Exemplo n.º 1
0
        public async Task SendNotificationFromTask(byte[] data)
        {
            try {
                string       strData       = System.Text.Encoding.UTF8.GetString(data);
                Notification notification  = JsonConvert.DeserializeObject <Notification>(strData);
                var          subscriptions = await PushSubscriptionsRepository.GetAllAsync();

                await subscriptions.ForEachAsync(async (subscription) => {
                    await PushClient.SendNotificationsAsync(subscription, notification);
                });
            } catch (Exception ex) {
                _logger.LogError($"{ex.Message}; {ex.StackTrace}");
            }
        }