我想通過php在iOS應用程序中發送推送通知。所以iOS開發人員給我一個pem文件。我請求託管服務器打開gateway.sandbox.push.apple.com:2195
,他們已經打開了該端口。但是,當我嘗試發送推送通知時,出現以下錯誤。我的代碼看起來像iOS推送通知連接失敗錯誤
$deviceToken='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$passphrase="";
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', '/home/sitename/public_html/push/ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195',
$err,
$errstr,
60,
STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,
$ctx);
if (!$fp)
exit("Failed to connect amarnew: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
收到以下錯誤
Failed to connect amarnew: 0
所以,我想通過telnet連接到蘋果,那結果是
[email protected] [~]# telnet gateway.sandbox.push.apple.com 2195
Trying XX.XXX.XXX.XX...
Connected to gateway.sandbox.push.apple.com.
Escape character is '^]'.
^\q
^]
telnet> q
Connection closed.
[email protected] [~]#
由於我是新來這個,我只是在這裏困住了。請任何一個幫助我提前
感謝
聽起來像您的證書/密鑰對.pem文件已損壞,重新生成它。我只是推動工作,所以我知道這是一個棘手的話題。 – Woodstock