is it possible to get the users decision of the bonding request of iOS?
- Choice 1: Abbort
- Choice 2: Connect/Bond
Screenshot of Bonding-request:
I tried to use the centralManagerDidUpdateState, but it is called only one time with CBManagerStatePoweredOn if I turn Bluetooth on.
#pragma mark - CBCentralManagerDelegate
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
info(@"centralManagerDidUpdateState");
switch(central.state){
case CBManagerStateUnauthorized:
info(@"unauthorized");
break;
case CBManagerStatePoweredOff:
info(@"poweredOff");
break;
case CBManagerStatePoweredOn:
info(@"poweredOn");
break;
case CBManagerStateResetting:
info(@"resetting");
break;
case CBManagerStateUnknown:
info(@"unknown");
break;
case CBManagerStateUnsupported:
info(@"unsupported");
break;
}
}
I also tried to use "didConnectPeripheral" and "didFailToConnectPeripheral":
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
[peripheral setDelegate:self];
[self _cancelConnectionRequests];
[peripheral discoverServices:nil];
BleDevice* bleDevice = [knownDevices findDevice:[peripheral.identifier UUIDString]];
devicePaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
[peripheral setDelegate:self];
[self _cancelConnectionRequests];
[peripheral discoverServices:nil];
BleDevice* bleDevice = [knownDevices findDevice:[peripheral.identifier UUIDString]];
deviceNotPaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
But both methods are not called after clicking on "Abort" or "Connect/Bond"! At least only "didConnectPeripheral" is called while trying to connect to the device - but this happens before the popup comes up!
Any other ideas?
Note: I have no problems with scanning, connecting or bonding with a BLe device - I only want to know if the user accepted the bonding-request from his iPhone!