Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Seeing Two Geolocation Prompts in a PhoneGap/Cordova Application?

DZone's Guide to

Seeing Two Geolocation Prompts in a PhoneGap/Cordova Application?

· Mobile Zone
Free Resource

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 screenshots 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.


Topics:

Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}