Apple extended notification Apple

I used this great blog post to try and get Apple Push notifications from my server. The connection seems to work just fine, and I can write to it. However, no notice has been received. To try and debug it, I would like to create an “extended notification” that will cause the APNS server to return an error code before shutting down. However, I'm not sure how to create data to send to the server using PHP.

Currently, for normal notification, I use according to the instructions:

$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;

This creates a request in the format:

alt text

However, I need a request in the format:

alt text

Where, according to the documentation:

- , . error-response, APN .

- UNIX, (UTC), , . expiry (big endian). , APN . , , APN .

!

+3
2 answers
$apnsMessage = 
    // new: Command "1"
    chr(1)
    // new: Identifier "1111"
    . chr(1) . chr(1) . chr(1) . chr(1)
    // new: Expiry "tomorrow"
    . pack('N', time() + 86400)
    // old 
    . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;
+5
source
$apnsMessage = pack('CNNnH*na*',
    1, // always one
    intval($messageId), // sequential Id for a message
    time() + 86400, // UTC relative timestamp + one day
    32, // device token binary length
    $deviceToken, // clean (no spaces, hex-only) device token
    mb_strlen($payload, '8bit'), // payload binary length
    $payload
);
+1
source

Source: https://habr.com/ru/post/1785226/


All Articles