is it possible to connect bluetooth device, without pairing them in iOS?

902 views Asked by At

The question is not for BLE device, its just normal bluetooth device.

currently my code works like this, I call the function :

[[EAAccessoryManager sharedAccessoryManager] showBluetoothAccessoryPickerWithNameFilter:nil completion:^(NSError *error)
        {

        }];
    }

and it opens the popup with list of available Bluetooth device, then i click on my desired device and get an object and go ahead.

Is there any way that i can skip this picker step and directly get an object of my device?

1

There are 1 answers

3
Samuel Peter On

No, it's not possible to connect without pairing first. The first time, you must have the user pair with the device either from the Settings app or from the picker. After the first pairing, however, you can skip the picker and get an EAAccesory * for your accessory, if the accessory is already connected to the iOS device. Here is how you can query the list of connected accessories:

NSArray<EAAccessory *> *connectedAccessories = [EAAccessoryManager sharedAccessoryManager].connectedAccessories;
for (EAAccessory *accessory in connectedAccessories) {
    // Implement needed filter to recognize your device.
    // You can use for instance accessory.protocolStrings
    // The MAC address is available with [accessory valueForKey:@"macAddress"]
}

With the EAAccessory framework you can't initiate a connection to a device programmatically. For subsequent connections, you can have your device reconnect to the last connected device (if you control the firmware). This will trigger the EAAccessoryDidConnectNotification if your app is in the foreground, otherwise it will queue the notification and update the list of connected accessories.