简体   繁体   English

使用 phonegap-plugin-push 处理同时到达的许多推送消息并防止过载

[英]Handling many push messages arriving at once with phonegap-plugin-push and preventing overload

I am using phonegap-plugin-push on Cordova and some app users get push notifications every ~30 seconds.我在 Cordova 上使用phonegap-plugin-push并且一些应用程序用户每 30 秒收到一次推送通知。 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.问题是当他们的设备处于OFFLINE状态并且他们在线上说 1 小时后,他们突然被 120 条推送消息淹没,导致应用程序崩溃并冻结。

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?例如,如果 X 条相同的消息到达,只显示 1 条?

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.据我所知,具有相同折叠 ID 的消息应该在传递到手机之前已经覆盖自己。 If 100 notifications would be sent with the same collapse id, while the device is offline, each new notification would "overwrite" the previous one.如果在设备离线时发送 100 个具有相同折叠 ID 的通知,则每个新通知都会“覆盖”前一个通知。 As a result only the newest notification associated with the collapse id would be delivered.因此,只会传递与折叠 ID 关联的最新通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM