I am using Apple's Core Bluetooth example code (here, with slight modifications) to scan for Bluetooth Low Energy devices and connect with the device I want. On the first connect this brings up the iOS pairing dialog. Also, if the device is forgotten and then scanned and connected to again, that brings up the pairing dialog again.
The dialog comes up not when [central connectPeripheral]
is called, but the first time that there is a call to either [peripheral setNotifyValue:YES forCharacteristic:c]
or [peripheral writeValue:data forCharacteristic:c]
.
Is there a way to tell if the pairing dialog will come up before it does? (i.e. whether the OS has stored pairing info for a particular peripheral?)
I need to know before I do either of the calls that might bring up the dialog whether the dialog would come up, so I can show some instructions to the user.