我在Ruby中发送HTTP/2 POST请求时发现了一个类似的问题 但是我想用PHP更新我的服务器
此处描述了基于HTTP/2的新Apple推送通知API:https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html
任何具有HTTP/2经验的人都可以帮助我在PHP中作为客户端发出请求.
在尝试执行我的php脚本以向我的iphone发送推送通知后,我收到此错误.
我尝试了一切,没有任何作用.我相信这意味着我ck.pem错了,但我不确定它是key.pem还是cert.pem是错误的.
请帮忙
脚本
// This this a fake device id:
$deviceToken = '9870h8v088bj29u080af894jj67klfgcv9mmm79k8e4l23456h908743n093e359';
// fake password:
$passphrase = '123456';
// Put your alert message here:
$message = 'New Message';
////////////////////////////////////////////////////////////////////////////////
$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 …Run Code Online (Sandbox Code Playgroud) 我使用apns与http2协议发送推送通知,我使用的代码类似于这篇文章:https://stackoverflow.com/a/34831873/1546652
当我的应用程序正确安装时,apns http2 api在发送消息时工作正常,我的回复是这样的风格:{"response":"","httpcode":200}
问题是,当我卸载应用程序并向无效registrationId发送推送时,我没有收到状态410,也没有响应"原因:未注册",仍然收到状态为200的真实响应.
在apns http2中取消应用程序时,如何获得410状态和对应响应?