![](/img/trans.png)
[英]Is there a way to send Push Notification through a NotificationHub with the Webjob SDK?
[英]Is there a way to send multiple notification to a NotificationHub with Webjob SDK?
我已经设置了一个WebJob,它每分钟都会向NotificationHub发送一个通知用于测试目的,我需要它发送多个通知而不是一个通知。
我试图只发送一个Notification对象数组而不只是一个对象,但这似乎不起作用。
Function.cs
public class Functions
{
// This function will get triggered/executed when a new message is written
// on an Azure Queue called queue.
public static void SendNotif1([TimerTrigger("0 * * * * *")] TimerInfo time, TextWriter log, [NotificationHub] out Notification notification)
{
string title = "Hello";
string message = "Message";
notification = new GcmNotification(ToGcmPayload(title, message));
}
private static string ToGcmPayload(string title, string message)
{
var gcmPayloadModel = new
{
data = new
{
FormType = "Next scheduler",
MemberForm = "Hello"
}
};
return JsonConvert.SerializeObject(gcmPayloadModel);
}
}
我试图以错误的方式做这件事吗?
不确定您是否打算发送该代码段,但我找到了原始来源。
// This binding sends multiple push notification to any clients registered with the template
// when method successfully exits.
public static void SendNotificationsOnTimerTrigger(
[TimerTrigger("*/30 * * * * *")] TimerInfo timerInfo,
[NotificationHub] out Notification[] notifications)
{
notifications = new TemplateNotification[]
{
GetTemplateNotification("Message1"),
GetTemplateNotification("Message2")
};
}
private static IDictionary<string, string> GetTemplateProperties(string message)
{
Dictionary<string, string> templateProperties = new Dictionary<string, string>();
templateProperties["message"] = message;
return templateProperties;
}
我没有代表评论,但我相信根据这个问题,上述解决方案只适用于版本1类型的功能,而不是版本2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.