Esempio n. 1
0
        private void SendNotifications(int temperatureC, CancellationToken stoppingToken)
        {
            PushMessage notification = new AngularPushNotification
            {
                Title = "New Weather Forecast",
                Body  = $"Temp. (C): {temperatureC} | Temp. (F): {32 + (int)(temperatureC / 0.5556)}",
                Icon  = "assets/icons/icon-96x96.png"
            }.ToPushMessage();

            foreach (PushSubscription subscription in _pushSubscriptionsService.GetAll())
            {
                // Fire-and-forget
                _pushClient.RequestPushMessageDeliveryAsync(subscription, notification, stoppingToken);
            }
        }
Esempio n. 2
0
        public void SendNotifications(string title, string body, CancellationToken stoppingToken)
        {
            PushMessage notification = new AngularPushNotification
            {
                Title   = title,
                Body    = body,
                Icon    = "assets/icons/icon-96x96.png",
                Actions = new List <NotificationAction> {
                    new NotificationAction("openwebsite", "Open webapp")
                },
                Data = new Dictionary <string, object> {
                    { "url", _configuration["FrontUrl"] }
                },
            }.ToPushMessage();

            foreach (PushSubscription subscription in _pushSubscriptionsService.GetAll())
            {
                // fire-and-forget
                _pushClient.RequestPushMessageDeliveryAsync(subscription, notification, stoppingToken);
            }
        }
 public IEnumerable <PushSubscription> GetAll()
 {
     return(_pushSubscriptionsService.GetAll());
 }