Launching iOS BLE Central app on iPhone restart

I am planning to develop an iOS app using the CoreBluetooth platform that constantly monitors the pedometer peripheral and counts steps.

I know that if the backgroud execution mode is set to BLE Central, the application will continue to receive BLE events even in the background.

Apple documentation states that in the event of an application terminated due to low memory, the system can track BLE events for a specific central manager if persistence is saved and restored.

Let's say I have an iOS app running in central mode. The app is subscribed to receive a notification from the pedometer when the step characteristic changes.

In my application, I accepted the following.

  • BLE Center background mode
  • Save / restore BLE state for Central Manager

I run my app, scan, pair and connect to the pedometer and the app starts getting steps.

My questions:

  • Now if the iPhone restarts, will I continue to receive BLE events so that my app can run in the background without having to manually restart the app and connect to the pedometer?

  • If the app is opened by the user using multitasking gestures, will the app be able to receive BLE events without having to manually restart the app and connect to a pedometer?

  • Is there a way to start my app on iOS boot?

+3


source to share


1 answer


  • Now if the iPhone restarts, will I continue to receive BLE events so that my app can run in the background without having to manually restart the app and connect to the pedometer?

Your app will not receive BLE events because all apps start in a terminated state after reboot (even though they stayed in the app switcher). The user will have to manually launch the application at least once after reboot in order for him to use BLE.

  1. If the app is opened by the user using multitasking gestures, will the app be able to receive BLE events without having to manually restart the app and connect to a pedometer?

Same as above, the application has entered a terminated state, so it won't be able to communicate using BLE until it is explicitly started again.

  1. Is there a way to start my app on iOS boot?


iOS does not provide any way to launch the app on boot.

The only exception to all this that I can find is iBeacons. If your app registers to receive updates for a specific iBeacon, iOS will launch your app when it detects it (even after a reboot or if the user explicitly kills it from the switch). When you receive the iBeacon callback, you can run all your BLE logic and it will run in the background as usual. Of course, this means that you need to advertise the iBeacon on your pedometer, which may or may not be feasible.

Remember that iBeacon detection is quite difficult, especially after a reboot. You have little guarantee as to how fast or even if an iBeacon callback will be sent to you to launch your application. But this is something.

Source

+3


source







All Articles