I have a one BLE Device(Peripheral) and iOS Application which communicate to each other using CoreBluetooth.framework( connect, disconnect, subscribe, notify services). Here are the few scenario:
- The app is foreground -> I am very easily connected with BLE device.
- The app is in the background -> I get the callback and connect with the BLE device
- The app is removed from the background (Kill the app) -> I am not getting any callback even I connect the device from iPhone Device-> Settings-> Bluetooth on -> Select Ble Device -> Connect.
I google and get State Preservation and Restoration will be invoked the app. After deep drive :

This also showing App Force Quit by the user , app will not relaunch or active using state preservation and restoration.
I read from this, this and this, have some points :
"If you need to execute code when your app isn’t running, there are several options open to you depending on what you’re trying to do. - Background fetch will let your app run in the background for about 30 seconds at scheduled intervals. The goal of this is to fetch data and prepare your UI for when the app runs next. - Push notifications let your app fetch fresh data from your server. You can make a message appear on the device if you want, but it’s not required – silent push notifications let you skip that part. - Local notifications let you display an alert to the user, along with any media attachments you want and some options for the user to select from. If they choose those options then your app can be launched in the foreground or background to handle them."
I tried with Background Fetch, but it's also not awake when the application has been terminated.
My single objective to achieve is "When the application has terminated or killed by the user, Whenever BLE Device is connected the app should be invoked in foreground/background so that I will perform some operation like get the data from BLE Device and save it"
Other BackgroundModes also not gives any clue: 
How can achieve this without using push notification or silent notification? if anything in CoreBluetooth framework where the application awake after the termination, let me know?
from How to BLE device will invoke the app, when app has terminated
No comments:
Post a Comment