hi everyone,
i want to check gps is enable or not, if gps is disable will appear popup notification to enable that like in the native apps.
Can someone give me a few example on how to get this working?
hi everyone,
i want to check gps is enable or not, if gps is disable will appear popup notification to enable that like in the native apps.
Can someone give me a few example on how to get this working?
Check Cordova Geo location plugin
but how to open android location settings ? i don’t found it
thanks TheJetlag… i’ll try
I have found one android based plugin for this… hope this helps you
if (window.cordova) {
cordova.plugins.diagnostic.isGpsLocationEnabled(
function(e) {
if (e){
alert("location on")
}
else {
alert("Location Not Turned ON");
cordova.plugins.diagnostic.switchToLocationSettings();
}
},
function(e) {
alert('Error ' + e);
}
);
}
if (this.platform.is(‘android’)) {
let successCallback = (isAvailable) => { console.log('Is available? ’ + isAvailable); };
let errorCallback = (e) => console.error(e);
this.diagnostic.isLocationAvailable().then(successCallback).catch(errorCallback);
this.diagnostic.isGpsLocationAvailable().then(successCallback, errorCallback);
this.diagnostic.getLocationMode()
.then((state) => {
if (state == this.diagnostic.locationMode.LOCATION_OFF) {
let confirm = this.alertCtrl.create({
title: '<b>Location</b>',
message: 'Location information is unavaliable on this device. Go to Settings to enable Location for Untapped.',
buttons: [
{
text: 'GO TO SETTINGS',
handler: () => {
this.diagnostic.switchToLocationSettings();
}
}
]
});
confirm.present();
} else {
this.FinalSave();
}
}).catch(e => console.error(e));
}
how to check ios platform