You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error unsubscribing from notifications: PlatformException(reactive_ble_mobile.Central.(unknown context at $101519dac).Failure:1, The operation couldn’t be completed. (reactive_ble_mobile.Central.(unknown context at $101519dac).Failure error 1.), {}, null)
#884
Describe the bug
I am experiencing an issue with BLE notifications in my Flutter application using the flutter_reactive_ble package. Notifications work correctly on Android, but on iOS, they automatically unsubscribe without any explicit action, leading to no notifications being received.
I receive the following error: Error unsubscribing from notifications: PlatformException(reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure:1, The operation couldn’t be completed. (reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure error 1.), {}, null)
To Reproduce
Steps to reproduce the behavior:
Connect to a BLE device that supports notifications.
Subscribe to notifications for a characteristic.
Send data to the characteristic using writeCharacteristicWithoutResponse.
Observe that notifications are received on Android, but on iOS, they stop with an error as: Error unsubscribing from notifications: PlatformException(reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure:1, The operation couldn’t be completed. (reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure error 1.), {}, null)
Expected behavior
I expect to receive notifications continuously from the device on both iOS and Android after sending data.
I tried doing the same with a general BLE scanner application (e.g. nRF Connect) and it exhibits the expected behavior as described above: Not Used
Smartphone / tablet
Iphone 15 Plus
OS: iOS 18.0.1
Package version: 5.3.1
Peripheral device
Vendor, model: Nedap NVite Reader
Does it run a custom firmware / software: no
Additional context
The logs for both the OS are as follows
iOS Logs
flutter: 080000000000000552
flutter: 7cfe70936cba9edcc187d53faf4b176b
Warning! No event channel set up to report a connection update
flutter: Service UUID: 180a
flutter: Service UUID: 87b1de8d-e7cb-4ea8-a8e4-290209522c83
flutter: isNotifiable: true
flutter: Data sent: [8, 0, 0, 0, 0, 0, 0, 5, 82]
flutter: Error unsubscribing from notifications: PlatformException(reactive_ble_mobile.Central.(unknown context at $101519dac).Failure:1, The operation couldn’t be completed. (reactive_ble_mobile.Central.(unknown context at $101519dac).Failure error 1.), {}, null)
The text was updated successfully, but these errors were encountered:
I see that the exception happens when it is trying to unsubscribe from the notifications. That suggests to me that the device is actually disconnecting.
Can you also print what you get on the streams statusStream and connectedDeviceStream?
The issue was resolved by first calling the following line of code to read the characteristic:
final response = await flutterReactiveBle.readCharacteristic(notificationCharacteristic);
Once the characteristic was successfully read, I then used the following code to subscribe to the characteristic and listen for incoming notifications:
flutterReactiveBle.subscribeToCharacteristic(notificationCharacteristic).listen((data) { // code to handle incoming data }, onError: (dynamic error) { // code to handle errors });
This sequence of calls allowed me to read the characteristic and properly listen for updates without further issues in iOS.
Describe the bug
I am experiencing an issue with BLE notifications in my Flutter application using the flutter_reactive_ble package. Notifications work correctly on Android, but on iOS, they automatically unsubscribe without any explicit action, leading to no notifications being received.
I receive the following error:
Error unsubscribing from notifications: PlatformException(reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure:1, The operation couldn’t be completed. (reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure error 1.), {}, null)
To Reproduce
Steps to reproduce the behavior:
Error unsubscribing from notifications: PlatformException(reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure:1, The operation couldn’t be completed. (reactive_ble_mobile.Central.(unknown context at $101c31dac).Failure error 1.), {}, null)
Expected behavior
I expect to receive notifications continuously from the device on both iOS and Android after sending data.
Smartphone / tablet
Peripheral device
Additional context
The logs for both the OS are as follows
Android Logs
D/BluetoothGatt(29225): connect() - device: XX:XX:XX:XX:36:BA, auto: true
D/BluetoothGatt(29225): registerApp()
D/BluetoothGatt(29225): registerApp() - UUID=376c6bd9-06a3-46b0-b08b-05af7be6a55b
D/BluetoothGatt(29225): onClientRegistered() - status=0 clientIf=5
D/BluetoothAdapter(29225): getBleEnabledArray(): ON
D/BluetoothGatt(29225): onClientConnectionState() - status=0 clientIf=5 device=XX:XX:XX:XX:36:BA
D/BluetoothGatt(29225): discoverServices() - device: XX:XX:XX:XX:36:BA
D/BluetoothGatt(29225): onConnectionUpdated() - Device=XX:XX:XX:XX:36:BA interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt(29225): onSearchComplete() = Device=XX:XX:XX:XX:36:BA Status=0
I/flutter (29225): Service UUID: 00001800-0000-1000-8000-00805f9b34fb
I/flutter (29225): Service UUID: 00001801-0000-1000-8000-00805f9b34fb
I/flutter (29225): Service UUID: 0000180a-0000-1000-8000-00805f9b34fb
I/flutter (29225): Service UUID: 87b1de8d-e7cb-4ea8-a8e4-290209522c83
D/BluetoothGatt(29225): onConnectionUpdated() - Device=XX:XX:XX:XX:36:BA interval=39 latency=0 timeout=500 status=0
I/flutter (29225): Data sent: [8, 0, 0, 0, 0, 0, 0, 4, 88]
I/flutter (29225): isNotifiable: true
D/BluetoothGatt(29225): setCharacteristicNotification() - uuid: 540810c2-d573-11e5-ab30-625662870761 enable: true
I/flutter (29225): Got Notification
I/flutter (29225): Notification data: [65, 127, 143, 162, 132, 86, 72, 234, 172]
I/flutter (29225): 417f8fa2845648eaac
D/BluetoothGatt(29225): onClientConnectionState() - status=19 clientIf=5 device=XX:XX:XX:XX:36:BA
D/BluetoothGatt(29225): setCharacteristicNotification() - uuid: 540810c2-d573-11e5-ab30-625662870761 enable: false
iOS Logs
flutter: 080000000000000552
flutter: 7cfe70936cba9edcc187d53faf4b176b
Warning! No event channel set up to report a connection update
flutter: Service UUID: 180a
flutter: Service UUID: 87b1de8d-e7cb-4ea8-a8e4-290209522c83
flutter: isNotifiable: true
flutter: Data sent: [8, 0, 0, 0, 0, 0, 0, 5, 82]
flutter: Error unsubscribing from notifications: PlatformException(reactive_ble_mobile.Central.(unknown context at $101519dac).Failure:1, The operation couldn’t be completed. (reactive_ble_mobile.Central.(unknown context at $101519dac).Failure error 1.), {}, null)
The text was updated successfully, but these errors were encountered: