Twitter: raymondcamden


Address: Lafayette, LA, USA

Seeing two geolocation prompts in a PhoneGap/Cordova application?

11-02-2013 8,360 views Mobile

Are you using geolocation in your PhoneGap/Cordova application and seeing two prompts?

I was. Even more odd was the fact that one had the "nice" application name and one was the full path to the index.html. See the screen shots below.

In all my Googling for this issue, all I could find were warnings about using geolocation before the deviceready event had fired. I definitely had not made that mistake, so I was truly confused. Also - none of these reports mentioned multiple prompts. To make things even more confusing - if I reran my application I would only get the second, ugly, prompt. An application is supposed to remember that you gave it permission, so what the heck, right?

Turns out that I made the same mistake others have made with Cordova 3.0 - I forgot to add the geolocation plugin!

cordova plugin add org.apache.cordova.geolocation
Even without the plugin you are still able to use geolocation. I have no idea why it prompted twice (I'm sure some of the engineers could explain it), but as soon as I added the plugin the second prompt went away.