2

我正在使用Azure通知集线器向GCM和APN发送推送通知时,我注意到生产中它只发送给前10个注册设备,而其他新注册设备无法接收消息它已经在GCM上注册。我需要的是发送到所有注册的设备,他们是圆形600设备。公共类通知 { public static Notifications Instance = new Notifications();MS Azure仅向10个设备发送通知

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); 

     } 

    } 
+0

你是什么意思? –

回答

2

我假设你使用的是内置在通知枢纽在Azure门户网站或Visual Studio叶片测试工具。

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

详情概述here

注意的是,使用这个属性被严重节流,所以你 只能在开发/测试环境,其中一套有限的 注册使用。我们只向10个设备发送调试通知。我们也有 处理调试发送的限制为每分钟10。

检查这一行:

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

为了提供超过10台设备,你需要让你不使用EnableTestSend肯定。

+1

我从.net后端发送,是否有我应该使用的任何配置 –

+0

您是下面的示例还是您自己写的? –

+1

我正在使用样本 –

相关问题