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

标签 azure push-notification google-cloud-messaging azure-notificationhub

我在向 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/

相关文章:

android - 无法启动 GCM Intent 服务

azure - 以特定方式自定义 Azure 搜索评分

azure - 使用工作(Azure AD)身份验证的 ASP.NET Core Web 应用程序可以在本地进行调试,但在发布到 Azure 后无法进行调试

ios - 如何处理在密码锁定的 iOS 设备上点击推送通知横幅?

android - PushPlugin 注册到 errorhandler 显示 'Class not found' 与 cordova 4.0.0 for android 平台

android - Google Cloud Messaging (GCM) 为每个设备和用户发放多少个注册 ID?

azure - Kubernetes - 服务类型 LoadBalancer 每次部署在 AKS 中时使用特定的 IP 地址

powershell - azure VM中未加载指定的模块 'SQLPS'

mysql - 如何使用 Objective C 将推送通知和其他用户设置的设备 token 发送到服务器上的 sql 表

android - GCM - 注册完成后,registerID 立即为空