Reputation: 21
I'm new in the world of the Ionic framework and I'm developing an Ionic app using bluetooth-low-energy (the cordova plugin ble-central). Everything has worked well until two days ago. Now, the scan()
function doesn't work anymore. The function is correctly called and the bluetooth and location permission are allowed. I've made no changes on my code that would explain this issue. I've also tried to uninstall/install the app, reboot my android phone and also used another phone. Nothing work.
Below a snips of my manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-feature android:name="android.hardware.location.gps" />
and the bluetooth code:
this.ble.scan([], 5).subscribe(
device =>
this.onDeviceDiscovered(device),// Never reached
error => {
this.scanError(error).catch(e => console.log('scan error ' + e)); // Never reached
},
() => console.log('completed')); // Never reached
// Debug
setTimeout(this.setStatus.bind(this), 6000, 'Scan completed');
The function setStatus
is for debugging.
I've read and tried a lot of things but nothing work. Thanks for your help!
PS: Of course, the bluetooth and the gps are active when I'm using my app.
Upvotes: 2
Views: 2490
Reputation: 2848
Since android api 29, ACCESS_FINE_LOCATION permission is used instead of ACCESS_COARSE_LOCATION. The mantainer of cordova-plugin-ble-central have not accepted a pull request that correct this issue yet.
I did the necessary changes on my fork and it is working fine now on android 10, api 29...
Maybe you can use it by removing the old:
ionic cordova plugin rm cordova-plugin-ble-central
And adding my fork:
ionic cordova plugin add git+https://github.com/dslima90/cordova-plugin-ble-central.git
Upvotes: 2