Launching iOS BLE Central application on iPhone reboot

时间:2015-06-26 10:07:56

标签: ios core-bluetooth

I am planning to develop an iOS application using CoreBluetooth framework which monitors a pedometer peripheral continuously and counts the footsteps.

I know that if 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 case the app gets terminated due to low memory, the system can keep track of BLE events for a particular Central Manager if state preservation and restoration is adopted.

Assume I have an iOS application that operates in Central mode. The app is subscribed to receive notification from a Pedometer when ever the footstep characteristic changes.

I have adopted the following in my app.

  • BLE Central background mode
  • BLE State preservation/restoration for Central Manager

I start my app, Scan, Pair and Connect to the pedometer and the app starts receiving footsteps.

My Questions:

  1. Now if the iPhone reboots, Will I continue to receive BLE events so that my app will be launched in the background without the user having to manually launch the application again and connect to the pedometer?

  2. If the app is terminated by the user explicitly using the multitasking gesture, Will the app be able to receive BLE events without the user having to manually launch the application again and connect to the pedometer?

  3. Is there a way to launch my application on iOS boot up?

1 个答案:

答案 0 :(得分:3)

  
      
  1. 现在,如果iPhone重新启动,我是否会继续接收BLE事件,以便我的应用程序将在后台启动,而无需用户再次手动启动应用程序并连接到计步器?
  2.   

您的应用将不会收到BLE事件,因为所有应用都会在重启后以终止状态启动(尽管仍保留在应用切换器中)。用户必须在重启后至少手动启动一次应用程序才能使用BLE。

  
      
  1. 如果用户明确使用多任务处理手势终止应用程序,应用程序是否能够接收BLE事件而无需用户再次手动启动应用程序并连接到计步器?
  2.   

与上述相同,应用程序已进入终止状态,因此在再次明确启动之前,它无法使用BLE进行通信。

  
      
  1. 有没有办法在iOS启动时启动我的应用程序?
  2.   

iOS无法提供任何启动应用程序的方法。

我能找到的所有这一个例外是iBeacons。如果您的应用程序注册接收特定iBeacon的更新,iOS将在找到它时启动您的应用程序(即使重启后或用户明确将其从切换台中杀死)。获得iBeacon回调后,您可以启动所有BLE逻辑,然后按常规在后台运行。当然,这意味着你需要在你的计步器上做广告作为iBeacon,这可能是也可能是不可行的。

请记住,iBeacon的检测非常挑剔,尤其是重启后。您无法保证多快,甚至是否会通过iBeacon回调来启动您的应用。但它确实存在。

Source