bluetooth-le icon indicating copy to clipboard operation
bluetooth-le copied to clipboard

Scanning in background in Android should use a Pending Intent

Open omercnet opened this issue 4 months ago • 0 comments

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:

  1. Launch a BLE Scan
  2. Close device screen
  3. Broadcast on BLE device
  4. 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

omercnet avatar Oct 20 '24 17:10 omercnet