I am Using Azure Notification hub when sending push notifications to GCM and APN what I notice on the production it is only send to the first 10 registered devices and other new register device cant receive messages despite it is already registered on GCM . what i need is to send to all registered devices and they are round 600 devices.
public class Notifications { public static Notifications Instance = new Notifications();
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);
}
}