Phonegap Pushnotification + node-gcm:组通知 [英] Phonegap Pushnotification + node-gcm: group notifications

查看:67
本文介绍了Phonegap Pushnotification + node-gcm:组通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Node应用程序中有这样的东西:

I have something like this in a Node app:

var sender = new gcm.Sender("XPTO");
var registrationIds = ["whatever"];
...
var message = new gcm.Message({
    data: {
        avatar: body_data.avatar,
        message: body_data.message
    }
});

sender.send(message, registrationIds, 4, function (err, result) { console.log("success"); });

它工作正常,通知到达,并进入托盘如果应用程序,如果没有打开。
但是如果我发送一个新的通知到同一个registrationId,旧的通知是更新(或删除),只有新的显示。

It works fine, the notification arrives and goes to the tray if the app if not opened. But if I send a new notification to the same registrationId, the old notification is "updated" (or removed) and only the new one is shows.

如果我添加一个随机整数作为参数到notId

If I add a random integer as parameter to notId

message.addData("notId", parseInt(Math.random() * 25));

通知保留在托盘中,但随后托盘开始显示多个通知。
有一种方法来分组通知?

the notifications are kept in the tray, but then the tray start to show multiple notifications. Is there a way to group the notifications?

推荐答案

Android设备组同类通知。如果您为每种类型的通知设置了不同的collapseKey,则它们不会与其他通知分组。您最多可以在托盘中向用户显示最多4个不同的collapseKey。

Android devices group same kind of notifications. If you set set different collapseKey for each kind of notification, they won't get grouped with others. You can have at most 4 different collapseKey at the same time visible to user in tray.

这篇关于Phonegap Pushnotification + node-gcm:组通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆