Seeing Two Geolocation Prompts in a PhoneGap/Cordova Application?
Join the DZone community and get the full member experience.Join For Free
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
Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.