I'm currently working on an app using vue-js and cordova that involves the phone's camera for taking pictures. However, I am facing challenges in asking the user to grant permission for my app to access the camera.
Despite trying the cordova-plugin-android-permissions, the results have not been as expected.
( cordova plugin add cordova-plugin-android-permissions )
In my main.js file, I have added:
var permissions = cordova.plugins.permissions
permissions.checkPermission(permissions.CAMERA, success, null)
function error () {
console.warn('Camera permission is not turned on')
}
function success (status) {
if (!status.checkPermission) {
permissions.requestPermissions(
permissions.CAMERA,
function (status) {
if (!status.checkPermission) {
error()
}
},
error)
}
}
Upon testing, my app only shows a white screen and during the build process, I received this message:
cordova is not defined
I am considering importing cordova for testing purposes, but unsure about the correct path for the import.
Additionally, I am uncertain if my current method is effective or if there are alternative ways to request device authorization.