(v2) White page with Phonegap Barcode Scanner permissions


#1

Hello,
I’ve a problem with the barcode plugin (phonegap-plugin-barcodescanner) and the new version of F7 (with the old 1.6.5 works good).
If I use this code in the index.js the app open with a white page:

app.initialize();
document.addEventListener("deviceready", onDeviceReady, false);

 function hasCameraPermission() {
	"use strict";
    cordova.plugins.barcodeScanner.hasCameraPermission(
      function(result) {
        // if this is 'false' you probably want to call 'requestCameraPermission' now
        alert(result);
      }
    );
  }

  function requestCameraPermission() {
    // no callbacks required as this opens a popup which returns async
	"use strict";
    cordova.plugins.barcodeScanner.requestCameraPermission();
  }

If I remove only CameraPermission instructions “sometimes” the app works good (but obviously not more works the barcode):

app.initialize();
document.addEventListener("deviceready", onDeviceReady, false);

If I remove above code app.initialize()… (index.js empty) the app works good always.

How can I solve this problem (maintaining barcode permissions)?
Thanks.


#2

I’ve fixed with this code:

var app = {
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    }
};

app.initialize();

function hasCameraPermission() {
"use strict";
   cordova.plugins.barcodeScanner.hasCameraPermission(
     function(result) {
       // if this is 'false' you probably want to call 'requestCameraPermission' now
       alert(result);
     }
   );
 },

 function requestCameraPermission() {
   // no callbacks required as this opens a popup which returns async
"use strict";
   cordova.plugins.barcodeScanner.requestCameraPermission();
 }

[SOLVED] Cordova Plugins with Framework7 + Vue?