pav*_*gel 5 xcode message geolocation ios cordova
有没有人有使用cordova,HTML的经验,并知道如何修复iOS的地理定位消息问题?我只想让消息说出应用名称后跟行,"想要使用你当前的位置."
当前的地理定位消息:
///Users/kklsndksjladn/Library/Developer/CoreSimulator/Devices/FAF7EE4C-40BA-430A-80D5-5C84B07D970D/data/Containers/Bundle/Application/DAE305B6-C6DD-438B-B4D7-9B183A8B2D97/HelpME.app/www/index html的
我已经尝试过堆栈溢出和其他网站的各种解决方案.我实现了 navigator.geolocation.getCurrentPosition(onSuccess, onError);代码,在每个html页面中包含了我的cordova.js文件,确保<script> src=cordova.js</script>首先出现在我的index.html页面中,在我的config.xml文件中包含geolocation标记,并尝试使用我的plist.有人请帮忙!!!!
-谢谢
除了DaveAlden的答案之外,我不得不删除旧版本的geolocation插件并添加新版本.然后我不得不删除/添加Cordova iOS平台.只有这样才能NSLocationWhenInUseUsageDescription成功添加到.plist文件中.
首先,删除/添加地理位置插件:
cordova plugin rm org.apache.cordova.geolocation
cordova plugin add org.apache.cordova.geolocation
Run Code Online (Sandbox Code Playgroud)
其次,删除/添加iOS平台:
cordova platform rm ios
cordova platform add ios
Run Code Online (Sandbox Code Playgroud)
最后,添加NSLocationWhenInUseUsageDescription到.plist.打开/platforms/ios/{project}/{project}-Info.plist并添加以下内容:
<key>NSLocationWhenInUseUsageDescription</key>
<string>[App Name] would like to access your location when running and displayed.</string>
Run Code Online (Sandbox Code Playgroud)
有关与vs的详细信息,请参阅此iOS Developer Library链接.NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescriptionNSLocationUsageDescription
使用Cordova的iPhone上的位置许可警报可能是重复的.
要自定义 iOS 位置权限请求消息,您需要将属性添加到项目的 .plist 中。
如果您的应用程序请求在后台使用位置的权限,您需要以下键(将字符串值设置为您喜欢的任何值):
<key>NSLocationAlwaysUsageDescription</key>
<string>My app requires constant access to your location, even when the screen is off.</string>
Run Code Online (Sandbox Code Playgroud)
如果您的应用程序仅在前台使用位置信息,则添加以下键:
<key>NSLocationWhenInUseUsageDescription</key>
<string>My app requires access to your location when the screen is on and the app is displayed.</string>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10275 次 |
| 最近记录: |