Just add an Alert Controller.
Alert Controller
presentConfirm() {
let alert = this.alertCtrl.create({
title: 'Locations = off!',
message: 'Location needs to be turned on. Turn on now ?',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Ok',
handler: () => {
//!ADD YOUR CODE HERE!
console.log('Ok clicked');
}
}
]
});
alert.present();
}
Your Code
this.geolocation.getCurrentPosition().then((resp) => {
this.lat = resp.coords.latitude;
this.lng = resp.coords.longitude;
this.latlong = resp.coords.latitude + ',' + resp.coords.longitude;
console.log('loaction: ' + this.latlong)
}).catch((error) => {
this.presentConfirm();
console.log('Error getting location', error);
});
I’ve found a promising code here. I hope this is what you wanted.
Else download a demo application wich also uses location settings and look how they coded it.