我使用插件cordova-plugin-geolocation.我唯一的问题是允许位置的消息提示如下所示:
/var/container/bundle/application/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/my_project/www/index.html想要使用您的位置.
反正有没有更性感的东西,比如说
my_project想要使用你的位置
干杯.
为非信徒添加了一些代码
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
navigator.geolocation.getCurrentPosition(onLocationSuccess, onLocationError, {maximumAge:3000, timeout:2000, enableHighAccuracy:true});
function onLocationSuccess(){
}
function onLocationError(){
}
}
Run Code Online (Sandbox Code Playgroud)
Sta*_*tan 14
解决方案已经改变了cordova-plugin-geolocation:"4.0.0".这是您需要添加的内容config.xml:
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>need location access to find things nearby</string>
</edit-config>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请访问:https://github.com/apache/cordova-plugin-geolocation
来自docs:
iOS Quirks
从iOS 10开始,必须在info.plist中添加NSLocationWhenInUseUsageDescription条目.
NSLocationWhenInUseUsageDescription描述了应用访问用户位置的原因.当系统提示用户允许访问时,此字符串将显示为对话框的一部分.要添加此条目,您可以在插件安装上传递变量GEOLOCATION_USAGE_DESCRIPTION.
示例:cordova插件添加cordova-plugin-geolocation - 变量GEOLOCATION_USAGE_DESCRIPTION ="您的使用信息"
如果您没有传递变量,插件将添加一个空字符串作为值.
要解决您的问题,请尝试:
卸载插件:
cordova plugin remove cordova-plugin-geolocation
Run Code Online (Sandbox Code Playgroud)
重新安装:
cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="my_project would like to use your location"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11009 次 |
| 最近记录: |