首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IOS 11上的Cordova插件地理定位超时

IOS 11上的Cordova插件地理定位超时
EN

Stack Overflow用户
提问于 2017-12-20 20:13:36
回答 1查看 750关注 0票数 1

我访问了所有关于这个问题的链接,没有人帮助我。

我得到错误代码3(超时),总是在执行方法"getCurrentLocation“从”科多瓦-插件-地理定位“在IOS上。

按照我的代码:

代码语言:javascript
复制
getCurrentPosition() {
 return new Promise(function (resolve, reject) {
  document.addEventListener("deviceready", function(){
    navigator.geolocation.getCurrentPosition((position) => {
      resolve(position);
    }, (error) => {
      reject(error);
    }, {
      timeout: 10000
    });
  }, false);
 });
}

我升级了所有插件和引擎,错误仍然存在。按照我现在的版本:

  • 科多瓦8.0.0;
  • 科多瓦-ios 4.5.4;
  • cordova-android 7.0.0;
  • 科多瓦-插件-地理定位4.0.0。
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-22 18:01:31

经过艰苦的工作,我找到了解决办法。我在"/platform/ios/{project_name}/{project_name}-Info.plist":中添加了以下键

代码语言:javascript
复制
<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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47913715

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档