gpt4 book ai didi

azure - 使用 .NET 中的 Azure 通知中心向所有注册设备发送推送通知

转载 作者:行者123 更新时间:2023-12-02 07:12:02 24 4
gpt4 key购买 nike

我正在使用 Azure 通知中心,我想向 .NET 后端中的所有注册设备发送推送通知消息。但我不确定这种方式是否会发送到所有设备,因为我没有办法检查收到推送消息的设备数量。那么,如何,我可以向所有设备发送推送消息或者可以确保这种方式是正确的?

public static async Task<bool> SendBroadcast(string msg)
{
try
{
var notificationHubClient = NotificationHubClient.CreateClientFromConnectionString(ConfigurationManager.AppSettings["ServiceBusPushNotificationConnectionString"], ConfigurationManager.AppSettings["ServiceBusPushNotificationName"]);
Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("message", msg);
param.Add("alert", msg);
var template = new TemplateNotification(param);
var result = await notificationHubClient.SendNotificationAsync(template);
Console.WriteLine(JsonConvert.SerializeObject(result));
return true;
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
return false;
}
}

最佳答案

如果您不指定任何标记表达式,则表示它是广播。所有设备都会收到通知。您可以使用每消息遥测跟踪收到的设备数量。请参阅下面的链接以了解相同内容。

https://msdn.microsoft.com/en-us/library/azure/mt608135.aspx https://azure.microsoft.com/en-us/blog/push-notification-hub-telemetry-expiry-update/

关于azure - 使用 .NET 中的 Azure 通知中心向所有注册设备发送推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39590084/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com