iPhone推送通知 - 错误响应的问题 [英] iPhone Push Notification - Error response problem

查看:271
本文介绍了iPhone推送通知 - 错误响应的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发送推送通知后的响应错误检查时,我有一个问题。这是我的设置:

I've got a problem when checking for a response error after sending a Push Notification. This is my setup:

从我的PHP服务器,我送推送通知。这些通知在增强格式发送,这样我可以从苹果服务器的错误响应。例如:错误#7无效的有效载荷大小

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);

这正常工作时,有一个实际的错误。我的问题是:当没有错误,FREAD调用不返回任何东西,会持续永远

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!

推荐答案

您需要设置 stream_set_blocking($这个 - > _apnsSocket,0); 0是非阻塞模式,因为苹果的成功并没有发回任何东西,但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.

这篇关于iPhone推送通知 - 错误响应的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆