现在我可以从安装了一通已经在设备上发送推送令牌,但我不知道如何在这一点上,反馈工作。 从苹果的文档,苹果推送通知服务(APN的)反馈给服务器,以判断是否pushToken是否有效。 如何得到这种反馈? 我试试这个代码,但很多错误。 这是代码:
<?php
$cert = '/Applications/MAMP/htdocs/passesWebserver/certificates.pem';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $cert);
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
$fp = stream_socket_client('ssl://feedback.sandbox.push.apple.com:2196', $error, $errorString, 60, STREAM_CLIENT_CONNECT, $ctx);
// production server is ssl://feedback.push.apple.com:2196
if (!$fp) {
error_log("Failed to connect feedback server: $err $errstr",0);
return;
}
else {
error_log("Connection to feedback server OK",0);
}
error_log("APNS feedback results",0);
while ($devcon = fread($fp, 38))
{
$arr = unpack("H*", $devcon);
$rawhex = trim(implode("", $arr));
$feedbackTime = hexdec(substr($rawhex, 0, 8));
$feedbackDate = date('Y-m-d H:i', $feedbackTime);
$feedbackLen = hexdec(substr($rawhex, 8, 4));
$feedbackDeviceToken = substr($rawhex, 12, 64);
error_log ("TIMESTAMP:" . $feedbackDate, 0);
error_log ( "DEVICE ID:" . $feedbackDeviceToken,0);
}
fclose($fp);
?>