简体   繁体   English

无法重新启动充当BLE中央管理器的iOS应用

[英]Cannot relaunch iOS application which works as BLE central manager

I'm developing a iOS application which works as BLE Central. 我正在开发一个可作为BLE Central的iOS应用程序。 I want to relaunch the application, even after its termination, if it detects peripheral devices. 我想重新启动该应用程序,即使它终止后也可以检测到外围设备。

I created my central manager according to the Apple's programming guide in section "Performing Long-Term Actions in the Background". 我根据Apple的编程指南“在后台执行长期操作”部分创建了我的中央管理器。 https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW1 https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW1

But the app. 但是应用程序。 relaunches only in particular condition. 仅在特定条件下重新启动。

  • Start [RUN] on Xcode and go into backgroud by pushing [HOME] of iPhone, then [STOP] on Xcode 在Xcode上启动[RUN],然后按iPhone的[HOME]进入背景,然后在Xcode上按[STOP]

In this case, my app relaunch ([application didFinishLaunchWithOption] and [central willRestoreState] is called) after peripheral device start advertising. 在这种情况下,外围设备开始投放广告后,我的应用程序重新启动([应用程序didFinishLaunchWithOption]和[central willRestoreState]被调用)。

In the situations like below my app doesn't relaunch even after peripheral device start advertising. 在以下情况下,即使外围设备开始投放广告,我的应用也无法重新启动。

  • Start [RUN] and [STOP] on Xcode (Stop when the app. is in foreground) 在Xcode上启动[RUN]和[STOP](当应用程序处于前台时停止)
  • When the app. 当应用程序。 is in background, double click [HOME] on iPhone and terminate the app. 在背景中,双击iPhone上的[HOME]并终止该应用程序。 by swiping upward. 向上滑动。
  • After the reboot of iPhone iPhone重启后

I'm creating and initiating my central manager normally. 我通常会创建并启动我的中央经理。

    NSDictionary *options = @{
        CBCentralManagerOptionRestoreIdentifierKey : kBlitCentralMgrRestoreIdKey,
        CBCentralManagerOptionShowPowerAlertKey : @YES,
    };
     self.centralMgr = [[[CBCentralManager alloc] initWithDelegate:self queue:nil options:options] autorelease];

If you have any idea to resolve the issue, please let me know. 如果您有解决问题的想法,请告诉我们。 I appreciate you kind cooperation. 感谢您的合作。

If you swipe the app from the App Switcher to kill it, the OS will not relaunch it. 如果您从应用切换器上滑动该应用以将其杀死,则操作系统将不会重新启动该应用。 This is the same case with apps that rely on Background App Refresh. 依赖于后台应用刷新的应用也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM