0

I want to remove paired bluetooth device from system settings or "unpair". I know that apple doesn't provide public api to do this so I tried private class CBPairingAgent. I found headers on github CBCentralManager.h CBPairingAgent.h and here is my code:

- (void)unpair:(CBPeripheral *)peer {
    id agent = [self.centralManager valueForKey:@"sharedPairingAgent"];
//    [agent performSelector:@selector(setDelegate:) withObject:self.centralManager];
    [agent performSelector:@selector(unpairPeer:) withObject:peer];
}

This code runs without errors but also without any effect for peripheral.

Can somebody point me in right direction? Or suggest better way

sage444
  • 5,661
  • 4
  • 33
  • 60

1 Answers1

1

The private API to remove a device pairing works if the process has enough entitlements, which is only possible on a JB device.

On JB, I've added these entitlements (found in Settings & SpringBord):

  • com.apple.BTServer.allowRestrictedServices
  • com.apple.BTServer.le
  • com.apple.BTServer.programmaticPairing
mringwal
  • 476
  • 3
  • 10
  • sounds interesting, can you share a code that works with those entitlements ? – sage444 Mar 16 '17 at 11:11
  • The code shown above should work. Just get the CBPairingAgent from your CBPeripheralManager and call unpairPeer: with the CBPeripheral* to remove. – mringwal Mar 16 '17 at 15:28
  • I don't have JB device and can't check it. Maybe someone else will check it, thank you – sage444 Mar 16 '17 at 15:32