Apple Multiple Push Notifications not visible in Notifications Tray
Asked Answered
L

3

5

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.

Lectionary answered 13/2, 2015 at 14:54 Comment(0)
S
5

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.

Stenograph answered 16/2, 2015 at 9:15 Comment(3)
:I tried this on whtsapp by turning data connection off and coming back online after a while(During this period it wont matter if whtsapp was in background)but it still recieved all push notifications.It might not be using apns but then how they are achieving it that is what i need to know.Lectionary
I've edited the answer to make things a bit more clearStenograph
application:didReceiveRemoteNotification:fetchCompletionHandler: this method is not working in terminate state so how to could we possibly do that, when we got last message then request and get last messages push again.Reseat
T
-1

It is explained in Troubleshooting Push Notifications. Check for "Some Notifications Received, but Not All" section.

Theocrasy answered 16/2, 2015 at 6:35 Comment(0)
M
-1

As described you cannot have any control over those push notifications.

However you may know that from iOS7 a new background execution mode (remote-notification) allows the App to be awaken by the system when a push is received, allowing you to process some data, then go back to sleep...

This is probably the trick: using that way to receive the push notifications (silently) and then trigger your own local notification instead as @Segev said. See the UIBackgroundModes here.

Mallis answered 22/2, 2015 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.