Bevin
Bevin

Reputation: 41

Ionic Cordova Bluetooth Serial Permissions Issue on Android 12

I need assistance with the Bluetooth Serial plugin, when l check for bluetooth.isEnable it returns Ok or is Disabled which is correct. If l try to use any other functions for example List or discoverUnpaired l get the error below ERROR "Need android.permission.BLUETOOTH_SCAN permission for AttributionSource { uid = 10467, packageName = com.fire.service.app, attributionTag = null, token = android.os.BinderProxy@a208f16, next = null }: Starting discovery."

Your assistance will be much appreciated.

Below is my environment Ionic: Ionic CLI : 6.20.1 Ionic Framework : @ionic/angular 6.2.2 @angular-devkit/build-angular : 13.0.4 @angular-devkit/schematics : 13.0.4 @angular/cli : 13.0.4 @ionic/angular-toolkit : 5.0.3

Cordova: Cordova CLI : 11.0.0 Cordova Platforms : android 10.1.2 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 14 other plugins)

Utility: cordova-res : 0.15.4 native-run (update available: 1.7.1) : 1.5.0

System: NodeJS : v14.15.4 (C:\Program Files\nodejs\node.exe) npm : 6.14.10 OS : Windows 10

Upvotes: 2

Views: 2818

Answers (1)

sarbelaez
sarbelaez

Reputation: 21

In this case, you must have the following permissions in the manifest file of the app:

<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_ADVERTISE" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

With this you have the first part resolved, so that it can work correctly, when the user installs the application, he must go to the settings option, applications and search for your app, and then enter it and give him the permission to use the bluetooth, which is requested for versions of android 12 or higher, additionally, I tell you that there is an option that when it needs to use the plugin, the app requests permission, but I think that you can solve it without a problem.

Upvotes: 1

Related Questions