OGeek|极客世界-中国程序员成长平台

标题: ios - iOS上的 ionic 地理定位权限问题 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 04:34
标题: ios - iOS上的 ionic 地理定位权限问题

我对 GeoLocation Plugin 有疑问在 ionic 3。

我添加了所有导入的东西。 部分也是如此。我可以在我的 plist 文件中看到这一点:

<key>NSLocationWhenInUseUsageDescription</key>
<string>Get Position</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Get position</string>

所以我认为它有效。但事实并非如此;它适用于 Android,但不适用于 iOS。 我称这种方法为:

this.geolocation.getCurrentPosition().then((resp) => {
    alert("geo " + resp.coords.latitude);
    // resp.coords.latitude
    // resp.coords.longitude
   }).catch((error) => {
     alert(error.code);
     alert(error.message);
   });

我得到了 Error.code 2 和 Error.message:“Origin 没有使用 Geolocation 服务的权限”。

我该怎么办?



Best Answer-推荐答案


我遇到了这个确切的问题——我必须在 XCode 本身的 *.plist 文件中手动添加这个隐私设置(在资源/中找到)。

Key 下输入 Privacy - Location When In Use Usage Description,或至少开始输入,它会自动完成。 Type 应该是 String 并且 Value 应该是您想要向用户弹出的消息,解释您为什么需要访问位置数据。

关于ios - iOS上的 ionic 地理定位权限问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51745825/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4