繁体   English   中英

要求在Cordova地理位置中始终获得许可

[英]Request Always Permission in Cordova Geolocation

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

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

转到platform / ios / ios.json查找以下内容:

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

并将“ NSLocationWhenInUseUsageDescription”替换为“ NSLocationAlwaysUsageDescription”,如下所示:

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

运行“ cordova build ios”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM