I am getting the following error when requesting the user permission:
{
"error": "requestPermission",
"message": "Unknown error."
}
Here’s a code snippet for checking and requesting permission:
let PERMISSIONS_NEEDED = [
this.androidPermissions.PERMISSION.CAMERA,
this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE
];
this.androidPermissions.checkPermission(PERMISSIONS_NEEDED[0]).then((result) => {
// If no permission, request permission.
if (!result.hasPermission || result.hasPermission == false || result.hasPermission == "false") {
alert("REQUEST-PERMISSION");
this.androidPermissions.requestPermissions(PERMISSIONS_NEEDED).then((_) => {
alert("PERMISSION-GIVEN");
})
.catch(err => {
alert("REQUEST-PERMISSION-ERROR: " + JSON.stringify(err)); // <<<<<<<<<<<<<<<< error
});
}
// If permission is already granted, proceed normally.
else {
alert("ALREADY-HAVE-PERMISSION");
}
}
Additional Information:
- Using Ionic 3
-
Android Permissions
plugin has been installed as instructed on the Ionic Official Documentation