8

I am having an issue when instantiating my CBCentralManager. I get a "duplicate issue" message when monitoring it from the iOS console (it does not show in the XCode console).

I've tried updating the queue name and the restoration key id without success. This is how I instantiate my Central Manager:

CBCentralManager *central = [[CBCentralManager alloc] initWithDelegate: self 
    queue: dispatch_queue_create("com.mydomain.myapp.scanner", NULL)
    options: @{
        CBCentralManagerOptionRestoreIdentifierKey: @"hexa-string-comes-here"
    }];

And those are the errors I am getting:

CKLs-iPhone-5S securityd[78] : securityd_xpc_dictionary_handler MyApp[2571] add The operation couldn’t be completed. (OSStatus error -25299 - duplicate item O,genp,E99372E2,L,ck,X2W6M5UYJ9.com.mydomain.myapp,0,acct,svce,v_Data,20151218165347.298588Z,2CAE5650)

CKLs-iPhone-5S MyApp[2571] : SecOSStatusWith error:[-25299] The operation couldn’t be completed. (OSStatus error -25299 - Remote error : The operation couldn‚Äôt be completed. (OSStatus error -25299 - duplicate item O,genp,E99372E2,L,ck,X2W6M5UYJ9.com.mydomain.myapp,0,acct,svce,v_Data,20151218165347.298588Z,2CAE5650))

Any ideas?

Michael Dorner
  • 17,587
  • 13
  • 87
  • 117
marcelosalloum
  • 3,481
  • 4
  • 39
  • 63

2 Answers2

1

If you want to use the CBCentralManagerOptionRestoreIdentifierKey, you must

  1. implement the method

    // in Objective-C
    - (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary<NSString *, id> *)dict
    
    // or in Swift
    func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : AnyObject])
    

    from CBCentralManagerDelegate, and

  2. use the background mode Uses Bluetooth LE accessories set up in Xcode:

    enter image description here

Michael Dorner
  • 17,587
  • 13
  • 87
  • 117
0

This may be related to known Keychain issue. (However, it is only a guess that this is Keychain coming from Security log in your app). OSStatus duplicate item appears when there is already a registered item with all attributes supplied along with the item. So what could happen in here is:

  1. keychain failed to delete last restoration id - item is left in keychain.
  2. register for the restoration with the same id
  3. keychain tries to save item.
  4. it returns duplicate item error
Wladek Surala
  • 2,590
  • 1
  • 26
  • 31