我们有一个内置PHP的应用程序,它向Android和iOS发送推送通知。我们的问题是,iOS中有一些设备ID似乎完全停止了我们脚本中所有其他iOS推送通知的发送,他们甚至说它们已经没有错误地发送,但之后它会停止循环中的所有通知。iOS应用程序推送通知
如果我们从我们的数据库中删除有问题的设备ID,则发送脚本适用于违规设备后的所有设备。这很奇怪,似乎无法弄清楚为什么。
有没有人有这方面的经验?与发送到不存在的设备ID有关吗?是否会阻止苹果完成特定连接上的脚本?
这里是我们在PHP脚本发送(这除了适用于所有设备从奇流氓设备ID):
$tHost = 'gateway.push.apple.com';
$tPort = 2195;
$tCert = "path_to_our_cert.pem";
$tPassphrase = 'passphrase';
$tAlert = $this->title; //assign a title
$tBadge = 8;
$tSound = 'default';
$tPayload = $this->body_plain; //assign a body
// Create the message content that is to be sent to the device.
$tBody['aps'] = array ('alert' => $tAlert,'badge' => $tBadge,'sound' => $tSound,);
$tBody ['payload'] = $tPayload;
$tBody = json_encode ($tBody);
$tContext = stream_context_create();
stream_context_set_option ($tContext, 'ssl', 'local_cert', $tCert);
stream_context_set_option ($tContext, 'ssl', 'passphrase', $tPassphrase);
$tSocket = stream_socket_client ('ssl://'.$tHost.':'.$tPort, $error, $errstr, 30, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $tContext);
if (!$tSocket) exit ("APNS Connection Failed: $error $errstr" . PHP_EOL);
//Loop through all devices to send
foreach($this->device->devices as $item){
if($item->os != "iOS") continue;
if(session::getAdministratorStaffSchoolID() != $item->school_id) continue;
$tToken = $item->device_id;//assign the device id
$tMsg = chr (0) . chr (0) . chr (32) . pack ('H*', $tToken) . pack ('n', strlen ($tBody)) . $tBody;
$tResult = fwrite ($tSocket, $tMsg, strlen ($tMsg));
}
fclose ($tSocket);
有没有人有这方面的任何想法?
非常感谢