How to enable GPS pragmatically when app is initialize


#1

when i open my ionic app then if GPS is off how to enable GPS pragmatically without going on setting menu


#2

Checking GPS is enabled or not

cordova.plugins.diagnostic.isGpsLocationEnabled(function(enabled){
console.log("GPS location is " + (enabled ? "enabled" : "disabled"));
 }, function(error){
console.error("The following error occurred: "+error);
}); 

If success, then use the following plugin to show a confirmation dialog
https://www.npmjs.com/package/cordova-plugin-request-location-accuracy