public async Task <bool> SendPushNotificationToAllActiveContactsOnStatusActive(int userId) { if (userId != 0) { var user = await GetUserById(userId); var oneSignalDeviceIds = new List <string>(); var userContacts = await GetAllActiveUserContactsForUser(userId); foreach (var userContact in userContacts) { oneSignalDeviceIds.Add(userContact.OneSignalUserId); } if (oneSignalDeviceIds != null && oneSignalDeviceIds.Count != 0) { var oneSignalHelper = new OneSignalPushNotificationHelper(); var responseOneSignal = oneSignalHelper.SendOneSignalPushNotification(oneSignalDeviceIds, user, "I am online"); if (responseOneSignal != 0) { return(true); } } return(false); } return(false); }
public async Task <IActionResult> CreateNotification(CreateNotificationModel request) { Guid appId = Guid.Parse(_configuration.GetSection(AppSettingKey.OneSignalAppId).Value); string restKey = _configuration.GetSection(AppSettingKey.OneSignalRestKey).Value; string result = await OneSignalPushNotificationHelper.OneSignalPushNotification(request, appId, restKey); return(RedirectToAction("Index", "Notification")); }
public async Task <IActionResult> CatchNotificationDisplayed([FromBody] NotificationDislayedRequest request) { return(Ok(await OneSignalPushNotificationHelper.WebhooksDisplayed(request))); }