【发布时间】:2016-11-22 17:11:39
【问题描述】:
我用 2 个模板注册了一个设备
{
"handle":"handleIdGoeshere",
"installationId":"installationIdgoeshere",
"platform":"gcm",
"templates":{
"ctemplate":
{
"Body" : "{\"data\": {\"message\": \"$(message)\",\"conversation\": \"$(conversation)\"}}",
"Tags":["chatTemplate"]
},
"rtemplate":
{
"Body" : "{\"data\": {\"message\": \"$(message)\"}}",
"Tags":["regularTemplate"]
}
},"tags":["device:tablet","language:en"]}
正如您在上面看到的,一个模板有变量message,另一个有message和conversation
每个模板都有一个指定的名称,但是在发送推送时
var properties = new Dictionary<string, string>();
properties.Add("message", message);
properties.Add("conversation", "1234567890");
outcome = await hub.SendTemplateNotificationAsync(properties);
我无法指定我想使用哪个模板,我认为 azure 会根据用于推送的变量自动检测模板,但我猜不是这样,如果我发送推送时只设置了消息变量我得到以下内容
{
conversation=,
message=another test
}
这会导致解析错误,因为对话变量为空白。那么如果 azure 会发送所有模板,那么模板的目的是什么?以及如何解决这个问题。
谢谢
【问题讨论】:
标签: c# azure push-notification azure-notificationhub