繁体   English   中英

城市飞艇-在消息传递平台上汇总类似的推送通知

[英]Urban Airship - Aggregating Similar Push Notifications on Messaging Platform

我正在创建一个消息传递应用程序,并且像任何移动消息传递服务一样,当应用程序未连接到后端时,也需要“推送通知”。

让我用一个例子概述我所遇到的情况。

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)

我不确定在通知到达电话后如何收集这些通知,假设它们已附加了元数据,这些元数据清楚地表明了消息的“发送者”是谁。

目前,这是我要发送给Urban Airship的有效载荷

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。

您的应用似乎需要创建自己的自定义推送通知对象,并以某种方式获得对NotificationManager的访问权限

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

我不确定Urban Airship如何公开NotificationManager,但是您需要在NotificationBuilder中使用setGroup("arbitrarygroupname")访问器

除非您的目标是最低API级别20,否则访问器将不可用,因此您必须使用v4 + NotificationCompat.Builder对象,并确保您的支持库为版本20或更高版本。

编辑,作为UrbanAirship 4.0.3的Android,这是不可能的 ,服务器端就可以跟踪一系列推送通知和使用collapse_key每推参数, collapse_key将更换同一类型的推送通知,让您的服务器将必须发送具有不同名称的推送通知,名称为Message from User A (2)而不是让Android系统处理该客户端

暂无
暂无

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

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