Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Multiple Push Notifications not visible in Notifications Tray

I basically want to make multiple push notifications in the same application visible in the notification tray in iOS.

This scenario works if my data is on while push notification is triggered via APNS, but only the latest one is received in case I am offline and come back after a while. This functionality is affirmed by APNS documentaion.

However, this is what worked in WhatsApp:

  1. Turned Data Connection OFF
  2. Sent some messages to WhatsApp
  3. Turned Data Connection ON
  4. Saw multiple push notifications received in Apple's Notification Tray

How's this scenario working? Can I use APNS for this? If yes, then how?

See this sample image of multiple Push Notifications in WeChat.

like image 348
Geek Avatar asked Oct 20 '22 17:10

Geek


1 Answers

Like you wrote in your question, this is mentioned in the Apple Docs:

If you are sending multiple notifications to the same device or computer within a short period of time, the push service will send only the last one.

Link

The only scenario that what you're describing will work is if your whatsApp was open in the background while getting those push notifications. That way whatsApp will handle them as local notifications and will present all of them in the notification center. If whatsApp was closed you'd get only the last notification like any other app.

You can easily test this:

  1. Terminate whatsApp and turn on Airplane mode.
  2. Send your device 5 messages from 1 to 5.
  3. Turn Airplane mode off and lock your device.
  4. You'll only see one msg (the last one you sent aka "5") in your notifications center.

This is how whatsApp is making it work:

While whatsApp is in the background, a single push notification is received (the last one the user sent, "5" in our example). That msg will not be shown to the user.

whatsApp receives it in the method application:didReceiveRemoteNotification:fetchCompletionHandler: and checks against their servers if there are any notifications prior to "5" that the user didn't receive. If that's the case, they will pull that data from their servers and will present it to the user using local notifications which is basically just a way to present data and not related to APNS at all.

like image 148
Segev Avatar answered Oct 29 '22 22:10

Segev