コード例 #1
0
        public async Task ProcessAsync(UserNotificationInfo userNotificationsInfo)
        {
            if (userNotificationsInfo == null)
            {
                return;
            }
            var notification = await _notificationStore.GetNotificationOrNullAsync(userNotificationsInfo.NotificationId);

            if (notification == null)
            {
                return;
            }

            var firebaseNotificationData = FirebaseNotificationData.FromJsonString(notification.Data);

            firebaseNotificationData.Notification.Badge =
                (await _notificationStore.GetUserNotificationCountAsync(userNotificationsInfo.UserId,
                                                                        UserNotificationState.Unread)).ToString();

            var firebaseRegistrations = await _firebaseService.GetAllRegistrationAsync(userNotificationsInfo.UserId);

            if (firebaseRegistrations.IsNullOrEmpty())
            {
                return;
            }

            firebaseNotificationData.RegistrationIds.AddRange(firebaseRegistrations.Select(x => x.RegistrationId));

            var json    = firebaseNotificationData.ToString();
            var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

            var response = await _httpClient.PostAsync(_configuration.Url, content);

            if (response.IsSuccessStatusCode)
            {
                await ProcessResponseOk(response, firebaseNotificationData);
            }
            else
            {
                await ProcessReponseError(response, firebaseNotificationData);
            }
        }
コード例 #2
0
 public Task <int> GetUserNotificationCountAsync(UserIdentifier user, UserNotificationState?state = null)
 {
     return(_store.GetUserNotificationCountAsync(user, state));
 }
コード例 #3
0
 public Task <int> GetUserNotificationCountAsync(Guid userId, UserNotificationState?state = null, DateTime?startDate = null, DateTime?endDate = null)
 {
     return(_store.GetUserNotificationCountAsync(userId, state, startDate, endDate));
 }
コード例 #4
0
 public Task <int> GetUserNotificationCountAsync(long userId, UserNotificationState?state = null)
 {
     return(_store.GetUserNotificationCountAsync(userId, state));
 }