我們有一個內置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);
有沒有人有這方面的任何想法?
非常感謝