【问题标题】:Send payload to specific client with Notification Hub使用通知中心将有效负载发送到特定客户端
【发布时间】:2015-08-07 09:16:02
【问题描述】:

我正在使用 Azure 通知中心服务。现在,该实现可以发送给所有在通知中心注册的客户端。但是,我不能发送给特定的人。我知道TAG Feature 但是,文件说这似乎是针对特定兴趣群体的解决方案。即使它适用于特定的人,我也想知道是否有其他方式可以向单个客户端发送消息。

以下代码是有效载荷和向客户端发送消息的函数。

var payload = 
{
    "data":
    {
        "message":"Notification Hub test notification"
    }
};
notificationHubService.gcm.send(null, payload, function(error){
  if(!error){
    //notification sent
  }
});   

我做了什么

notificationHubService.gcm.send(GCM 注册 ID,有效载荷, 函数(错误){});

var payload = 
{
    "register_ids": "device register id"
    "data":
    {
        "message":"Notification Hub test notification"
    }
};

【问题讨论】:

    标签: android node.js azure google-cloud-messaging


    【解决方案1】:

    根据 Routing and TAG Expression 文档:

    标签表达式可以包含所有布尔运算符,例如 AND (&&)、OR (||) 和 NOT (!)。它们也可以包含括号。

    这意味着您可以使用 AND (&) 操作选择要向其发送通知的客户端,并使用 NOT 操作保留其余的客户端。示例中给出了类似的内容。

    notificationHubService.gcm.send('(tagA && !tagB)', { text1: '你好,世界!' }, 回调);

    【讨论】:

      猜你喜欢
      • 2019-04-26
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      • 2015-07-31
      • 1970-01-01
      • 2016-02-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多