Hey guys. I am working on an app that implements push. It works great in development mode connecting to the sandbox servers, but it just doesn't play nice with the production servers.
I am using the following PHP code to do the actual pushing.
I have the correct password for the certificate in the PHP, I have the certificate on my server, I can push fine using the same script but using sandbox. Can anyone provide any insight to make this work. It's the last step to a giant puzzle.
I am using the following PHP code to do the actual pushing.
PHP:
function pushiPhoneMessage($token,$message) {
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', './production1.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'thepass');
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); //gateway.sandbox.push.apple.com, port 2195 for development
if(!$fp) {
print "Failed to connect $err $errstr\n";
} else {
$payload = json_encode($message);
//echo $token." > ".$payload."<br/>";
$msg = chr(0) . chr(0) . chr(32) . pack('H*',str_replace(' ', '', $token)) . chr(0) . chr(strlen($payload)) . $payload;
fwrite($fp, $msg);
}
fclose($fp);
}
I have the correct password for the certificate in the PHP, I have the certificate on my server, I can push fine using the same script but using sandbox. Can anyone provide any insight to make this work. It's the last step to a giant puzzle.