APNS (Apple Push Notification Service) reliability
Asked Answered
S

5

38

Our app uses APNS to receive Push Notifications. However, our client claims that some of their devices were not receiving notifications and argues to they 'must' make sure the notifications to be delivered 100%. But I have read somewhere that APNS is not 100% reliable and there should be cases which the notifications are not delivered.

I'm currently panic at how we could make sure APNS to received anytime. I have read that a case which may APNS not delivered (device may offline). But our test showing that even the device is online (Wifi or 3G), sometimes APNS were not delivered.

Is there any specific case which may APNS will not delivered? Or is there anything we (developers) can do with codes to make sure to receive all notifications? What I have done in the code is just registering the app to remote notification and write didRegisterForRemoteNotificationsWithDeviceToken, then throw the device token to our server.

Any help would be appreciated, for our client almost kill us if ALL of their devices not receiving APNS!

Sienese answered 16/12, 2012 at 0:44 Comment(8)
Yeah, it's not reliable, in the normal network sense of the word.Edulcorate
Is the backend pushing the messages to APNS controlled by you as well? In that case you should be able to log if some sendings to APNS fails and you could look and see if the feedback-service contains the tokens for the devices not getting the messages.Megasporophyll
Thank you for quick reply johan! If you are talking about the server-side, yes they're controlled by our PHP server. According to one of our developers who's in charge of server-side development, currently looks like the APNS messages were sended successfully. And the device sometimes gets notification, sometimes not. I'm getting confused and crazy about this APNS things...Sienese
@Edulcorate Aw, that's shame... In a sense, maybe you're right. But our client's so called 'iOS guru' said "there's NO case that APNS could fail with sending messages!" Maybe he's just an "Apple fanboy" or something?Sienese
I don't know if he's an Apple fanboy or not, but he's wrong on this issue, technically. It says it right in the documentation. Search for "best effort".Edulcorate
Yes, I have read that also. The real shame is perhaps he cannot understand English or too blind to accept this fact...Sienese
re Nate : developer.apple.com/library/Mac/DOCUMENTATION/… localtion is changed Search for "best effort" NOTE from that link: Important: Delivery of notifications is a “best effort”, not guaranteed. It is not intended to deliver data to your app, only to notify the user that there is new data available.Elyn
Are firebase notifications in iOS more reliable than APNS ? –Saporific
C
48
  1. APNS is based on Apple Servers, and Apple doesn't give any guarantee on successful message delivery.
  2. If the app is open (i.e. the user is using the app) while the notification arrives, iOS doesn't show a notification message, you need to handle it.
  3. Notification shows up only when the app is backgrounded or killed.
  4. Also implement feedback service on your server side; will help you get rid of old unwanted tokens (users who deleted the app or disabled notifications through settings).
  5. Don't send too many notifications to a device within a short span of time, because APNS caches only 1 message/device (if the device is offline). So it can deliver the message when the device comes online. Am not sure how long the message is cached though.

Or just implement Pusher... http://pusher.com

Cinchonism answered 16/12, 2012 at 3:35 Comment(5)
Thank you for your clear answer! Even in the document states and many real developers explained it, our air-headed client won't believe that APNS is not 100% reliable... perhaps they tested on the case 2 and didn't receive the notification. We cannot use third-party implementation, but thanks anyway for good suggestion!Sienese
Just a note: The recommendation to implement pusher is not a complete solution, since pusher does not deal with messages missed while offline or the app isn't running. My recommendation for best solution to push message reliability is to use sync-to-sync (where you download and display all messages) with a quality of service sequence number (timestamp) that calls back to the server once the push arrives. If it doesn't arrive, send a sync-to-sync push again. This can achieve 100% delivery. Of course it depends on your needs.Inconsumable
first you have to deal with the certificates crap.. then you have to deal with apns's unreliability..Nominalism
Or just implement pusher... I don't understand, because Pusher just uses APNs and FCM which are both unreliable services. Pusher does not add reliability.Frieze
@Cinchonism do the same rules apply for FCM ... because, for iOS devices, FCM uses APNs under to hood.Violent
F
10

We're facing the same problem. As everybody said, APNS is a best effort service so you can't be sure every notification will be delivered, but what you can do is to be sure of which ones have been received. This is what we're about to do. We register in our backend each notification que ship and the mobile app reports back each notification it receives. Then we set a maximum time of waiting for a notification to be received, if we don't receive the report back we try again.

I hope it might be helpful to someone (even 2 years later)

Fleabitten answered 28/11, 2014 at 19:18 Comment(3)
What if the end users device is off?Kaitlinkaitlyn
How do you stop the original message from being delivered (in our experience, sometimes up to 3 minutes later.... :(Carvel
Are firebase notifications in iOS more reliable than APNS ?Saporific
D
5

It says it quite clearly in the Apple Docs that it is not 100% gauranteed and nor should it be used as so. Its sent with "best effort".

Daffie answered 12/7, 2013 at 4:40 Comment(1)
Find "best effort" at developer.apple.com/library/IOs/documentation/…Daffie
S
0

As per Apple's guidelines, APNS is not 100% reliable service which means your app may not get push notifications from Apple servers due to some of the following reasons:

  • Device is offline
  • Your app is in the foreground state, you need to manage the push notification.

Note: Apple rejects apps which make compulsion to use notification services. (I have faced it in one of my App)

For more information, you can look into this answer

https://mcmap.net/q/410936/-how-to-know-push-notification-delivery-status

Snowbird answered 23/3, 2018 at 6:36 Comment(2)
Are firebase notifications in iOS more reliable than APNS ? –Saporific
Firebase is third party which eventually uses APNS.Snowbird
S
0

Implement custom notification handling logic inside app.

  1. Prepare Custom Payloads: When sending push notifications through a service like APNS or Firebase Cloud Messaging (FCM), include a custom payload with a unique identifier for each notification.
{
  "aps": {
    "alert": "Your notification message here",
    "badge": 1,
    "sound": "default"
  },
  "custom_id": "unique_identifier_for_notification"
}
  1. Handle Notifications in Your App: Implement the necessary code in your mobile app to handle incoming notifications. When a notification is received, extract the custom identifier from the payload.
  2. Update Status Locally: Maintain a local database or storage to store the status of each notification. When a notification is received, mark it as "received" in your local storage.
  3. Send Confirmation to Server: Implement logic to periodically send a confirmation to your server that indicates the device has received and processed the notification. Include the custom identifier in the confirmation payload.
Snappish answered 19/12, 2023 at 5:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.