Seeing two geolocation prompts in a PhoneGap/Cordova application?

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.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA