bluetooth-le
bluetooth-le copied to clipboard
Scanning in background in Android should use a Pending Intent
Describe the bug The current implementation does not allow connecting to BLE device after the app is backgrounrded
To Reproduce Steps to reproduce the behavior:
- Launch a BLE Scan
- Close device screen
- Broadcast on BLE device
- Wait forever
Expected behavior The app should find the device in the background
Screenshots If applicable, add screenshots to help explain your problem.
Plugin version:
- @capacitor-community/bluetooth-le: v6.0.1
Additional context https://developer.android.com/develop/connectivity/bluetooth/ble/background
In android, to receive scan results in the background, the startScan method should be called with a Pending Intent and not a ScanResult
See https://github.com/android/platform-samples/blob/main/samples/connectivity/bluetooth/ble/src/main/java/com/example/platform/connectivity/bluetooth/ble/BLEScanIntentSample.kt#L114-L120 for an official example