Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i'm using ionic capacitor and want to receive GPS coordinates using the Geolocator plugin. The problem is that my app is never asking for permission therefore i cannot receive any coordinates. Here is my code:

getLocation(): void{
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) => {
  if ("coords" in data) {
    this.lng = data.coords.longitude;
    this.lat = data.coords.latitude;
    this.getLocations();
  }else{
    this.snackBar.open("Kein Zugriff auf GPS Koordinaten", "Ok", {
      duration: 2000,
    });
  }
  console.log(this.lat, this.lng);
});
}

and here is my info.plist file: info.plis


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...