iPhone Push Notification - Error response problem

2019-02-27 16:07发布

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!

1条回答
闹够了就滚
2楼-- · 2019-02-27 16:55

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.

查看更多
登录 后发表回答