从我的服务器 PHP 发送推送通知
我正在尝试从本地主机向我的 iDevice 发送推送通知,一切正常,但在 PHP 错误日志中我收到以下警告,为什么?
注意:我在所有设备上收到推送
警告:
PHP Warning: socket_close(): supplied resource is not a valid Socket resource in /Applications/MAMP/htdocs/Push/SendPush.php on line xxx
我的一些代码:
//....
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
//...
socket_close($apns);
fclose($apns);
I'am trying to send push notification from my localhost to my iDevices all work properly but in the PHP error log I got the warning below Why ?
NOTE: I receive the Push on all Devices
THE WARNING:
PHP Warning: socket_close(): supplied resource is not a valid Socket resource in /Applications/MAMP/htdocs/Push/SendPush.php on line xxx
Some of My Code:
//....
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
//...
socket_close($apns);
fclose($apns);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Apple 很可能会在收到您的有效负载后终止连接。
要消除警告,请进行以下更改:
Most likely Apple is terminating the connection after it receives your payload.
To silence the warning make the following change:
如果出现错误,
stream_socket_client()
返回 false。您应该显式地测试它:其中 $error/$errorString 是您在stream_socket_client() 调用中指定的那些。
stream_socket_client()
returns false if there was an error. You should explicitly test for it:where $error/$errorString are the ones you've specified in the stream_socket_client() call.