如何为通行证添加10个以上的位置

时间:2013-05-21 09:42:00

标签: json ios6 passbook ios6.1

我想在锁定屏幕上显示许多位置。我测试过,只显示了10个位置。有没有办法显示超过10个位置?

1 个答案:

答案 0 :(得分:1)

Rachel的正确之处在于,Passbook只能识别pass.json中包含的前10个位置。如果有超过10个,那么这些将被忽略。

您链接到的解决方法,提出以下建议:

  • 您创建了一个启用了位置的应用
  • 每当您的应用检测到重大位置更改时,它会向您的服务器发出信号,提供通行证序列号和新位置
  • 您的服务器然后选择10个最近的位置,编译新的传递并将其推送到设备

根据您想要确定最合适位置的复杂程度,可能会有一些工作。它也不能提供良好的用户体验,因为该位置将吃电池并且不断更新通行证会吃掉数据。

三种替代方法是:

  • 让用户为他们选择10个最合适的位置,或
  • 每次使用通行证时更新位置。如果扫描了通行证,则可以使用扫描设备的位置来确定最近的10个位置并推送更新的通行证,或者
  • 将传递背面的唯一链接添加到HTML5页面,该页面使用Javascript(见下文)抓取当前位置,然后启动推送。例如。要通过最近的10个地点进行更新,请点击http://www.yourservice.com/?passSerial=xxxx
  • 下面的链接

示例位置JS:

<script>
if(navigator.geolocation){
    navigator.geolocation.getCurrentPosition(success,fail);
}

function success(a) {            
    $("#long").val(a.coords.longitude).focus(); // focus required to force an update of the field value in webkit browsers
    $("#lat").val(a.coords.latitude).focus();
    // initiate ajax callback to push new pass and alert the user that it is on the way

}
function fail() {
    alert("You must give permission to provide your location, please refresh this page and try again");
}
</script>