Number of max retries if the sending notification is failed.

48 views
Skip to first unread message

Tran Ho

unread,
May 27, 2020, 3:44:55 AM5/27/20
to pushy
Hi Jon and everyone,

This is a small question regarding the max retries. We are going to find the optimal times to do resending in case of failure. Is there any documentation or relevant information? 

Thanks in advance.

Jon Chambers

unread,
May 27, 2020, 8:31:16 AM5/27/20
to pushy
Can you please clarify what you mean by "failure?"

If an attempt tosend a notification fails entirely (i.e. with an exception), then it never made it to the server. That's likely due to local network conditions, and it's up to you to decide how to handle those cases. If the notification made it to the server but was rejected, with very limited exception for the HTTP/503 errors, you probably shouldn't retry at all. You can find a list of rejection reasons in the APNs docs: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns.

-Jon

Tran Ho

unread,
May 27, 2020, 8:35:04 AM5/27/20
to pushy
Thanks for your reply.

Regarding your documentation, the CompletableFuture will complete in one of three circumstances:
  1. The gateway accepts the notification and will attempt to deliver it to the destination device.
  2. The gateway rejects the notification; this should be considered a permanent failure, and the notification should not be sent again. Additionally, the APNs gateway may indicate a timestamp at which the destination token became invalid. If that happens, you should stop trying to send any notification to that token unless the token has been re-registered since that timestamp.
  3. The CompletableFuture fails with an exception. This should generally be considered a temporary failure, and callers should try to send the notification again when the problem has been resolved.
I would like to implement the retrying mechanism in the third circumstance. 

Jon Chambers

unread,
May 27, 2020, 9:11:07 AM5/27/20
to pushy
I see. I don't think there's any one-size-fits-all solution; you'll need to observe what happens in practice and decide on a solution that makes sense for you and your circumstances. You may find something like https://github.com/resilience4j/resilience4j helpful.

-Jon
Reply all
Reply to author
Forward
0 new messages