My scenario is:
Another (whatever app it is) try to retrieve the value from a Bluetooth device, But Bluetooth device doesn't send data other than our application.
Another application wants Bluetooth data it needs to call our app in background mode to perform an operation also in the background.
In short:
Retrieve data from Bluetooth in the background and share that content to another application.
If I tried using Custom URL it's open our application into the foreground. So, this one not covers our expectation.
Is that possible with Widget kind of? or any other method.
If any info missed let me know to understand my scenario.
Related
I'm working on an iPhone app to control some custom BLE hardware. I am able to talk to my device and generate all required controls, but my problem now comes with setting up UserNotifications.
Part of the functionality of this device is to alert the user if one of the BLE characteristic values gets outside of a certain range. When the app is in focus, I am able to do this via UIAlerts. I have played with UserNotifications and I can trigger a notification while the app is focused so that the notification will appear after a specific interval. My issue is trying to generate a UserNotification based on data that's coming over a BLE connection in an app that's not focused.
I can tell via LED's on my hardware that the BLE connection is being maintained even while I'm out of focus/locked. Is there a way to evaluate data from a background BLE connection and create a UserNotification based on it?
I found This Question on StackExchange asking basically the same thing, but I'm hoping that several years later there may be more answers out there.
Cheers,
Roger
Paulw11 above mentioned the app being set up for background operation, which I was not aware of (I'm really new to IOS, I'm more of a low-level firmware guy).
It was just a matter of setting up Xcode background mode to let this run in the background, now I can alert the user regardless of whether the app is Active or Background.
I know, from documentation, that iOS application can scan for BLE devices when it is in background mode. It can also retrieve data form peripherals devices.
Question
What can I do with this data. My purpose is to save this data (after deserialize of course) to core data. How can I do that?
If this is not possible, what is the recommended way to do it? (NSUserDefaults and after sync with CoreData?)
(iOS10, Swift3)
While in background an app registered to BLE event will be awaken by the system in occurrence of BLE related event that you are registered for. Then the appropriate delegate methods will be called as documented in the official apple documentation.
Events that will awake your app from the BLE are notifications, new peripheral if you are in discovery mode, new connection events (connection/disconnection).
From the moment the app is awaken by the system you have roughly 8 seconds to execute your code and respond to the BLE update. In this time window you can perform any kind of operation you wish, including core data related jobs.
Please consider to read this document released by apple to help developers to develop amazing apps that works with BLE: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html
I am working on developing a bluetooth peripheral to work with my iOS device. I need to make the iOS app receive data whilst it's in background and process that data as it comes. Looking through Apple's CoreBluetooth framework, I can see how the background execution modes can be used. Now to save power, I want the iOS device to only connect to the bluetooth peripheral at a certain time (without need of user interaction). I've looked through Local Notifications on iOS and it has very limited functionality and don't think it provides what I need.
So is there anyway to wake up an app at 6pm and ask the application to start scanning for bluetooth devices? And then execute other code once device is connected? All this without user interaction.
Any suggestions would be appreciated!
Thanks!
You can't really schedule operations to occur at a specific time in iOS (aside from local notification, which as you said isn't what you need).
You can use background fetch mode to periodically allow your app to check for new data. You can set an interval (although this is only a guideline to iOS, not a strict schedule) for how often your app is woken.
When iOS calls your app delegate performFetchWithCompletionHandler method you can check the current time and decide whether you want to transfer data. If not then you can quickly return UIBackgroundFetchResultNoData. If you do get new data then you can retrieve it before returning UIBackgroundFetchResultNewData
I am developing a Bluetooth Low Energy (4.0) device that works with an iOS app and uses CoreBluetooth. I have successfully created this app and it interacts with the device just fine. However, now that iOS 8 allows developers to implement custom widgets, I want to display a "Disconnect" button in the UINotification "Today" Center.
The issue is this: I believe I have read that there is no way to communicate between the widget and the app meaning that the widget has it's own container. This also means then that I cannot access the Bluetooth object in the app that is holding the reference to my Bluetooth device from the widget itself in order to disconnect the object. I am able to create a new Bluetooth object inside the widget class and retrieve the bluetooth connection from the iOS system but even I disconnected the BT device at this point, it would still be holding a reference inside the app.
Can anyone offer any insight on wonder what I am trying to do is possible?
You could possibly use a shared NSUserDefaults database to transfer data between your app and extension. You may also be interested in NSUserDefaults key value observing.
App extensions are meant to be independent from their containing app, and I'm not sure they were meant for this purpose.
However, another option would be to implement a custom URL scheme for your containing app, and then to use openURL to open your containing app and execute a disconnect action (or anything else you'd like your extension to do).
I have a fitness app that is already in the app store and now I want to implement a bluetooth device that users can purchase if they wish. This is my first time dealing with bluetooth and after reading "Core Bluetooth Programming Guide", I have the following questions.
My app contains information that my bluetooth device requires simply to display the data. If I'm not mistaken, this makes the app the "Peripheral" because it has the data. The bluetooth device wants the data from the app so that makes the bluetooth device the "Central". Am I correct about this?
Finally, here is where I get confused. The bluetooth device has a button that I want when pressed to trigger the app to get the app to send new values to the bluetooth device. Is this possible? The reason I ask because in this scenario, would this now mean that the bluetooth device is the peripheral and the app is the central? If yes, will I have to break the current connection between the two in order to switch their roles (manager, and peripheral)?
Thank you in advance, really appreciate it!
Ted
As you have control over coding the app and coding the device, you can make it work either way around (Assuming the device is to be used specifically with your app and nothing else).
Both central and peripheral have methods to read and write data from/to the peripheral.
Without more information on the data and how often it's updated, it's difficult to suggest the best way to do it.
You say your device will have a button that will tell the app to send data over to it, well the app won't need to send anything it simply keeps values up to date then your button would tell your device to read the latest value.
Or (Again without knowing the purpose this may not suit) you do away with the button completely and your device subscribes to a characteristic in the app and is notified every time the value is changed by the app.