Post

Replies

Boosts

Views

Activity

Reply to Issue with CBConnectPeripheralOptionNotifyOnConnectionKey Not Triggering Alert When Reconnecting in Background
Thank you for your response. To clarify my setup and issue, I have removed the bluetooth-central key from my plist. Here's what I'm doing to test the system alert behavior: Initially, I connect my central to the peripheral. After the connection, I move the central app to the background. Then, I turn off Bluetooth on the peripheral (which disconnects the central from the peripheral). Afterward, I turn Bluetooth back on in the peripheral (which should trigger it to re-advertise). However, even though the peripheral is re-advertising and the CBConnectPeripheralOptionNotifyOnConnectionKey option is set to true, I'm not seeing the system alert. Could you please help clarify why the alert is not appearing under these circumstances?
Jan ’25
Reply to Issue with CBConnectPeripheralOptionNotifyOnConnectionKey Not Triggering Alert When Reconnecting in Background
To clarify my setup: The peripheral app has bluetooth-peripheral in its Info.plist. The central app has bluetooth-central in its Info.plist. In my central app, I’m passing the CBConnectPeripheralOptionNotifyOnConnectionKey: true option when calling centralManager.connect after discovering the peripheral: func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { if let peripheralName = advertisementData[CBAdvertisementDataLocalNameKey] as? String, peripheralName == "test-device-1" { // Stop scanning to save power centralManager.stopScan() // Save a reference to the discovered peripheral self.discoveredPeripheral = peripheral let options: [String: Any] = [ CBConnectPeripheralOptionNotifyOnConnectionKey: true] // Connect to the peripheral centralManager.connect(discoveredPeripheral!, options: options) } else { print("No peripheral discovered to connect to.") } } However, when I move the central app to the background and toggle Bluetooth off/on in Settings, the peripheral reconnects, but I’m not seeing the expected alert. Am I missing any steps, or is there another way to verify this behavior?
Jan ’25