How to check my location is on or not

How to check my location is on or not .if no then force to on the location

Hi , when you call geolocation.getCurrentPosition() the device ask to on Gps , if user don’t run gps so getCurrentPosition will give you an error like this exemple :

this.geolocation.getCurrentPosition().then((resp) => {
 // resp.coords.latitude
 // resp.coords.longitude
}).catch((error) => {
  console.log('Error getting location', error);
});

Geolocation :

Actually i want to do that if location is not on force to on how can i do that?

you can’t force user to do something if he don’t want , but you can use Background Geolocation the platform will not ask for background tracking permission.

https://ionicframework.com/docs/native/background-geolocation/