是按照教程http://blog.csdn.net/newjueqi/article/details/7898591 来做的。 注意事项: 1. 测试阶段使用的推送地址: ssl://gateway.sandbox.push.apple.com:2195 正式上线使用的推送地址: ssl://gateway.push.apple.com:2195 2. 那里给的php推送代码有问
是按照教程 http://blog.csdn.net/newjueqi/article/details/7898591 来做的。
注意事项:
1. 测试阶段使用的推送地址:
ssl://gateway.sandbox.push.apple.com:2195
正式上线使用的推送地址:
ssl://gateway.push.apple.com:2195
2.
那里给的php推送代码有问题,下面我贴出修改后推送成功的代码:
$message,
'forum_id' => 88,
'topic_id' => 999,
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
//$msg = chr(0).pack('n', 32).pack('H', $deviceToken). pack('n', strlen($payload)).$payload;
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result){
echo 'Message not delivered' . PHP_EOL;
}else{
echo 'Message successfully delivered' . PHP_EOL;
}
// Close the connection to the server
fclose($fp);
?>
[文章作者]曾健生
[作者邮箱]zengjiansheng1@126.com
[作者QQ]190678908
[博客] http://blog.csdn.net/newjueqi
http://blog.sina.com.cn/h6k65
本文原创发布php中文网,转载请注明出处,感谢您的尊重!