don / cordova-plugin-ble-central

Bluetooth Low Energy (BLE) Central plugin for Apache Cordova (aka PhoneGap)
Apache License 2.0
942 stars 603 forks source link

The connectCallback of ble.connect() always got called not matter if it's really connected when first pairing #636

Open qiluo opened 5 years ago

qiluo commented 5 years ago

When my app was trying to connect a new device, there was a system message "The xxx would like to pair with your iPhone", you can choose "Cancel" or "Pair" then.

If click "Pair", everything was fine.

If click "Cancel", the both connectCallback and disconnectCallback got called, first connectCallback then disconnectCallback

I'm on plugin 1.2.2 and iOS

don commented 4 years ago

Pairing isn't well supported. If the plugin can create a peripheral object, it calls the success callback.

https://github.com/don/cordova-plugin-ble-central/blob/f2d42938a7ffb608e811fa60afffc349fc14a6cf/src/ios/BLECentralPlugin.m#L73

Then when you cancel pairing it disconnects.

Hopefully your app can work around this for now.