hengsokchamroeun / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

How to disable store-and-forward #76

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Based on doc from Apple about Expiry, if it is <=0, it will not store the 
notification at all, but I have trouble for gateway discards the request. Here 
is what I did:

1. Modified getMessage() to set expiry to 0 or less;
2. Turn Fight Mode on
3. Wait for new minutes.
4. Turn off Fight Mode

However, I still received the notification. Did I miss something or message 
will be delivered at least once?

Thanks.

Jim

if (expiry <= 0) {
    bao.write(intTo4ByteArray(expiry));
}
else {
    long ctime = System.currentTimeMillis();
    long ttl = expiry * 1000; // time-to-live in milliseconds
    Long expiryDateInSeconds = ((ctime + ttl) / 1000L);
    bao.write(intTo4ByteArray(expiryDateInSeconds.intValue()));
}

Expiry—A fixed UNIX epoch date expressed in seconds (UTC) that identifies 
when the notification is no longer valid and can be discarded. The expiry value 
should be in network order (big endian). If the expiry value is positive, APNs 
tries to deliver the notification at least once. You can specify zero or a 
value less than zero to request that APNs not store the notification at all. 

Original issue reported on code.google.com by wguo1...@gmail.com on 18 Oct 2011 at 6:09

GoogleCodeExporter commented 8 years ago
Fixed in trunk.  The version I just committed will now honor zero-or-less 
expiry settings.

Please let me know here if the fix works for you.

Original comment by sype...@gmail.com on 18 Oct 2011 at 6:31

GoogleCodeExporter commented 8 years ago
It works sometime but not always, but has nothing to do with the lib itself. I 
guess it is up to Apple gateway. If I wait only one minute, I still receive the 
notification; if longer (say 5min), no notificaiton. It must have been scanning 
processes running Periodically. Not sure exact interval. thanks. 

Original comment by wguo1...@gmail.com on 18 Oct 2011 at 7:00

GoogleCodeExporter commented 8 years ago
Support for setting zero-expiry did not exist before the commit I did earlier 
today, thus any test you made with a prior version will not give reliable 
results. 

It should be noted that Apple's push notification system has no delivery delay 
guarantee, thus the variations you are seeing may be normal, even when 
notification storage is disabled.

Since the library does properly set zero-expiry now, and that actual handling 
of that setting is up to Apple, I would suggest closing this issue as Fixed...

Original comment by sype...@gmail.com on 18 Oct 2011 at 7:10

GoogleCodeExporter commented 8 years ago
Totally agree it is fixed in lib. Thanks. 

Original comment by wguo1...@gmail.com on 18 Oct 2011 at 7:26

GoogleCodeExporter commented 8 years ago
Thank you!

Closing as Fixed in 2.0.005 (in trunk).

Original comment by sype...@gmail.com on 18 Oct 2011 at 7:51