I am using phonegap-plugin-push on Cordova and some app users get push notifications every ~30 seconds. The problem is when their device is OFFLINE and they go online say 1 hour later, they are suddenly flooded with 120 push messages at once, crashing and freezing the app.
I tried changing the push code and adding:
'notId'=>1,
but that didn't seem to help.
The entire push data I am sending is:
$data = array(
'title'=>$val['push_title'],
'body'=>$val['push_message'],
'vibrate' => 1,
'soundname'=> 'notificationsound',
'android_channel_id'=>$channel,
'content-available'=>1,
'count'=>1,
'badge'=>1,
'notId'=>1,
'push_type'=>'notification',
'icon'=>'icon_default',
'iconColor'=>'#FFFFFF',
'image'=>'icon_large_default'
);
Is there any easy way to fix this? Such as if X messages of the same arrive, only 1 gets shown?
How about using collapsable notifications? As far as I know, messages with the same collapse id should overwrite themselves already before delivery to the phone. If 100 notifications would be sent with the same collapse id, while the device is offline, each new notification would "overwrite" the previous one. As a result only the newest notification associated with the collapse id would be delivered.