简体   繁体   中英

Cannot relaunch iOS application which works as BLE central manager

I'm developing a iOS application which works as BLE Central. 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". 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

In this case, my app relaunch ([application didFinishLaunchWithOption] and [central willRestoreState] is called) after peripheral device start advertising.

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)
  • When the app. is in background, double click [HOME] on iPhone and terminate the app. by swiping upward.
  • After the reboot of 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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