在生产模式下的推送通知不会到来但是在开发中即将到来

我的PNS在开发模式下工作良好。 我已经使用raywendelich博客做了这个。 同样的方式,我已经在生产模式下创build证书,并从服务器运行相同的脚本,但没有收到任何通知

当我们从我们的服务器进行生产模式testing时,需要哪个额外的步骤,是非常迫切的需要。 plase帮助生产模式做什么。

我们的PHP代码

<?php // Put your device token here (without spaces): $deviceToken = 'd5d89cab86e6f1a3cfa66dd853f3f4d7dd932c4a6da793cb9c86d31e9cfcb31f'; // Put your private key's passphrase here: $passphrase = '*******'; // Put your alert message here: $message = '****'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'ckm.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); 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); 

您需要创build生产APNS证书(与您创build开发人员证书的方式非常相似),然后使用该证书连接到Apple。 开发和生产的pushtokens是不同的,所以为了得到您的生产推动令牌,你必须build立一个AdHoc版本的应用程序。 当你在你的设备上安装ad-hoc版本时,它应该问你是否要收到推送令牌。 接受和你的代码应该把你的生产推送令牌发送到你的服务器(我假设你保存在服务器上的所有pushtokens)。 这是您需要用来testing生产推送代码的标记。