iPhone推送通知-错误响应问题
发送推送通知后检查响应错误时遇到问题。这是我的设置:
我从我的 PHP 服务器发送推送通知。这些通知以增强格式发送,因此我可以从 Apple 服务器获取错误响应。例如:错误#7“有效负载大小无效”。
我检查错误的方法是读取套接字响应:
const ERROR_RESPONSE_SIZE = 6;
$errorResponse = @fread($this->_apnsSocket, self::ERROR_RESPONSE_SIZE);
当存在实际错误时,这可以正常工作。我的问题是:当没有错误时,“fread”调用不会返回任何内容并永远保持加载。
谁能帮我解决这个问题吗?感谢您的帮助!
I've got a problem when checking for a response error after sending a Push Notification. This is my setup:
From my PHP server, I'm sending Push Notifications. These notifications are send in the enhanced format, so I can get an error response from the Apple server. For example: Error #7 "Invalid payload size".
The way I check for errors is reading the socket response:
const ERROR_RESPONSE_SIZE = 6;
$errorResponse = @fread($this->_apnsSocket, self::ERROR_RESPONSE_SIZE);
This works fine when there is an actual error. By my problem is: when there's no error, the "fread" call doesn't return anything and keeps loading forever.
Can anyone help me with this? Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
stream_set_blocking($this->_apnsSocket, 0);
设置为 0,这是非阻塞模式,因为成功时 Apple 不会发回任何内容,但 fread 正在等待数据处于阻塞模式。You need to set
stream_set_blocking($this->_apnsSocket, 0);
to 0 which is non-blocking mode, because on success Apple doesn't send back anything, but the fread is waiting for data in blocking mode.