【问题标题】:Request Always Permission in Cordova Geolocation在科尔多瓦地理定位中请求始终许可
【发布时间】:2023-03-23 22:43:01
【问题描述】:

看起来 PhoneGap 有一个 config.xml 设置来更新项目中的 plist 键,以将 Geolocation 插件的权限从“使用时”设置为“始终”,如果我手动将项目的 .plist 文件的键设置为NSLocationAlwaysUsageDescription 而不是插件的默认 NSLocationWhenInUseUsageDescription 它设置了正确的权限,但是我如何告诉插件请求 Always 权限而不必深入研究平台/ios/*.plist 文件?看起来插件代码检查了要设置的权限,但我不知道如何请求它提示用户使用 JavaScript API 提供正确的权限。

见:https://github.com/apache/cordova-plugin-geolocation/blob/master/src/ios/CDVLocation.m#L130

【问题讨论】:

    标签: javascript ios cordova permissions geolocation


    【解决方案1】:

    转到平台/ios/ios.json 找到以下内容:

     "*-Info.plist": {
                        "parents": {
                            "NSLocationWhenInUseUsageDescription": [
                                {
                                    "xml": "<string />",
                                    "count": 1
                                }
                            ]
                        }
                    }
    

    并将“NSLocationWhenInUseUsageDescription”替换为“NSLocationAlwaysUsageDescription” 所以看起来如下:

    "*-Info.plist": {
                "parents": {
                    "NSLocationAlwaysUsageDescription": [
                        {
                            "xml": "<string />",
                            "count": 1
                        }
                    ]
                }
            }
    

    运行“cordova build ios”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-20
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多