2
votes

I am successfully getting the data from BLE in the foreground and background state. And also called the respective delegate method of core Bluetooth framework.

After user force quits the app, I want the data from BLE device. Is it possible to get the data from BLE in not running state? Or Is there any method that will be called in not running state like iBeacon?

1

1 Answers

0
votes

I don't think that's possible unless using iBeacon BLE devices. As explained in Understanding When Your App Gets Launched into the Background section:

Apps that support background execution may be relaunched by the system to handle incoming events. If an app is terminated for any reason other than the user force quitting it, the system launches the app when one of the following events happens:

For Bluetooth apps:

  • An app acting in the central role receives data from a connected peripheral.
  • An app acting in the peripheral role receives commands from a connected central.

In most cases, the system does not relaunch apps after they are force quit by the user. One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user. In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system. When password protection is enabled on the device, the system does not launch an app in the background before the user first unlocks the device.

So when the app is force quit by user, and not by the system, it means that the user doesn't want the app running in the background and the app will not be re-launched and delegates won't be called.

But if the app was killed by the system, iOS will handle waking it up again when a delegate is called.