Cordova geolocation.getCurrentPosition Works in Monaca iPhone Debugger But Not With Built iOS App -
navigator.geolocation.getcurrentposition cordova api method works monaca debugger/ app emulator installed on iphone, freezes in built ios version on same phone.
i added following config.xml didn't fix problem.
<feature name="geolocation"> <param name="ios-package" value="cdvlocation" /> </feature>
i tried reproduce problem. unfortunately posted less information. set new cordova project:
cordova create geolocationtest com.example.com geolocationtest
cd geolocationtest
cordova platform add ios
cordova plugin add cordova-plugin-geolocation
cordova build
then moved folder , edited index.html. added code:
document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready() { console.log("navigator.geolocation works well"); }
after added example geolocation-plugin documentation:
// onsuccess callback // method accepts position object, contains // current gps coordinates // var onsuccess = function(position) { alert('latitude: ' + position.coords.latitude + '\n' + 'longitude: ' + position.coords.longitude + '\n' + 'altitude: ' + position.coords.altitude + '\n' + 'accuracy: ' + position.coords.accuracy + '\n' + 'altitude accuracy: ' + position.coords.altitudeaccuracy + '\n' + 'heading: ' + position.coords.heading + '\n' + 'speed: ' + position.coords.speed + '\n' + 'timestamp: ' + position.timestamp + '\n'); }; // onerror callback receives positionerror object // function onerror(error) { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); } navigator.geolocation.getcurrentposition(onsuccess, onerror);
that worked fine me. problem has anywhere in code. should provide more information.