Cordova-plugin-geolocation location access prompt appears twice

Hello, I am seeing an issue where I am getting the request to access location information twice in my app. Can someone help me.

Image 1

Image 2

People on Stack Overflow have suggested that I need to make sure ionic has loaded. I do this and I still get this issue. Who has seen this and knows how to address it? FYI I am using ionic native API call-

Geolocation.getCurrentPosition({timeout: 20000, enableHighAccuracy: false})

ionic info


Your system information:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.2
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Ionic App Scripts Version: 0.0.39
ios-deploy version: Not installed
ios-sim version: 5.0.8
OS: Mac OS X Sierra
Node Version: v6.9.1
Xcode version: Xcode 8.1 Build version 8B62

So I have it working now.

This works for ios-
cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git --variable GEOLOCATION_USAGE_DESCRIPTION=“I would like to show you information near you”

so I thought the problem may be related to the normal plugin, so I added “cordova-plugin-geolocation” to packages.json and did ionic state reset and it works again.

I am not sure what it was in the end.

1 Like

I’m having this same problem, haven’t solved it yet. I’ve added cordova-plugin-geolocation to the package.json because it was odd to me it doesn’t get in there when you install it, even with a --save flag. I’d done a state reset both with and without that in the package.json and that hasn’t solved it either…

I solved this by putting the geolocation code inside the platform ready block on the app.component.ts.

I had mistakenly assumed that having it inside a child component would mean the platform was ready, but apparently this was not the case.

put you geolocation code inside platform.ready()

this.platform.ready().then(() => {
  this.geolocation.getCurrentPosition().then((resp) => {
      console.log(resp.coords.latitude);
      console.log(resp.coords.longitude);

})

TY this is the correct solution for Ionic 3