与问题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结果的最后一行。
请你在代码中给我正确的数据包格式。
答案 0 :(得分:0)
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;
}