2
votes

I'm developing an Ionic 2 app wich receives push notifications. It must receive silent background notifications, meaning the notifications don't get visible in system notification area. Instead, when the app is open, the notifications are sent to the app en it process the data received. It works except it receives only the last notification sent while the app was closed.

Maybe it's a GCM message config missing.

Expected Behaviour

Receive multiple background silent push notifications.

Actual Behaviour

Receiving only the last background push silent notification.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Send two or more silent background messages while the app is closed. Open the app. Only the last notification is received by the on receive listener.

Platform and Version

Android 5.1.1/6.0

(Android) What device vendor

Google

Cordova CLI version and cordova platform version

cordova --version 6.2.0 cordova

platform version android 5.1.1

Plugin version

cordova plugin version | grep phonegap-plugin-push 1.7.4

Sample Push Data Payload
{
                "delay_while_idle": true,
                "priority": "high",

                "data": {
                    "content-available": "1",                   
                    "notId": Date.now(),
                    "silenttitle": 'some title',
                    "silentmessage": 'some message'
                }
}

How could I receive all silent notifications sent to my app?

2
How are you checking to see if the messages are being received? Are you expecting that there be a log message? Also what happens if you send 3 messages is only the last one being received?Arthur Thompson
Yes. I implemented a on notification listener. When I open the app it receives and logs only the last silent message sent while the app was closed. If the app is open I receive all silent messages. It also saves the messages on database and shows it to the user.Natanael
I'm not sure what the resulting payload to GCM looks like from ionic, however if the priority is high a data message should always be delivered to the device. I think you need an ionic expert to sort this one out.Arthur Thompson

2 Answers

1
votes

Based from this SO question, silent notifications may not be delivered to device on some cases. For example, if there was an airplane mode on, after switching it off, you will not receive all missing notifications, you will instead receive only last one. Push notifications with both body and content-available will be delivered in most cases.

I have also seen in this blog that some notifications were received, but not all. It is common that if you’re sending multiple push notifications simultaneously, only a few are received. That is intended behaviour. APNS maintains a QoS (Quality of Service) queue for each device with a push app. The size of this queue is 1, so if you send multiple notifications, the last notification is overridden.

Hope this helps!

0
votes

https://github.com/firebase/quickstart-android/tree/master/messaging try this. I used it and I am able to receive push notifications.