Im trying to search for Bluetooth devices with this plugin:
https://github.com/nativescript-community/ble
And evertimy I try to search for devices with this code:
doStartScanning(){
{
this.isLoading = true;
// reset the array
this.observablePeripheralArray.splice(0, this.observablePeripheralArray.length);
this.bluetooth.startScanning(
{
filters: [{serviceUUID:'180d'}], // pass an empty array to scan for all services
seconds: 4, // passing in seconds makes the plugin stop scanning after <seconds> seconds
onDiscovered: function (peripheral) {
this.observablePeripheralArray.push(fromObject(peripheral));
}
}
).then(function() {
this.isLoading = false;
},
function (err) {
this.isLoading = false;
alert({
title: "Whoops!",
message: err,
okButtonText: "OK, got it"
});
});
};
}
I get this Error:
JS: Unhandled Promise rejection: Permission denied ; Zone: <root> ; Task: null ; Value: Permission denied undefined
Bluetooth is enabled and the permission granted from the Phone
it was a permissions error. Paste this in your android manifest.xml
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>