0

I am writing php code to send push notifications to multiple iphone devices.. While i am executing php code i am getting warning message in the below line

$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;

like

Warning: pack() [function.pack]: Type H: illegal hex digit in /myapp.com/pushgrams/pushtest.php on line 39

Can any one tell me how to solve this issue?

4

1 に答える 1

0

これは、Apple プッシュ通知の梱包方法です。

// APNs packet prepare
function pck($token, $notification, $msg_id = 0, $expiration = 604800) {
  $token = str_replace(" ", "", $token);
  $pck  = pack('CNNnH*', 1, $msg_id, $expiration > 0 ? time() + $expiration : 0, strlen($token) / 2, $token) . 
          pack('n', strlen($notification)) . $notification;

  return $pck;
}

通知を準備する方法は次のとおりです。

$m = '{"aps":{"alert":"' . $msg. '","sound":"default"},"acme2":["bang","whiz"],"acme3":["bing","bong"]}';
$p  = pck($k, $m);
于 2013-12-02T18:34:10.853 に答える