Hybrid Cordova App Callback For Location Permission Alert
I have a cordova hybrid app which using location permission. so is there anyway in JavaScript to detect the action performed on alert popup either allow or cancel. something like i
Solution 1:
You can do so by using cordova-diagnostic-plugin to request location permission:
Configure it:
config.xml
: <preference name="cordova.plugins.diagnostic.modules" value="LOCATION" />
Install it:
$ cordova plugin add cordova.plugins.diagnostic
Use requestLocationAuthorization()
:
cordova.plugins.diagnostic.requestLocationAuthorization(function(status){
switch(status){
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission not requested");
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied");
break;
}
}, function(error){
console.error(error);
});
Post a Comment for "Hybrid Cordova App Callback For Location Permission Alert"