don / cordova-plugin-ble-central

Bluetooth Low Energy (BLE) Central plugin for Apache Cordova (aka PhoneGap)
Apache License 2.0
951 stars 606 forks source link

startScan fails silently if location services are disabled #872

Open peitschie opened 2 years ago

peitschie commented 2 years ago

As per https://github.com/don/cordova-plugin-ble-central/blob/f5569e48262da901ee3b82b81ade3c73c5418f8b/src/android/BLECentralPlugin.java#L712

This should fail the scan callback so the calling app understands that the scanning is not in progress.

peitschie commented 2 years ago

Seems there's a bit of history around this behaviour

Any solution here will need to figure out how to determine whether the scan might work or not...

sam-higgs commented 2 years ago

Any updates on this? If global permissions on Android are disabled, no error is thrown from isEnabled() or startScan()

peitschie commented 2 years ago

Hi @sam-higgs

Nothing specific yet. The linked discussions above suggest there are some phones out there that are allowed to scan despite the location service being disabled, so I'm reluctant to force it one way or another.

In practice, this is something the application itself can do by checking ble.isLocationEnabled manually before starting a scan: https://github.com/don/cordova-plugin-ble-central#islocationenabled

But... it's still on my radar!