Dmi*_*nko 5 cordova cordova-plugins
我正在使用Cordova构建移动应用程序.我cordova-plugin-geolocation
用来获取用户的当前位置.要在iOS上自定义位置权限请求,需要设置NSLocationWhenInUseUsageDescription
plist值.
通常,要设置iOS plist选项,需要手动设置选项值platforms/ios/<app-name>/<app-name>-Info.plist
.问题是在每个构建中cordova-plugin-geolocation
使用它的默认空字符串覆盖自定义值.
猜测它与以下几行有关plugins/cordova-plugin-geolocation/plugin.xml
:
<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
<string></string>
</config-file>
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试将任何值设置<string>
为不受尊重,因为它似乎在plugin.xml
安装插件时被缓存.
因此NSLocationWhenInUseUsageDescription
,对于以项目重建持续存在的方式设置任何帮助都表示赞赏.
jce*_*ile 11
新答案:
如果使用Cordova CLI 6.5.0或更新版本cordova-plugin-geolocation
(> = 3.0.0),则应使用以下edit-config
标记config.xml
:
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>your custom text here</string>
</edit-config>
Run Code Online (Sandbox Code Playgroud)
旧的答案:分叉github插件
NSLocationWhenInUseUsageDescription
用你想要的文字改变
<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
<string>your custom text here</string>
</config-file>
Run Code Online (Sandbox Code Playgroud)
然后删除原始geolocation插件并安装你的fork
cordova plugin add https://github.com/yourUsername/yourGeolocationFork.git
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7340 次 |
最近记录: |