Exemple #1
0
        public async Task SendNotificationAsync(List <BellumGensPushSubscription> subs, TeamApplication notification, NotificationState state)
        {
            var subject = @"https://bellumgens.com";

            foreach (BellumGensPushSubscription sub in subs)
            {
                var subscription = new PushSubscription(sub.Endpoint, sub.P256dh, sub.Auth);
                var vapidDetails = new VapidDetails(subject, _publicVapidKey, _privateVapidKey);

                var webPushClient = new WebPushClient();
                var payload       = new BellumGensNotificationWrapper(notification, state);
                try
                {
                    await webPushClient.SendNotificationAsync(subscription, payload.ToString(), vapidDetails);
                }
                catch
                {
                }
            }
        }
        public static void SendNotification(List <BellumGensPushSubscription> subs, TeamApplication notification, NotificationState state)
        {
            var subject = @"https://bellumgens.com";

            foreach (BellumGensPushSubscription sub in subs)
            {
                var subscription = new PushSubscription(sub.endpoint, sub.p256dh, sub.auth);
                var vapidDetails = new VapidDetails(subject, NotificationsService._publicVapidKey, NotificationsService._privateVapidKey);

                var webPushClient = new WebPushClient();
                var payload       = new BellumGensNotificationWrapper(notification, state);
                try
                {
                    webPushClient.SendNotification(subscription, payload.ToString(), vapidDetails);
                }
                catch (WebPushException exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }