【发布时间】:2016-01-12 12:56:52
【问题描述】:
当应用由于状态保存事件而获得选项午餐时,从 AppDelegate 恢复 CBCentralManager 的正确方法是什么?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// The system provides the restoration identifiers only for central managers that had active or pending peripheral connections or were scanning for peripherals.
NSArray * centralManagerIdentifiers = launchOptions[UIApplicationLaunchOptionsBluetoothCentralsKey];
if (centralManagerIdentifiers != nil) {
for (int i=0; i<[centralManagerIdentifiers count]; i++) {
NSString * identifier = [centralManagerIdentifiers objectAtIndex:i];
NSLog(@"bluetooth central key identifier %@", identifier);
// here I expect to re-instatiate the CBCentralManager but not sure how and if this is the best place..
}
}
// Override point for customization after application launch.
return YES;
}
【问题讨论】:
标签: ios cbcentralmanager ble-state-preservation