public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler) { // Do your magic to handle the notification data Console.WriteLine(notification.Request.Content.UserInfo); Debug.WriteLine("WillPresentNotification"); var parameters = GetParameters(notification.Request.Content.UserInfo); _onNotificationReceived?.Invoke(CrossFirebaseEssentials.Notifications, new FirebasePushNotificationDataEventArgs(parameters)); CrossFirebaseEssentials.Notifications.NotificationHandler?.OnReceived(parameters); if (parameters.TryGetValue("priority", out var priority) && ($"{priority}".ToLower() == "high" || $"{priority}".ToLower() == "max")) { if (!CurrentNotificationPresentationOption.HasFlag(UNNotificationPresentationOptions.Alert)) { CurrentNotificationPresentationOption |= UNNotificationPresentationOptions.Alert; } } else if ($"{priority}".ToLower() == "default" || $"{priority}".ToLower() == "low" || $"{priority}".ToLower() == "min") { if (CurrentNotificationPresentationOption.HasFlag(UNNotificationPresentationOptions.Alert)) { CurrentNotificationPresentationOption &= ~UNNotificationPresentationOptions.Alert; } } completionHandler(CurrentNotificationPresentationOption); }
public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler) { // Do your magic to handle the notification data System.Console.WriteLine(notification.Request.Content.UserInfo); System.Diagnostics.Debug.WriteLine("WillPresentNotification"); var parameters = GetParameters(notification.Request.Content.UserInfo); _onNotificationReceived?.Invoke(CrossAzurePushNotification.Current, new AzurePushNotificationDataEventArgs(parameters)); CrossAzurePushNotification.Current.NotificationHandler?.OnReceived(parameters); string[] priorityKeys = new string[] { "priority", "aps.priority" }; foreach (var pKey in priorityKeys) { if (parameters.TryGetValue(pKey, out object priority)) { var priorityValue = $"{priority}".ToLower(); switch (priorityValue) { case "max": case "high": if (!CurrentNotificationPresentationOption.HasFlag(UNNotificationPresentationOptions.Alert)) { CurrentNotificationPresentationOption |= UNNotificationPresentationOptions.Alert; } if (!CurrentNotificationPresentationOption.HasFlag(UNNotificationPresentationOptions.Sound)) { CurrentNotificationPresentationOption |= UNNotificationPresentationOptions.Sound; } break; case "low": case "min": case "default": default: if (CurrentNotificationPresentationOption.HasFlag(UNNotificationPresentationOptions.Alert)) { CurrentNotificationPresentationOption &= ~UNNotificationPresentationOptions.Alert; } break; } break; } } completionHandler(CurrentNotificationPresentationOption); }
public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler) { // Do your magic to handle the notification data System.Console.WriteLine(notification.Request.Content.UserInfo); System.Diagnostics.Debug.WriteLine("WillPresentNotification"); var parameters = GetParameters(notification.Request.Content.UserInfo); _onNotificationReceived?.Invoke(CrossFirebasePushNotification.Current, new FirebasePushNotificationDataEventArgs(parameters)); CrossFirebasePushNotification.Current.NotificationHandler?.OnReceived(parameters); if ((parameters.TryGetValue("priority", out object priority) && ($"{priority}".ToLower() == "high" || $"{priority}".ToLower() == "max"))) { if (!CurrentNotificationPresentationOption.HasFlag(UNNotificationPresentationOptions.Alert)) { CurrentNotificationPresentationOption |= UNNotificationPresentationOptions.Alert; } }