我正在創建消息傳遞應用程序,並且與任何移動消息傳遞服務一樣,當應用程序未連接到後端時,需要推送通知。城市飛艇 - 在消息傳遞平臺上彙總類似的推送通知
讓我用一個例子來排除我遇到的場景。
There is a conversation between User A & User B
// User B's application is idle (not receiving messages from our backend)
// User A sends User B a message
A --> B
因爲用戶B沒有連接,所以他/她發送推送通知召喚他/她打開應用並同步消息。 用戶B的手機現在有他/她的鎖定屏幕上的一個通知,像這樣
Message from User A
然後...
// User A sends User B another message
A --> B
用戶B的手機現在已經從他/她的鎖定屏幕上的兩個獨立的通知用戶A. 這些消息這樣寫的:
Message from User A
Message from User A
,但我想鎖屏閱讀這樣的事情
Message from User A (2)
我不確定如何在通知到達手機時收集通知,假設他們有元數據附加到他們明確誰是郵件的「發件人」。
目前,這是我我如何可以利用發送者的元數據,聚合來自同一人連續推送通知到上一個行項目發送多達城市飛艇
function sendPushNotification (event, user) {
if (event.type == 21 || event.type == 22 || event.type == 24) {
var sender = event.sender.username;
var alert = "from @" + sender;
var reciever = user.username;
var payload = {
"audience": {
"alias" : reciever
},
"device_types": [ "ios", "android" ],
"notification": {
"ios": {
"alert": alert,
"badge": "+1",
"sound": "default",
"extra": { "username": sender }
},
"android": {
"alert": alert,
"collapse_key": "inboxappco",
"extra": { "username": sender }
}
}
};
console.log("Hello 2");
pushNotification(payload);
} else {
// modularize for general purpose notifications
}
}; // end sendPushNotification function
任何意見的有效載荷鎖屏?
在此先感謝SOF。