苹果推送通知不适用于分发,而是用于开发

我在我的应用程序中实施推送通知,在开发部分工作正常,我收到推送通知。 当我决定在应用程序商店发布它时,我实现了它的分发(我使用证书和configuration文件进行分发),我做了相同的步骤,并通过应用程序将.p12文件转换为.pem, certificate.pem和key.pem到另一个文件ck.pem。 在PHP文件中,我做了以下操作:

$passphrase = 'The passphrase I put it in the shall'; $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.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); 

我已经改变了沙箱到SSL://gateway.push.apple.com:2195在我的PHP。

我用这个步骤创build了production.pem。

 $ openssl x509 -in aps_developer_identity.cer -inform der -out PushChatCert.pem $ openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12 Enter Import Password: MAC verified OK Enter PEM pass phrase: Verifying - Enter PEM pass phrase: $ cat PushChatCert.pem PushChatKey.pem > ck.pem 

我把我的ck.pem上传到我的共享主机。 这不是什么错误,但不会推送通知。

在我的php它说:连接到APNS消息成功交付

你可能使用了错误的deviceToken。 记住生产deviceToken和开发deviceToken是不同的

您应该logging您的deviceToken,然后iPhoneconfiguration实用程序将logging您正确的生产deviceToken。

我相信在服务器端不使用分配PEM文件。 主要的基本规则是应用程序和服务器应该以相同的模式运行。如果你的应用程序运行在debugging模式,那么服务器也应该使用开发PEM文件,如果你的应用程序运行在发布模式,那么服务器也应该使用分布式PEM文件。