iPadOS 13.4 Ble pairing popup triggered without read/write to protected characteristic

520 Views Asked by At

Pre iPadOS 13.4 we needed to read/write to protected characteristic of a peripheral device in order to trigger pairing popup. Starting iPadOS 13.4 - the passcode popup seems to be triggered simply via a successful connection with the peripheral (CBCentralManager().connect(peripheral, options: nil)).

I need to further communicate with the peripheral in order to get the passcode before the pairing popup is displayed. Once the pairing popup is displayed - the peripheral stops responding to any further requests.

Is this a design change or a bug on 13.4? I cannot find anything on the web/apple's release notes for iPadOS 13.4.

If this is a design change - what is an elegant way of handling this?

The following code triggers pairing on didConnect peripheral: //Sample Code

var centralManager: CBCentralManager?
var peripheral: CBPeripheral?

override func viewDidLoad() {
    super.viewDidLoad()
    centralManager = CBCentralManager(delegate: self, queue: nil)
}

func centralManagerDidUpdateState(_ central: CBCentralManager) {
    switch central.state {
    case .poweredOn:
        print("CentralManager state: Powered On")
        centralManager?.scanForPeripherals(withServices: [advertisingUUID], options: nil)
        print("Scanning for peripherals...")
    default:
        print("CentralManager state: Powered Off")
    }
}

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
       self.peripheral = peripheral
       self.peripheral?.delegate = self
       centralManager?.connect(peripheral, options: nil)
       centralManager?.stopScan()
}

func centralManager(_ central: CBCentralManager,
                           didConnect peripheral: CBPeripheral) {
    print("Peripheral Connected")
}

func centralManager(_ central: CBCentralManager,
                    didDisconnectPeripheral peripheral: CBPeripheral,
                    error: Error?){
    print("Peripheral Disconnected")
}
0

There are 0 best solutions below