I am using this tutorial to learn push notification.
Use UrbanAirShip. In my opinion it's the best server side solution since it includes Push-alike notifications for Android (C2DM) and Blakberry too.
Try finding differences between these to files and understand them. Might be a solution to your problem. Here's my code:
$message, 'badge' => intval($badge), 'sound' => $sound);
$payload = json_encode($payload);
$apns_url = NULL; // Set Later
$apns_cert = NULL; // Set Later
$apns_port = 2195;
if($development)
{
$apns_url = 'gateway.sandbox.push.apple.com';
$apns_cert = '/path/apns.pem'; // relative address to an App Specific Certificate file
}
else
{
$apns_url = 'gateway.push.apple.com';
$apns_cert = '/path/cert-prod.pem';
}
$stream_context = stream_context_create();
stream_context_set_option($stream_context, 'ssl','local_cert',$apns_cert);
$apns = stream_socket_client('ssl://'.$apns_url.':'.$apns_port,$error,$error_string,2,STREAM_CLIENT _CONNECT,$stream_context);
// You will need to put your device tokens into the $device_tokens array yourself
$device_tokens = array(); // tokens!!!
foreach($device_tokens as $device_token)
{
$apns_message = chr(0).chr(0).chr(32).pack('H*',str_replace(' ','',$device_token)).chr(0).chr(strlen($payload)).$payload;
fwrite($apns, $apns_message);
}
@socket_close($apns);
@fclose($apns);
?>