I am trying to request camera and location permissions when the app starts. The location permission works fine, but the camera permission comes back with a status of “always_denied”. Here’s what the code looks like:
requestCameraPermissions(): Promise<boolean> {
return new Promise(resolve => {
if (this.platform.is('android')) {
this.andPerms.requestPermission(this.andPerms.PERMISSION.CAMERA).then((result) => {
console.log('Android Perm Request Result:', result);
resolve(result.hasPermission);
});
} else {
this.diag.requestRuntimePermission(this.diag.permission.CAMERA).then((authorization) => {
//this.diag.requestCameraAuthorization().then((authorization) => {
console.log(`Camera request result: ${authorization}`);
// resolve the promise to true or false based on whether it was granted
resolve(authorization === this.diag.permissionStatus.GRANTED);
});
}
});
}
The result I get back from the android permissions response is always:
Perm Request Result: Object {hasPermission: false}
When I tried the diagnostics approach, “authorization” is always “DENIED_ALWAYS”.
Here’s my ionic info:
Ionic:
ionic (Ionic CLI) : 4.1.2 (C:\Users\HinesRemote\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0Cordova:
cordova (Cordova CLI) : 7.1.0
Cordova Platforms : android 6.3.0, browser 5.0.4, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.4, (and 7 other plugins)System:
Android SDK Tools : 26.1.1 (C:\android\sdk)
NodeJS : v8.11.2 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10
This is occurring on the Android Emulator and I’m currently trying to see what happens on an iOS simulator. I’ll update with that info when it runs. My Mac is a little lightweight so sometimes it’s really slow.
But otherwise any ideas?