我访问了有关此问题的所有链接,没有人帮助过我。
在IOS上执行“cordova-plugin-geolocation”中的方法“getCurrentLocation”时,我总是得到错误代码3(超时)。
按照我的代码:
getCurrentPosition() {
return new Promise(function (resolve, reject) {
document.addEventListener("deviceready", function(){
navigator.geolocation.getCurrentPosition((position) => {
resolve(position);
}, (error) => {
reject(error);
}, {
timeout: 10000
});
}, false);
});
}
我升级了所有插件和引擎,错误仍然存在。 关注我当前的版本:
答案 0 :(得分:1)
辛勤工作之后,我找到了修复。我在" / 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>