private async Task SendNotification(string token, Guid userId)
 {
     await _mmc.SendNotification(
         token,
         "Versus",
         await ChoosePhrase(userId)
         );
 }
Beispiel #2
0
        public async Task <ActionResult <object> > SendMessageByUserId(Guid userId, Notification notification)
        {
            if (!await _userManager.Users.AnyAsync(u => u.Id == userId))
            {
                return(NotFound("Пользователь с таким ID отсутствует"));
            }

            var user = await _userManager.FindByIdAsync(userId.ToString());

            if (user.Token == null)
            {
                return(BadRequest("У пользователя отсутствует FCM-токен для уведомлений"));
            }

            var result = await _mmc.SendNotification(user.Token, notification.Title, notification.Body);

            return(Ok(result));
        }
 protected void RiskDetected(string token, string firebase, Location location, int risk)
 {
     _databaseEngine.Increment_Incidents(token);
     _mobileMessagingClient.SendNotification(location, token, firebase, risk);
 }