存折更新推送未显示在锁屏上 [英] Passbook Update Push not shown on Lockscreen

查看:23
本文介绍了存折更新推送未显示在锁屏上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩苹果 Passbook 服务.我在所有设备上都有一个非常奇怪的行为.如果我通过 APNS 向设备发送推送,让他们知道某个通行证有更新,他们会进行更新,但不会在设备的锁屏上显示任何通知.

I am playing with apples Passbook service. I have a really strange behaviour on all devices. If I send a push via APNS to the device to let them know that there is a update for a certain pass they do the update but they do not show any notification on the Lockscreen on the device.

现在我正在记录我的 PHP-Web 服务和 APNS 之间的整个通信.我总是用 headre 200 和要求的答案来回答.(1st Serials; 2nd Pass.pkpass)并且设备进行更新,正如我在存折应用程序中看到的那样,但正如我已经说过的那样,我在锁屏上没有收到任何通知.如本文所述,设备已正确设置:链接

Right now I am logging the whole communication between my PHP-Webservice and the APNS. I always answer with headre 200, and the requested answer. (1st Serials; 2nd Pass.pkpass) and the device does the update as I can see in the passbook app but as I already said I do not get any Notification on the Lockscreen. The Device is set up correctly as described in this article: a link

我像这样执行我的 APNS 请求:

and I do my APNS Request like this:

public function sendePushNotification($passTypeID, $debug = true)
{
// Zertifikat vorhanden ?
$certFullPath = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "api/cert/ck.pem";
if (file_exists($certFullPath))
{
  /**
   * Payload vorbereiten
   */
  $message = 'PASSDROP UPDATE'; 
  $body = array();
  $body['aps'] = array('alert' =>  $message);


  /**
   * Host bestimmen
   */
  $apnsHost = "gateway.push.apple.com";   // Development Umgbung

  /**
   * Stream erstellen
   */
  $ctx = stream_context_create();
  stream_context_set_option($ctx, 'ssl', 'local_cert', $certFullPath);
  $fp = stream_socket_client('ssl://' . $apnsHost . ':2195', $err, $errstr, 2, STREAM_CLIENT_CONNECT, $ctx);
  if (!$fp) 
  {
    echo "Fehler beim APNS: " . $err . " / ". $errstr. "\n";
    return false;
  }

  /**
   * Payload versenden
   */
  $payload = json_encode($body);
  $msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $this->token)) . pack("n",strlen($payload)) . $payload;      
}
else
{
  throw new Exception("Zertifikat-Bundle " . $certFullPath . " existiert nicht !!!");
}
}

据我所知,Apple 在 Passbook 中推送 Pass 时不会读取有效载荷.

As far as I know Apple does not read the payload when pushing a Pass in Passbook.

有没有人给我暗示我接下来可以尝试什么?我需要 pass.json 文件中的任何内容吗?

Does anybody have a hint for me what I can try next? Do I need anything in the pass.json file?

推荐答案

如果您的设备正在更新并接收新的通行证,但您没有看到通知,那么很可能您的 pass.json 不包含更改消息键.

If your devices are updating and receiving the new passes, but you are not seeing a notification then it is most likely that your pass.json doesn't contain a changeMessage key.

为了显示通知:

  • 传递数据值必须已更改(字段标签、颜色和图像不会触发更新),并且
  • 更改的字段必须包含 changeMes​​sage 键,最好带有 %@ 占位符,它将被新字段值替换.

对于 Passbook,APNS 推送的唯一目的是通知设备 Web 服务有新鲜内容.所有通知活动都由新旧 pass.json 文件之间的差异决定.

For Passbook, the APNS push's only purpose is to notify the device that the web service has fresh content. All notification activity is determined by the differences between the old and new pass.json files.

如果您的 pass 字段发生变化,并且您设置了 changeMes​​sage 键但没有看到通知,那么发布 pass.json 的前后相关部分可能会帮助我们确定问题所在.

If your pass field is changing, and you have a changeMessage key set but you are not seeing a notification, then posting the relevant before and after sections of pass.json may help us identify what's wrong.

当after"传递替换before"传递时,下面的json摘录将触发以下两个通知:

The json excerpts below will trigger the follwoing two notifications when the 'after' pass replaces the 'before' pass:

  • 请前往 22 号登机口
  • 航班状态:登机

通过前:

  "boardingPass": {
        "headerFields": [{
            "key": "h1",
            "value": "--",
            "label": "Gate",
            "changeMessage": "Please proceed to gate %@"
        }, {
            "key": "h2",
            "value": "On Time",
            "label": "Status",
            "changeMessage": "Flight status: %@"
        }],
           ...

通过后:

  "boardingPass": {
        "headerFields": [{
            "key": "h1",
            "value": "22",
            "label": "Gate",
            "changeMessage": "Please proceed to gate %@"
        }, {
            "key": "h2",
            "value": "Boarding",
            "label": "Status",
            "changeMessage": "Flight status: %@"
        }],
           ...

这篇关于存折更新推送未显示在锁屏上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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