dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
540 stars 361 forks source link

Fatal error: requestBluetoothAuthorization() plugin is not installed #447

Closed juanmaoyarzun closed 2 years ago

juanmaoyarzun commented 3 years ago

I have error when request permissions Bluetooth: plugin is not installed The isBluetoothAvailable() and getBluetoothState() methods return a response on the promise, but the requestBluetoothAuthorization() method returns the error: plugin is not installed

Check the diagnostic.bluetooth.js file that cordova generates and the requestBluetoothAuthorization() method is not declared. I need your urgent help.

Code `
private getBluetooth() { let successCallback = (isAvailable) => { console.log('Is available? ' + isAvailable); }; let errorCallback = (e) => console.error(e);

this.diagnostic.isBluetoothAvailable().then(successCallback, errorCallback);

if (successCallback) {
  this.diagnostic
    .getBluetoothState()
    .then(async (state) => {
      if (state == this.diagnostic.bluetoothState.POWERED_ON) {
        // do something
        const bluetooth =
          await this.diagnostic.requestBluetoothAuthorization();
        console.log('Bluetooth: ', bluetooth);
      } else {
        // do something else
        console.log('Bluetooth OFF');
      }
    })
    .catch((e) => console.error(e));
} else {
  console.log(errorCallback);
}

}: `

config.xml <preference name="cordova.plugins.diagnostic.modules" value="LOCATION BLUETOOTH CAMERA NOTIFICATIONS MICROPHONE" />

ionic info `Ionic:

Ionic CLI : 6.18.0 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 5.5.3 @angular-devkit/build-angular : 0.901.15 @angular-devkit/schematics : 9.1.15 @angular/cli : 9.1.15 @ionic/angular-toolkit : 2.0.0

Cordova:

Cordova CLI : 10.0.0 (cordova-lib@10.1.0) Cordova Platforms : android 10.1.1, ios 6.2.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 16 other plugins)

Utility:

cordova-res : 0.15.3 native-run (update available: 1.5.0) : 1.4.1

System:

ios-deploy : 1.11.4 ios-sim : 8.0.2 NodeJS : v14.17.0 (/usr/local/bin/node) npm : 6.14.15 OS : macOS Big Sur Xcode : Xcode 13.1 Build version 13A1030d`

dpa99c commented 2 years ago

requestBluetoothAuthorization() is defined here and exposed here The function can also be validated as working correctly in the example project.