APNS: Unexpired, priority=10, type=alert sometimes do not appear in Notification Center when coming back online

System Information: iPhone 13, iOS 17.6.1

Steps to reproduce:

  1. Open my app, causing it to register for an APNS token
  2. Kill my app to make sure it is not in the foreground
  3. Send a push notification with a payload similar to this:
{"aps":{"alert":{"title":"My App Name","body":"10:24am 🚀🚀🚀"}},"price":19,"clock":175846989,"time":1731001868.379526}

And the following attributes:

Expiry: (Date that is 7 days from now)
Type: Alert
Priority: High (10)
Payload Size: 141 bytes
  1. The notification appears in the Notification Center, as expected
  2. Turn on Airplane Mode (WiFi=off)
  3. Wait between 60 seconds - 8 hours (varies)
  4. Send the same notification payload/attributes again
  5. Wait between 60 seconds - 8 hours (varies)
  6. Turn on WiFi
  7. Wait 1-30 minutes (varies)

Expected behavior:

  • The notification appears in the Notification Center

Actual behavior:

  • Push notifications from other apps immediately appear in the Notification Center
  • Roughly 30% of the time: The push notification(s) from my app never arrive, even after waiting 30 minutes
  • Roughly 70% of the time: The notification appears in the notification center, and everything works fine

Thoughts:

  • Expiry must be set correctly because I've seen my notifications get queued and then delivered (correctly) in the CloudKit Push Notification tool.
  • Identical notifications (payload, APNS headers, etc.) are also sent to other devices at the same time. They receive the notifications just fine.
  • It must not be my iPhone's notification Settings, because notifications appear correctly when online
  • I've tried restarting the iPhone, it did not fix this issue
  • So it seems it must be an unexpected behavior in APNS or something broken with my specific phone? Not sure what else I could possibly do to make sure the notifications arrive.

This breaks the entire experience of my app. I need to be able to notify users of incoming messages so they do not miss them.

Normally I would use the CloudKit Push Notification tool delivery logs, but I have been unable to reproduce the issue in the CloudKit Push Notification tool so far. I can only try a few times per day due to the very long wait times sometimes required to reproduce the issue.

I can think of two reasons this could be happening.

First one is on you - APNs stores only one single undelivered notification per app for future delivery (when the device becomes available). If you are sending another notification to the app, whether it is alert, p=10, or low priority silent/background notification, the second notification will replace the first one in storage. So the first undelivered notification will be dropped for good. So, make sure there isn't another notification being sent, either via the Notification tool or by your regular push mechanism.

The second one could be an issue with the notification getting stuck our deduping logic - based on you saying after WiFi off you are sending the same notification attributes and content you have sent just before the test. We have some logic in place where if a device is having problems keeping a persistent connection to APNs, and notifications get rerouted over cellular or WiFi, to minimize risk of delivering the same message twice, if the notifications are identical, the system could be ignoring the second one. Can you try with different messages? (both attributes and content).

To be able to see what might be going on, it would help if you can share the apns-id's of the two notifications. Please share them as soon as possible after reproducing the issue as our logs rotate quickly and @ mention me in case the repro falls to one of the upcoming holiday breaks.

If we see that the second message has been received by the device, then we will look at some logs from the device to see what the problem might be.


Argun Tekant /  DTS Engineer / Core Technologies

Thank you for the fast reply.

  • I'm not using other notification types. Only p=10, alert. So I would expect to see at least one Notification when I turn WiFi on. But I do not see any.

  • I frequently experience the issue in production where I am sending a different payload each time (clock and timestamp are unique, and the message is usually different) so I don't think it's due to identical payloads

I am not sure if I have the apns-ids because I'm using Amazon SNS to deliver the notifications. Perhaps it is the messageId or deliveryId field below? I also have a precise timestamp and device token below, if that is something you can use.

I'm fairly certain this one failed to appear, but just in case you don't see anything unusual on your side, I will try to reproduce the issue again.

Token:
3f6e0931ae20851fdb17fe1add4a880a0449adabe130be01d08bf8fae79e2f09

# 2024-11-12T11:12:36.528-05:00
{
    "notification": {
        "messageMD5Sum": "...",
        "messageId": "4f660f74-9108-5925-a5bf-50d911ba999e",
        "topicArn": "...",
        "timestamp": "2024-11-12 16:12:34.1"
    },
    "delivery": {
        "deliveryId": "8ed6d103-a369-598d-9bbc-8eae23dbea58",
        "destination": "...",
        "dwellTimeMs": 67,
        "token": "3f6e0931ae20851fdb17fe1add4a880a0449adabe130be01d08bf8fae79e2f09",
        "statusCode": 200
    },
    "status": "SUCCESS"
}

I'll also keep trying to reproduce the issue using the APNS API directly, so I can specify an apns-id.

The history of this push and the following ones are:

  • 11:12: this push is sent and is stored because the device is offline
  • 11:40: another push is sent, the device is still offline, so that one was stored instead of the first one.
  • 11:57: another push is sent. This wakes up the connection with the device and this third push is delivered. The previous two pushes are lost.

Does this match what you have observed?

Does this match what you have observed?

No. I'm pretty sure the third push never arrived in the Notification Center.

To increase our confidence, I reproduced the issued again. This time I wrote everything down and took screenshots so I'm 100% sure of what happened:

  • Sat Nov 16 22:25 EST 2024 — AirplaneMode=on, Wifi=off
  • Sun Nov 17 03:53 EST 2024 — Amazon SNS reports successful API call to APNS:
{
    "notification": {
        "messageMD5Sum": "...",
        "messageId": "...",
        "topicArn": "...",
        "timestamp": "2024-11-17 08:53:51.186"
    },
    "delivery": {
        "deliveryId": "...",
        "destination": "...",
        "dwellTimeMs": 57,
        "token": "3f6e0931ae20851fdb17fe1add4a880a0449adabe130be01d08bf8fae79e2f09",
        "statusCode": 200
    },
    "status": "SUCCESS"
}
  • Sun Nov 17 05:30 EST 2024 — Wifi=on, Gmail push notification appears. No notifications from my app.
  • Sun Nov 17 06:52 EST 2024 — Still 0 notifications from my app

I think we are going to need some logs from the device and for us to share some additional information better handled in private. Can you please open a support request at https://developer.apple.com/contact/request/code-level-support/ and reference this forum thread in the "Did someone from Apple ask you to submit ..." section.

That will come to me, and we can continue there.


Argun Tekant /  DTS Engineer / Core Technologies

APNS: Unexpired, priority=10, type=alert sometimes do not appear in Notification Center when coming back online
 
 
Q