使用 PhoneGap 在 iPhone 上的位置权限警报 [英] Location permission alert on iPhone with PhoneGap

查看:29
本文介绍了使用 PhoneGap 在 iPhone 上的位置权限警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何更改警报上的字符串:

How do you change the string on the alert saying:

(应用名称/不管它是什么)想使用您当前的位置

(Appname/whatever it is) would like to use your current location

当然,我只想更改 appname 部分.因为当你使用PhoneGap框架时,字符串是非常难看的,像这样:

Of course, I only want to change the appname part. Because when you use the PhoneGap framework, the string is very ugly, something like this:

/var/mobile/Applications/157EB70D-4AA7-826E-690F0CBE0F/appname.app/www/index.html

/var/mobile/Applications/157EB70D-4AA7-826E-690F0CBE0F/appname.app/www/index.html

有人有想法吗?

推荐答案

您需要在设备准备好后进行地理定位.例如,以下 Jquery 代码将在没有那种讨厌的警报的情况下进行地理定位:

You need to do the geolocation after the device is ready. The following Jquery code, for example, will geolocate without that nasty alert:

$(function(){
  document.addEventListener("deviceready", onDeviceReady, false);
})

function onDeviceReady() {
  navigator.geolocation.getCurrentPosition(onSuccess, onError);     
}

function onSuccess(position) {
  // your callback here 
}

function onError(error) { 
  // your callback here
}

这篇关于使用 PhoneGap 在 iPhone 上的位置权限警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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