cordova-plugin-ble-peripheral icon indicating copy to clipboard operation
cordova-plugin-ble-peripheral copied to clipboard

Android 12

Open markarupert opened this issue 2 years ago • 1 comments

Has anyone gotten this working with Android 12. I am getting a permission error for BLUETOOTH_ADVERTISE. I put it in the AndroidManifest. and have tried enabling with cordova.plugins.diagnostic.requestBluetoothAuthorization.

This is the error I am getting.

Possibly unhandled Error: Need android.permission.BLUETOOTH_ADVERTISE permission for AttributionSource { uid = 11308, packageName = biz.geowiz.mobile, attributionTag = null, token = android.os.BinderProxy@288b4e9, next = null }: GattService startAdvertisingSet

markarupert avatar Dec 27 '22 15:12 markarupert

Use the permissions plugin, and check the permission programmatically:

  permissions.checkPermission('android.permission.BLUETOOTH_ADVERTISE', function( status ){
    if (!status.hasPermission ) {
      console.log('Requesting BLUETOOTH_ADVERTISE permission...');
      permissions.requestPermission('android.permission.BLUETOOTH_ADVERTISE', function() {
        console.log('BLUETOOTH_ADVERTISE granted by user :-)');
      }, function() {
        console.log('BLUETOOTH_ADVERTISE denied :-(');
      });
    }
    else {
      console.log('BLUETOOTH_ADVERTISE already granted :-)');
    }
  });

https://github.com/NeoLSN/cordova-plugin-android-permissions

ragcsalo avatar Feb 28 '24 19:02 ragcsalo