1

我正在創建消息傳遞應用程序,並且與任何移動消息傳遞服務一樣,當應用程序未連接到後端時,需要推送通知。城市飛艇 - 在消息傳遞平臺上彙總類似的推送通知

讓我用一個例子來排除我遇到的場景。

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。

回答

0

看來,你的應用程序將需要創建自己的自定義推送通知對象,並以某種方式得到了NotificationManager

PushManager.shared().setNotificationBuilder(new YourCustomNotificationObject());

我不知道城市飛艇如何公開NotificationManager訪問,但你需要在您的NotificationBuilder中使用setGroup("arbitrarygroupname")訪問器

除非您的目標是最低API級別20,否則此訪問器不可用,因此您必須使用v4 + NotificationCompat.Builder對象,並確保您的支持庫是vers離子20或更高。

編輯,作爲UrbanAirship 4.0.3爲Android的,這是不可能,服務器端可以保持一系列的推送通知的軌道,並與各推使用collapse_key參數,collapse_key將更換相同的推送通知類型,所以你的服務器將不得不發送不同名稱的推送通知,名稱爲Message from User A (2),而不是讓Android系統處理該客戶端

相關問題