iOS APNS “best-effort” fallback

2020-02-01 18:10发布

问题:

I cannot seem the have my head around this. APNS as stated in the documentation has best-effort delivery, i.e. delivery is not guaranteed. However, if I am to use the push-notification model in my client/server application, I have to use them somehow.

The general model looks as follows: there is new data on the server -> the server then sends a push notification informing the client(s) that there is new data available -> client downloads new data.

The question is then, if I cannot rely 100% on the notification to be delivered, what kind of fallback mechanism can I use so that I can ensure that the client receives the new data available on the server ? What is the way to ensure that the client has the most-up-to-date data using APNS ?

回答1:

What is the way to ensure that the client has the most-up-to-date data using APNS ?

There is no way to do this with just APNS. Your client needs to query your server when the app is brought to the foreground to see if there is new data, regardless of any push notifications you may have lost or received.



回答2:

It all depends on how you are planning on using APNS.

Lets say you were making an App that sold items like eBay. You have:
- bids being placed by multiple users
- countdown to item closing time

You would not use APNS to update the timer on the persons device or notify them of the current price of the item. These are too crucial to rely on a best-effort delivery and was not the intended use of APNS.

It would be best if, in this scenario, you had the app poll the server every X seconds for updated information. You could then user APNS for non-crucial features like notifying the user if they are outbid or if they have won the item.