APNS expiry time wont work

I am having trouble sending offline push messages to the apple devices. I am using APNS enhanced format and I formatted my packet like the below: (in perl)

print "I will timeout in $timeout \n";

return pack(

'cNNnH*na*', # format

1, # command

$id, # message ID used for error tracking

$timeout, # expiry timestamp

32, # Lenth should always be 32 as per Apples doc

$devicetoken, # token (Hex not string)

bytes::length($json), # payload length

$json # payload

);



This always works when the device is connected to the internet. I tried killing the app, disabling data from the app and it always work. However, it never works when I send the push while the device is offline (eg. in Airplane mode). I am setting the expiry time adding a day with the current epoch time. But it doesnt seem to work. I am not getting any error back from APNS from my side everything looks good. As per my understanding, once I set expiry to a future date APNS should try to send the push later again. I kept on waiting and it never showed up. What can be the possible reason for this What else I may try to check the issue?

Replies

Are you certain you're using the right units for your timestamp? The "legacy" notification format (which you appear to be using) wants a timestamp in seconds since the epoch, and it may be that you're trying to give it milliseconds, which could cause some confusion.

Hi, did you solve this, i have the same problem.


I use

_expirationDate = time(NULL) + 86400; // default expiration date set to 1 day


and then converting to big endian


uint32_t networkOrderExpiryEpochUTC = htonl(_expirationDate);


as it is required. https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/LegacyNotificationFormat.html#//apple_ref/doc/uid/TP40008194-CH14-SW1


Lukyn.cz