自上周五(4 月 23 日)以来一切正常,我收到了沙盒和生产通知。但是当我现在检查时,通知不起作用。我检查了我的 .pem 文件在 2021 年 12 月之前有效,当我运行以下代码时,结果是“消息已成功传递”。我不知道发生了什么。请帮帮我。
<?php
$deviceToken = "a9eb9cd54446b5cad4fa3636dbe822b5d420126fdbb632ef79b4bf07bfd8b6b4";
$passphrase = 'secret';
$message = "Hello world!";
$ctx = stream_context_create();
$passphrase = 'secret';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'certi.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
/* $fp = stream_socket_client(
'ssl://gateway.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);*/
$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 tess connect: $err $errstr" . PHP_EOL);
}
$body = array('aps' => array('alert' => $message,'sound' => 'default','badge' => 1),'rewards_badge' => 1);
$payload = json_encode($body);
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
$result = fwrite($fp, $msg, strlen($msg));
if (!$result){
echo 'Message not delivered' . PHP_EOL;
}else{
echo 'Message successfully delivered' . PHP_EOL;
}
fclose($fp);
?>
谢谢
答案 0 :(得分:1)
我也是。我向 Apple 提交了帮助请求,请他们提供帮助。
我使用相同的测试脚本。我注意到 ssl://gateway.sandbox.push.apple.com:2195
不再有效。
If your Apple devices aren't getting Apple push notifications
这是新域名? api.sandbox.push.apple.com:443
Sending Notification Requests to APNs
我也是。让我们像 Apex Legends 一样一起解决这个问题。
我已向 Apple 提交了 TSI。他们在 2 月 10 日发送了一封电子邮件说:
从 2021 年 3 月 29 日起,与 Apple 推送通知服务的基于令牌和证书的 HTTP/2 连接必须包含新的根证书 (AAACertificateServices 5/12/2020),以取代旧的 GeoTrust Global CA 根证书。为确保无缝过渡并避免推送通知传送失败,请在 3 月 29 日之前验证 HTTP/2 接口的新旧根证书都包含在每个通知服务器的信任存储中。
请注意,Apple 向您颁发的 Apple Push Notification 服务 SSL 提供商证书此时无需更新。
了解有关连接到 APN 的更多信息。
如果您有任何问题,请联系我们。
此致,Apple 开发者关系部
更新 - 5 月 3 日星期一,在向 Apple Dev 提交 TSI 后
Registering Your App with APNs
Establishing a Token-Based Connection to APNs
Generating a Remote Notification
我学到了什么?
好消息?新的 APNS 提供程序 API 仍然与 Objective C 兼容!
?