Here is a revised version of the response that follows the format you specified:
Answer
If I understand your question correctly, you are experiencing an issue where you can write a value successfully to a characteristic but do not receive a pairing request.
The pairing is triggered by the peripheral. Meaning the peripheral has to refuse the write or read request of your central to a characteristic. Your central gets the refusal “unauthorized authentication” and then tries to pair with the peripheral, showing the pairing alert pop up that you are waiting for.
This is all done by Core Bluetooth automatically. The only thing you need to do is change the characteristics options and permissions in your peripheral.
To trigger a pairing, modify the emailCharacteristic creation as follows:
emailCharacteristic = [[CBMutableCharacteristic alloc]
initWithType:emailCharacteristicUUID
properties:CBCharacteristicPropertyRead
| CBCharacteristicPropertyNotifyEncryptionRequired
value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
This change adds the permissions:CBAttributePermissionsReadEncryptionRequired parameter, which enables encryption for read operations.
Additionally, refer to the Apple sample code documentation and WWDC 2012 advanced Core Bluetooth video at 28 minutes, where they explain the concept of pairing.
Last modified on 2025-01-09