iOS - Bypass Pairing alert for bluetooth - ios

I'm using Core Bluetooth framework in my iOS app to communicate securely with BT devices. In my product, server sends a pairing code that user has to enter in the text box in peripheral device’s alert to complete the pairing process. It's working good.
As server sends the code, without showing the pairing alert, can I by-pass the alert and handle the code that pairs the device without user's intervention.

No, if you are using encryption on any of your characteristics an attempt to read or write that characteristic will trigger the iOS pairing dialog.
Your app has no direct access to the pairing process as it happens outside of your app.

Related

How do I initiate pairing with a BLE peripheral that uses unprotected ATT attributes?

We are developing an iOS app that must pair (and bond) with a BLE peripheral before our app can proceed with other steps. From what I understand Apple wants accessories to follow this flow to initiate pairing:
iOS device connects to accessory
iOS device attempts to access an attribute that requires special permissions (e.g. authenticated connection or encrypted connection)
Accessory rejects the attribute access with an “Insufficient Authentication” error code
iOS realizes it needs to initiate pairing, so it generates a pairing popup that allows the user to initiate it
The problem is that the firmware on our BLE peripheral can not be altered. All of its BLE attributes are unprotected and do not require an encrypted or authenticated connection to access these attributes. So in this case, how can we get iOS to generate the pairing popup so that the user will have the ability to pair?
I realize that my question is related to How to bond/pair to a bluetooth LE device programmatically in swift Xcode?, but it differs in that we can not change the permissions used by the characteristics of our BLE peripheral. We have no control over the firmware.
Thanks in advance.

iPhone Bluetooth pairing without confirming passcode

In my BLE app, the user story is like, bluetooth pairing should happen without the passcode confirmation step. As far as i have researched so far, it is possible in Android (like Android Bluetooth Pairing without User Enter Pin and Confirmation Using Android API)
Is it possible in iPhone?
Sadly, on iOS it is not possible to skip the pairing dialog. It is directly sent from the OS. It is a strict convention from apple that apps are not able to skip security processes.
Some additional information:
Dependent on the IOCapabilityResponse from the peripheral device on bluetooth level iOS will show you a dialog asking to pair or to confirm a pass code. If iOS will show you the dialog at all depends if the bondable flag is set in the IOCapabilityResponse from the peripheral.
There are three types of connection in BLE:
connection: pin not required, connection not secure
pair: pin could be requested or not, connection secured with short term key, a popup will be displayed
bond: pin could be requested or not, connection secured with long term
key, a popup will be displayed
All of these method are managed by BLE peripheral firmware, iOS only adapts its connection based on how the peripheral is configured

iOS: Does a pairing window always display when connecting to a BLE device?

I want to avoid the BLE pairing pop up window on iOS when connecting to a small disposable device. The device will only be used once. If the device is advertising for its lifetime (no more than a few minutes) and does not require encrypted communication. Will an app that I develop be able to directly communicate with the device without displaying a pairing popup?
The pairing pop up is only shown if a characteristic specifies that encryption is required. If no encryption is specified by the peripheral then no pairing dialog is shown.
If you aren't getting the behaviour you desire, you need to change your peripheral or not access the encrypted characteristic from your central.
If you pair the devices, then the user must accept that. But if you just connect and communicate with GATT characteristics that don't need pairing, you don't need to pair and hence no popup.

Handling multiple Bluetooth Pairing Request Dialogs at once

I have an app that integrates with BLE devices. I can connect to any number of devices. When initiating a pairing from the app to the device via [CBCentralManager connectPeripheral:options:] the system bluetooth pairing request alert will fire if no previous pairing information is found. This all works great.
However, I am implementing a functionality that discovers, pairs, and reads characteristics from multiple devices at once. This also works great if the devices have been paired previously. But if this is the first pairing for more than one of the devices, only one of the pairing request alert controllers is displayed. What makes this even more difficult is that I also don't receive a failed connection error from CB for the other devices waiting for response from the pairing dialog.
Is there any way I can elegantly handle situations where there are multiple pairing requests needing attention? It would be helpful if at least one of these was possible:
The ability to complete the outstanding pair requests sequentially
Notification of failed pairing for other devices
Knowledge of whether a pairing request dialog will be fired before initializing the pairing so I can pair one at a time
There are no APIs in CoreBluetooth that lets you interact with the pairing.
Are you in control of the firmware of the peripherals you want to be able to pair with? If so, you can enable notifications and send events how the pairing process is going. That way you know in the app the current status of a pairing process.
For some examples, by looking at status and error codes (details depends on your peripheral BLE stack), you will be able to identify when iOS shows the pair dialog, when the user presses cancel and when pairing succeeds. It will also be possible to identify when iOS didn't put up the pair dialog.

ios Core BlueTooth Pairing to External BLE Device

I am making an BLE based application.
As I know Bluetooth Pairing is handling ios internally.
Is there any possiblity to get access over bluetooth pairing request in ios . I am getting pairing request from external BLE Device but i am not able to know whether user is paired or cancelled.
Apps like TI SensorTag and Multitool apps are handling the pairing request when user clicks cancel then these apps disconnects the peripheral.
I am not getting any clue how they are handling the pairing.
Please help me in getting this solved.
Thanks
The BLE devices are more then likely handling the cancel on their side. When you click cancel through iOS it does not pair and does not enable encryption. At this point the BLE devices are probably issuing a disconnect because encryption has not been started.
The only time you will see that pairing message is when encryption is being requested.

Resources