is it possible to check if device is paired?

Hi, I am currently working on project that is using BLE.


My app will connect to bluetooth device to send some data.


iPhone itself is asking to pair with pop up message. (Such Pair / Cancel)


If I select to pair then my app will send data with encryption but it is still sending data without encryption even if I select cancel.


Is there any method that my app send data only when it is paired?


or is there any way I can check if device is paired? (not only connected)


Thank you in advance.

Replies

Is your app running in Peripheral Mode (CBPeripheralManager) or Central Mode (CBCenterManager) ?

I forgot to mention it in advance. My app is ruuing in Central Mode (CBCentralManager)

In your

CBCentralManagerDelegate
you should have

func centralManager(_ central: CBCentralManager,  didConnect peripheral: CBPeripheral)
.

You will receive this callback in the delegate when a peripheral device connects to your Central.

Similarly, you will get a call to

func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?)

when your peripheral disconnects. You will need to keep track of the connected devices using those functions in your delegate.

I see pairing pop up message after didConnect called.


Depends on choice of user if tap "pair" or "cancel" from bluetooth pair popup alert,


device send a data with encryption only when it is paired.


It even send a data without encryption when it is not paired but connected.


This is why I am looking for something that I can check if device is paired or not.


I want to make it send a data with encryption only.