Over a million developers have joined DZone.

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

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

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.

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda


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

Opinions expressed by DZone contributors are their own.


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.


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

{{ parent.tldr }}

{{ parent.urlSource.name }}