我也是男人。让我们像 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 之后
在 Apple 迁移到新的 APNS 提供程序 API(http/2 协议)后,推送通知于 2021 年 3 月 31 日停止为开发人员工作。
要继续使用推送,请参阅此页面:https ://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/
我学到的是?
撤销与 APNS 相关的所有开发者帐户证书 制作新证书,这次在将它们安装到您的提供服务器时不要制作任何 PEM 文件。此外,请确保在2195
连接到 APNS 时停止使用端口并使用443
or 2197
。
好消息?新的 APNS 提供者 API 仍然与 Objective C 兼容!
<?php
// Put your device token here (without spaces):
$deviceToken = '09a0c8ff92b3621c5f5032c1fa031f2851d01dd99beaf1446c281c5458fe2ffd';
// Put your private key's passphrase here:
$passphrase = 'pushchat';
// Put your alert message here:
$message = 'Hello!';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$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: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n',
strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;
// Close the connection to the server
fclose($fp);
更新:我对 PEM 方面的看法是错误的。对于使用新的 APNs Provider API 的 APNs 连接,仍然需要创建 PEM 文件。