Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Apple推送通知:命令2二进制接口和多消息通知_Php_Ios_Binary_Apple Push Notifications_Pack - Fatal编程技术网

PHP Apple推送通知:命令2二进制接口和多消息通知

PHP Apple推送通知:命令2二进制接口和多消息通知,php,ios,binary,apple-push-notifications,pack,Php,Ios,Binary,Apple Push Notifications,Pack,关于这个问题,我不知道如何一次发送多条消息 那一系列的商品呢 如何创建项目?而不是一帧数据 我试过了 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))

关于这个问题,我不知道如何一次发送多条消息

那一系列的商品呢

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

我试过了

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结果中的最后一行


你能给我正确的代码包格式吗。

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

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;
}