【问题标题】:ionic 3 - Position retrieval timed out only for iOSionic 3 - 位置检索超时仅适用于 iOS
【发布时间】:2018-08-04 12:28:49
【问题描述】:

它在浏览器和 Android(设备和模拟器)上完美运行,但在 iOS 上,它确实从不请求位置权限,当我尝试获取时出现超时错误用户的位置。

我完全迷路了,我安装了 AndroidPermissions 只是为了检查我是否有权限,结果证明我有(不知道为什么提示给应用程序访问该位置的权限从来没有出现过) .

我正在使用

"cordova-plugin-geolocation": "^3.0.0",
"cordova-ios": "^4.5.4"

代码看起来像这样:

import { Injectable } from '@angular/core';
import { Geolocation } from '@ionic-native/geolocation';
@Injectable()
export class BaresProvider {

    getPosition() {
        return this.geolocation.getCurrentPosition({ timeout: 15000 });
    }
}

再次,我从另一个类使用此服务,并且在 Android 上它按预期工作。

请输入一些信息!

【问题讨论】:

    标签: ios ionic-framework mobile permissions geolocation


    【解决方案1】:

    所以,我刚刚通过在我的应用程序的 info.plist 文件中添加这两个带有字符串的键来解决它:

    NSLocationWhenInUseUsageDescription

    NSLocationAlwaysUsageDescription

    【讨论】:

      猜你喜欢
      • 2015-07-10
      • 2018-08-24
      • 2018-05-12
      • 2016-09-01
      • 2019-11-14
      • 1970-01-01
      • 2019-01-21
      • 1970-01-01
      • 2018-02-02
      相关资源
      最近更新 更多