Cordova iOS位置信息 [英] Cordova iOS location message

查看:1341
本文介绍了Cordova iOS位置信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用插件 cordova-plugin -geolocation 。我唯一的问题是消息提示允许位置如下:

I use the plugin cordova-plugin-geolocation. My only issue is that the message prompt to allow location looks like this:


/ var / container / bundle / application / xxxxxx-xxxx- xxxx-xxxx-xxxxxxxx / my_project / www / index.html
想要使用您的位置。

/var/container/bundle/application/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/my_project/www/index.html Would like to use your location.

my_project要使用您的位置

my_project would like to use your location

干杯。

添加了一些代码,为非信徒

Added some code, for the non believers

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady(){

    navigator.geolocation.getCurrentPosition(onLocationSuccess, onLocationError, {maximumAge:3000, timeout:2000, enableHighAccuracy:true});

    function onLocationSuccess(){

    }

    function onLocationError(){

    }
 }


推荐答案

docs


iOS Quirks

iOS Quirks

自从iOS 10以来,必须在info.plist中添加一个NSLocationWhenInUseUsageDescription条目。

Since iOS 10 it's mandatory to add a NSLocationWhenInUseUsageDescription entry in the info.plist.

NSLocationWhenInUseUsageDescription描述了应用程序
访问用户位置的原因。当系统提示用户
允许访问时,此字符串显示为对话框的一部分。要
添加此条目,您可以在插件安装上传递变量GEOLOCATION_USAGE_DESCRIPTION

NSLocationWhenInUseUsageDescription describes the reason that the app accesses the user's location. When the system prompts the user to allow access, this string is displayed as part of the dialog box. To add this entry you can pass the variable GEOLOCATION_USAGE_DESCRIPTION on plugin install.

示例:cordova插件add cordova-plugin-geolocation --variable
GEOLOCATION_USAGE_DESCRIPTION =您的使用消息

Example: cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="your usage message"

如果您不传递变量,插件将添加一个空字符串作为
值。 / p>

If you don't pass the variable, the plugin will add an empty string as value.

要解决问题,请尝试:

卸载插件: p>

Uninstall the plugin:

cordova plugin remove cordova-plugin-geolocation

重新安装:

cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="my_project would like to use your location"

这篇关于Cordova iOS位置信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆