有没有人有使用cordova,html的经验,并且知道如何解决iOS的地理位置消息问题?我只想让消息说出应用程序名称,然后加上以下行:“想使用您的当前位置”。
当前地理位置消息:
我已经尝试过堆栈溢出和其他网站的各种解决方案。我实现了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
其次,删除/添加iOS平台:
cordova platform rm ios
cordova platform add ios
最后,将
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>
有关
NSLocationWhenInUseUsageDescription
与NSLocationAlwaysUsageDescription
与NSLocationUsageDescription
的详细信息,请参见此iOS Developer Library link。Location permission alert on iPhone with Cordova是可能的重复项。
关于ios - 修复Cordova地理位置询问位置信息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28891339/