Having problems with production push

Discussion in 'iOS Programming' started by Jeremy1026, Jun 23, 2009.

  1. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #1
    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.


    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$errstr60STREAM_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.
     
  2. Jeremy1026 thread starter macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #2
    It was a problem with my build, it wasn't connecting to the push server.
     
  3. notmaxx macrumors newbie

    Joined:
    Dec 2, 2009
    #3
    Hi Jeremy,
    I met the same problem, could you help on this, sandbox is ok but production push doesn't accept my certificate
     

Share This Page