so basically i'm using this
public static async void postToPushNotifcationAsync(String deviceId, String message, String title)
{
var serverKey = "";
var senderId = "";
var fcm = new FCMJsonModel();
var fcmNotification = new FCMNotificationModel();
fcmNotification.body = message;
fcmNotification.title = title;
fcmNotification.sound = "sound.caf";
fcm.to = deviceId;
fcm.notification = fcmNotification;
var json = fcm.ToJSON();
var content = new StringContent(json);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "key=" + serverKey);
client.DefaultRequestHeaders.TryAddWithoutValidation("Sender", "id=" + senderId);
//client.Timeout = TimeSpan.FromMinutes(2);
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(1));
var response = await client.PostAsync("https://fcm.googleapis.com/fcm/send", content, cts.Token);
var responseString = await response.Content.ReadAsStringAsync();
}
}
This method is basically posting a push notification server and send a message.I used this method multiple times for different api's but the post gets cluttered and it sends the first one and doesn't send the other ones. I just want to use this method multiple times and i'm even willing to not use async on this but it won't allow me to. I'm not an expert on ASP.NET programming but I would like to know how this can be fixed. Thank you for your help.