Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoreBluetooth[WARNING] has no restore identifier but the delegate implements

I'm using the CoreBluetooth but I got this warning message in the output.

CoreBluetooth[WARNING] has no restore identifier but the delegate implements the centralManager:willRestoreState: method. Restoring will not be supported!

I'm using this code:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], CBCentralManagerOptionShowPowerAlertKey, nil];

myCentralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];

I don't know what's wrong.

Thanks.

like image 376
Benoît Freslon Avatar asked Jan 06 '14 18:01

Benoît Freslon


1 Answers

This is in regards to CoreBluetooth's save/restore optional feature, see "Opt In to State Preservation and Restoration" part of the documentation for more details.

What looks to be happening is that you are implementing the right delegate method to use this feature but you are not providing a restoration identifier in your call to initialize the CBCentralManager.

There are two options to resolve the warning:

  1. If you want to use this feature you should provide a string identifier that represents the central or peripheral manager to CBCentralManager like so:

    myCentralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil
         options:@{ CBCentralManagerOptionRestoreIdentifierKey:
         @"myCentralManagerIdentifier" }];
    
  2. If you don't want to use this feature then remove the centralManager:willRestoreState: method from your delegate.

Doing either one should resolve your warning.

like image 96
foggzilla Avatar answered Oct 01 '22 22:10

foggzilla