Hi all,
I integrated ionic geolocation plugin on my ionic 5 app but on ios simulator it doesn’t work. Could you please support me?
npm install cordova-plugin-geolocation
npm install @ionic-native/geolocation
<edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
<string>We use your location for full functionality of certain app features.</string>
</edit-config>
import { Geolocation } from '@ionic-native/geolocation/ngx';
...
constructor(private geolocation: Geolocation) {}
...
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
}).catch((error) => {
console.log('Error getting location', error);
});
let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
// data can be a set of coordinates, or an error (if an error occurred).
// data.coords.latitude
// data.coords.longitude
});
On browser and on android it works. On ios simulator or device, no permission request shown and geolocalizator not works.
Any idea?
Tks