I am trying to send push notification to a bunch of iPads and tested it first with the device I have. It worked just fine. Then I tried to expand it to include multiple devices, including my own, and it doesn't seem to work (checked with other relevant device holders just to make sure). The device token information appears to be just fine. What could be wrong? Maybe it's a throttling issue?
I tried to rewrite everything from the following tutorial and the issue is still the same: http://learn-php-by-example.blogspot.co.il/2013/01/working-with-apple-push-notification.html
I get no error in the checkAppleErrorResponse
function.
Here is the code that changes when changed from one device to many:
foreach ($device_tokens as $token)
{
$apple_identifier = '[censored]';
$payload = json_encode($body);
$msg = pack("C", 1) . pack("N", $apple_identifier) . pack("N", $apple_expiry) . pack("n", 32) . pack('H*', str_replace(' ', '', $token)) . pack("n", strlen($payload)) . $payload;
/* Actually sends the notification */
fwrite($fp, $msg);
$this->checkAppleErrorResponse($fp);
}
Update: I tried to manually copy some of the tokens and do random tests on when devices receive the notifications. Although I can't say the results are conclusive, it turns out that when all tokens are certainly valid (devices that exist in our company), the messages go through. However, when I add at least one device that I can't check personally (means it might be invalid, or the user refused notifications), none of the devices in the list get messages.
The question is, does this mean Apple requires the entire array of tokens to be valid devices whose owners authorized APNs? (Seems completely illogical, but it's the only explanation I can think of).