Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth #751

Open
Covarians opened this issue Mar 22, 2023 · 1 comment
Open

Bluetooth #751

Covarians opened this issue Mar 22, 2023 · 1 comment

Comments

@Covarians
Copy link

Covarians commented Mar 22, 2023

Hello,
I am using this superb plugin on an Android 12 device (SDK31+)
After bluetoothle.initialize I request the SCAN permission and then the CONNECT permissions and get responses that these two permissions are granted succesfully.
I can see on the android apps permission page that both Location and Nearby devices permission are allowed for my application.

But when I start the scan process I get the following error message

[BLE] ERROR in startScanning: "Need android.permission.BLUETOOTH_SCAN permission for AttributionSource { uid = 10388, packageName = com.covarians.aexpad, attributionTag = null, token = android.os.BinderProxy@729d2, next = null }: GattService registerScanner"

My AndoidManifest.xml file includes:

<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I tried the different variations recommanded but without any success

If I disallow and reallow manually the Nearby Device permission it works.

Any idea how to solve that strange behaviour.

Thanks a lot.

FG

@marcui13
Copy link

marcui13 commented Jul 25, 2023

Hi,
Have you tried requesting the ACCESS_FINE_LOCATION permission manually?
If you haven't, I'll show you how I've implemented it in my app.
In the page builder:

this.plt.ready().then((readySource) => { console.log('Platform ready from', readySource); this.androidPermissions .checkPermission( this.androidPermissions.PERMISSION.ACCESS_FINE_LOCATION ) .then( (result) => this.bluetoothService.initBLE(result), (err) => this.androidPermissions.requestPermission( this.androidPermissions.PERMISSION.ACCESS_FINE_LOCATION ) ); });

Dependencies:

(public bluetoothle: BluetoothLE,
public plt: Platform,
private androidPermissions: AndroidPermissions)

I hope this help you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants