1
當應用程序由於狀態保存事件而與選項共享時,從AppDelegate恢復CBCentralManager的正確方法是什麼?CoreBluetooth狀態保存:正確的恢復方式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;
}
謝謝。我閱讀指南,但我不明白何時調用此方法。我無法添加一個斷點,我不知道如何測試這個..謝謝 – mm24