I visited all links about this problem and none helped me.
I get the error code 3 (timeout) in response always when execute the method "getCurrentLocation" from "cordova-plugin-geolocation" on IOS .
follow my code:
getCurrentPosition() {
return new Promise(function (resolve, reject) {
document.addEventListener("deviceready", function(){
navigator.geolocation.getCurrentPosition((position) => {
resolve(position);
}, (error) => {
reject(error);
}, {
timeout: 10000
});
}, false);
});
}
I upgraded all plugins and engines and the error persisted. Follow my current versions:
After the hardwork, I found the fix. I added the follow keys in "/platform/ios/{project_name}/{project_name}-Info.plist":
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>My app requires constant access to your location, even when the screen is off.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>My app requires constant access to your location, even when the screen is off.</string>