public async Task HandleAsync(PushExternalFcmNotificationCommand message, CancellationToken cancellationToken) { if (message.Data == null && message.Notification == null) { throw new ArgumentException( "Error sending FCM notification: either Notification or/and Data fields must not be null!"); } List <FcmExternalUserDeviceToken> tokens = await repository.Where <FcmExternalUserDeviceToken>( x => message.UserIds.Contains(x.ExternalUserId) && x.AppId == message.AppId) .ToListAsync(repository.GetQueryableResolver <FcmExternalUserDeviceToken>()); if (tokens.Count == 0) { return; } fcmBrokerDispatcher.QueueNotifications( tokens.Select( x => new WrappedFcmNotification(new GcmNotification() { RegistrationIds = new List <string>() { x.RegistrationId }, Data = message.Data, Notification = message.Notification }, x.AppId))); }
public Task PushNotification(PushExternalFcmNotificationCommand parameters) { return(CommandBus.SendAsync(parameters)); }