I’m currently writing a passbook API that allows users to send push notifications to passes. Now I’m at the point of testing it but my push notification aren’t arriving. I’m writing the push sending code in PHP and this is what I have so far:
$payload = json_encode(array("aps" => array("alert" => "test", "sound" => "default")));
//send it to all devices found
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
error_log($row['pushToken']);
//write the push message to the apns socket connection
$msg = chr(0) .
pack("n",32) .
pack('H*', $row['pushToken']) .
pack("n",strlen($payload)) .
$payload;
fwrite($fp, $msg);
}
Is there anything I’m missing here or doing wrong? The certificate is valid and connecting to the APNS server doesn’t give me any error.
Thanks!
I’ve solved this problem by re-creating the certificate, doing the openssl magic again and use the new certicates. Now it’s working, so I think there was something bugged in my certificate 🙂