i honestly have no idea… The tests you’ve done are completely sensible. The _only_ difference in the code between the two requests is that the first one does “SELECT * FROM push” and the second does “SELECT * FROM push WHERE token=token”.
In other words, if the second method works, the first one should as well.
The only thing I can think of is that the first request is somehow incorrectly detecting a token in the URL.
Can you try temporarily changing the code:
function send_payload($handle, $deviceToken, $payload) {
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;
return fwrite($handle, $apnsMessage);
}
to
function send_payload($handle, $deviceToken, $payload) {
echo $deviceToken."\n";
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;
return fwrite($handle, $apnsMessage);
}
and see if that shed any light onto the issue?