public void SendNotificationFromWeb(MobileAppNotification notification) { if (notification.SystemUserId == 0) { return; } var devices = _systemUserDeviceService.GetBySystemUserId(notification.SystemUserId); var systemUser = _systemUserRepository.GetFirstOrDefault(predicate: a => a.SystemUserId == notification.SystemUserId, include: a => a.Include(b => b.Business)); var badges = UnreadCount(notification.SystemUserId); var university = _universityRepository.GetFirstOrDefault(predicate: a => a.BusinessId == (systemUser.Business.UniversityId ?? systemUser.BusinessId)); var createdBy = _systemUserRepository.GetFirstOrDefault(predicate: a => a.SystemUserId == notification.CreatedBy); var message = _dashboardService.ResourceMessage(new Repository.Models.Notification() { SystemUserId = notification.SystemUserId, NotificationType = notification.Notification, Message = notification.Message, CreatedBy = notification.CreatedBy, RegardingId = notification.RegardingID }, createdBy, university, systemUser, false).GetAwaiter().GetResult(); if (!string.IsNullOrEmpty(message)) { foreach (var device in devices) { var response = _hub3CFirebaseApi.Send(new Hub3cFirebase() { Notification = new FIrebaseNotification() { Title = "Mentifi", Body = message, Icon = "default", Sound = "default", Badge = badges, mutable_content = true, Click_Action = GetNotifType(notification.Notification) }, To = device.DeviceToken }).GetAwaiter().GetResult(); } } }
public async Task <IActionResult> Test() { var result = await _hub3CFirebaseApi.Send(new Hub3cFirebase() { Notification = new FIrebaseNotification() { Title = "Mentifi", Body = "Garry Nilson has sent you a < a href =\"../../mentifi/network\">connection request</a>, communicate further in <a href=\"javascript:void(0)\" onclick=\"checkAvailableMessageBoardLinks('{0}', '{1}')\">message board</a>", Icon = "default", Sound = "default", Badge = 1, mutable_content = true, Click_Action = NotificationType.Pending, }, To = "ejEDLXuaMJw:APA91bF5HNWcJSZGny5JY53BRaHAEMJoMxLzz-pZnbs6iXjaXE6FCqApR3NUBCNA8kccUyZByizp9f14x1ZGrI_P89mms58FBCwJtVBFH9SLh4aGUrdxYbguFOPDllxyRg8PZXotcJqF" }); return(Ok(MessageHelper.Success(result))); }