I found the cause of the problem.
A call to navigator.geolocation.getCurrentPosition(onsuccess, onerror) occurs before navigator.geolocation.getCurrentPosition(onsuccess, onerror) is fully loaded.
This means that a webview geolocation request is initiated (rather than a native call via PhoneGap), which again asks for permission (which makes sense). Compare it with the regular Safari browser on your smartphone. He will request geolocation permission for each new website. The same thing happens when loading index.html via PhoneGap when the application starts.
However, the solution is to wait for the deviceready event, which fires when PhoneGap is fully loaded:
document.addEventListener("deviceready", function(){ navigator.geolocation.getCurrentPosition(onsuccess, onerror, params); }, false);
This will make the PhoneGap API available, which overwrites the default HTML5 substitution request in the browser and receives the geographic location of the device through its own call (which you already accepted in the first invitation).
This will work because the PhoneGap API calls are identical to the standard W3C calls for HTML5: http://docs.phonegap.com/en/2.2.0/cordova_geolocation_geolocation.md.html#Geolocation
Timo
source share