我从这个Apns码中为php和目标c做了apn代码
以及来自此链接的安装证书
沙箱和生产apns用于向ios设备发送通知在我的服务器上运行得很好,我将代码和同一个证书转移到客户端服务器,然后发送通知就不起作用了。
我调试了所有php代码,发现它停止在这一行代码中。
private function _connectSSLSocket($development) {
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $this->apnsData[$development]['certificate']);
$this->sslStreams[$development] = stream_socket_client($this->apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
if(!$this->sslStreams[$development]){
$this->_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
unset($this->sslStreams[$development]);
return false;
}
return $this->sslStreams[$development];
}apns.log文件显示错误“连接到APNS: 110连接超时”失败。
没有得到错误。为什么我会收到这个错误而不向ios设备发送通知?有人能指点我吗?
发布于 2013-10-12 06:11:42
最后,我选择了vps,而不是共享主机。卢卡布罗的评论帮助我解决了。谢谢卢卡布。
发布于 2019-11-18 20:38:04
一个好的解决方案是使用像firebase这样的云函数来运行实际的apns连接,并在共享主机中为您的另一个后端公开一个API。这是我在处理这个问题时所用的方法。
防火墙云功能方便,易于开发,几乎免费。
https://firebase.google.com/docs/functions
我会把我的解决方案发到下个星期。
https://stackoverflow.com/questions/19025488
复制相似问题