title: Push notification not receiving on iphone
body: <p>I am using <strong><a href="http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12" rel="nofollow">this tutorial</a></strong> to learn push notification. </p>
  
  <pre><code>&lt;?php
  
  // Put your device token here (without spaces):
  $deviceToken = '1675ba8bb005740bb514222227f861c30230a81e6eed6bb6b8f353c57831341d';
  
  // Put your private key's passphrase here:
  $passphrase = '111134';
  
  // Put your alert message here:
  $message = 'My first push notification!';
  
  ////////////////////////////////////////////////////////////////////////////////
  
   $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 body
  $body['aps'] = array(
  'alert' =&gt; $message,
  'sound' =&gt; '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));
   echo 'result =' . $result. PHP_EOL;
  if (!$result)
  echo 'Message not delivered' . PHP_EOL;
  else
  echo 'Message successfully delivered' . PHP_EOL;
  
   // Close the connection to the server
  fclose($fp);
  </code></pre>
  
  <p>I also configure app for push notification. After configuring for push i also recreate provisioning  profiles, old delete one, install new profile. 
  I run app it gives me device id and then i connect both server sandbox and production to send push notification with their relative push profiles but still i am not able to receive push notification on my device.</p>
  
  <p>I also install ipusher on my device and check push notification. they are coming from that application.</p>
  
  <p>One strange thing i notice is that i change my application identifier and use any other app id then device token remain same</p>
  
  <p>Now my problem is I am not receiving the push notification on my device.</p>
  
  <hr>
  
  <p>The problem is not in my profiles. May be the error is php code that i am using because when i use the easy apns on remote server then it sends push notifications.
  The notifications received time was 6 to 7 hours. I think this is due to network problem on my device side.
  But now it is working fine after 2 days on production profile. Now notification take no time for delivering on my device but it is taking 30 sec to 5 minutes on some devices.</p>
  
  <hr>
  
  <p>There can be one more problem if you are not receiving push notifications on your device from other apps too, then you should check your DNS for the connection.</p>