gpt4 book ai didi

azure - MS Azure 仅向 10 台设备发送通知

转载 作者:行者123 更新时间:2023-12-02 23:50:04 25 4
gpt4 key购买 nike

我在向 GCM 和 APN 发送推送通知时使用 Azure 通知中心,我在生产中注意到它仅发送到前 10 个注册设备,而其他新注册设备无法接收消息,尽管它已在 GCM 上注册。我需要的是发送到所有注册的设备,它们是大约 600 台设备。

公开课通知 { 公共(public)静态通知实例=新通知();

    public NotificationHubClient Hub { get; set; }

private Notifications()
{
string NotificationHubConnectionString = WebConfigurationManager.AppSettings["NotificationHubConnectionString"];

string NotificationHubPath = WebConfigurationManager.AppSettings["NotificationHubPath"];

Hub = NotificationHubClient.CreateClientFromConnectionString(NotificationHubConnectionString, NotificationHubPath, false);
}



public static async void SendNotificationAsync(string Message, string Type, string ID, string Date, string Summery, string Location, string Risk)
{

string to_tag = Type.Replace(" ", string.Empty);
try
{
var notif = "{ \"data\" : {\"message\":\"" + Message + "\",\"type\":\"" + Type + "\",\"ID\":\"" + ID + "\",\"Date\":\"" + Date + "\",\"Summery\":\"" + Summery + "\",\"Risk\":\"" + Risk + "\",\"Location\":\"" + Location + "\"" + ", \"sound\" : \"default\"}}";
var outcome = await Notifications.Instance.Hub.SendGcmNativeNotificationAsync(notif);

string msg = string.Format("This Notification: " + Message + " has been delivered to this number [" + outcome.Success.ToString() + "] of android Mobiles");
Logger.LogMessage(msg, EventLogEntryType.Information);
}
catch (Exception ex)
{
string msg = string.Format("Coudn't send notification to android mobiles");
Logger.LogMessage(msg, EventLogEntryType.Error);
Logger.LogException(ex, EventLogEntryType.Error);

}
try
{
var alert = "{\"aps\":{\"alert\":\"" + Message + "\",\"type\":\"" + Type + "\",\"ID\":\"" + ID + "\",\"Date\":\"" + Date + "\",\"Summery\":\"" + Summery + "\",\"Risk\":\"" + Risk + "\",\"location\":\"" + Location + "\" " + ", \"sound\" : \"default\"}}";

var outcome = await Notifications.Instance.Hub.SendAppleNativeNotificationAsync(alert, to_tag);
string msg = string.Format("This Notification: " + Message + " has been delivered to this number ["+ outcome.Success.ToString() +"] of IOS Mobiles");
Logger.LogMessage(msg, EventLogEntryType.Information);
}
catch (Exception ex)
{
string msg = string.Format("Coudn't send notification to IOS mobiles");
Logger.LogMessage(msg, EventLogEntryType.Error);
Logger.LogException(ex, EventLogEntryType.Error);

}

}

最佳答案

我假设您正在使用 Azure 门户或 Visual Studio 的“通知中心”边栏选项卡中的内置测试工具。

这是设计使然 - 来自那里的测试通知将发送到 10 个随机设备。您需要有一个真正的后端来发送通知,以便传播到所有已注册的设备。

详细信息概述here .

Note that the use of this property is heavily throttled and so you must only use this in dev/test environment with limited set of registrations. We only send debug notifications to 10 devices. We also have a limit of processing debug sends to be 10 per minute.

检查这一行:

bool enableTestSend = true;
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(connString, hubName, enableTestSend);

为了向 10 台以上的设备提供服务,您需要确保您没有使用 EnableTestSend .

关于azure - MS Azure 仅向 10 台设备发送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35515009/

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