1
votes

I have an iPhone app that receive BLE info from a particular device. The device sends data to my app anytime it has something to report, and the transmission rate is about 2K Bytes per second.

The problem is that my app can be killed in the background mode by iOS and I can get no indication about this. If the device start to send ble data after my app is killed, my app can only get the last data packet after it is woken up by the system and lost all the data during the wake up procedure.

How can I get all the BLE data after my app is woken up and restored by the system?

PS: I have added Bluetooth-central under UIBackgroundModes in the Info.plist. In background mode didUpdateValueForCharacteristic: method is being called. Also, a CBCentralManagerOptionRestoreIdentifierKey is specified while I construct the CBCentralManager.

1
You can store the packets when this call happens developer.apple.com/documentation/uikit/uiapplicationdelegate/… and when the app is woken up you can restart. Also, stackoverflow.com/questions/33125295/… for proper state preservations.Sachin Vas
@Sachin Vas I subscribed notification of characteristic.[peripheral setNotifyValue:true forCharacteristic:ch]; System will relaunch my app when peripheral notify data. but I only get the last data by reading the property named value, and peripheral already notify lost of data before my app can work. @ property(retain, readonly, nullable) NSData *value;roMoon

1 Answers

0
votes

On iOS you can ensure that your app isn't completely killed by the system by using State Preservation and Restoration. Please have a look at the following link for more info:-

Core Bluetooth Background Processing for iOS

However, please note that you cannot use this if you force kill the app. There's more information about this in the following question:-

BLE device keep connect with iPhone when application terminate