【问题标题】:PHP Apple Push Notification :command 2 Binary Interface and Notification multi messagesPHP Apple 推送通知:命令 2 二进制接口和通知多消息
【发布时间】:2015-12-14 01:27:12
【问题描述】:

关于asked的问题,我不知道如何一次发送多条消息。

the Binary frame image from Apple ios

系列项目呢?

我如何创建一个项目?而不是帧数据?

我试过了

while ($row = mysqli_fetch_assoc($result)){
      //command 2
    $msgInner =
      chr(1)
    . pack('n', 32)
    . pack('H*', $row['device_token'])

    . chr(2)
    . pack('n', strlen($payload))
    . $payload

    . chr(3)
    . pack('n', 4)
    . $row['id']

    . chr(4)
    . pack('n', 4)
    . pack('N', time() + 86400)

    . chr(5)
    . pack('n', 1)
    . chr(10);

    $framedata.=$msgInner; //to accumulate (probably wrong, and need binary packing)
 } 
   $msg=
    chr(2)
    . pack('N', strlen($framedata))
    . $framedata;

它只发送到我的 sql 结果中的最后一行。

你能给我正确的数据包格式吗?

【问题讨论】:

    标签: php ios binary apple-push-notifications pack


    【解决方案1】:

    最好问一个问题,如果你回答自己的问题会更好,也许其他人会学习。 为了以新格式发送多条消息,您需要这样发送消息:

    while ($row = mysqli_fetch_assoc($result)){
        $msgInner =
                          chr(1)  
                        . pack('n', 32)
                        . pack('H*', $row['device_token'])
    
                        . chr(2)
                        . pack('n', strlen($payload))
                        . $payload
    
                        . chr(3)    //Notification identifier
                        . pack('n', 4)
                        . pack('N', $row['id']) 
    
                        . chr(4)   //Expiration date
                        . pack('n', 4)
                        . pack('N', time() + 86400)
    
                        . chr(5)    //Priority
                        . pack('n', 1)
                        . chr(10);
    
                        $Imsg=
                            chr(2) //command 2
                            . pack('N', strlen($msgInner))
                            . $msgInner;
    
                        $allmessages=$allmessages.$Imsg;
    }
    

    【讨论】:

      猜你喜欢
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-08
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      相关资源
      最近更新 更多