Example #1
0
        public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
        {
            var    parameters = GetParameters(response.Notification.Request.Content.UserInfo);
            string?result     = null;
            NotificationCategoryType catType = NotificationCategoryType.Default;

            if (response.IsCustomAction)
            {
                catType = NotificationCategoryType.Custom;
            }
            else if (response.IsDismissAction)
            {
                catType = NotificationCategoryType.Dismiss;
            }


            if (response is UNTextInputNotificationResponse textResponse)
            {
                result = textResponse.UserText;
            }

            var notificationResponse = new NotificationResponse(parameters, $"{response.ActionIdentifier}".Equals("com.apple.UNNotificationDefaultActionIdentifier", StringComparison.CurrentCultureIgnoreCase) ? string.Empty : $"{response.ActionIdentifier}", catType, result);

            _onNotificationAction?.Invoke(this, new PushNotificationResponseEventArgs(notificationResponse.Data, notificationResponse.Identifier, notificationResponse.Type, result));

            CrossPushNotification.Current.NotificationHandler?.OnAction(notificationResponse);

            // Inform caller it has been handled
            completionHandler();
        }
 public PushNotificationResponseEventArgs(IDictionary <string, object> data, string identifier = "", NotificationCategoryType type = NotificationCategoryType.Default, string?result = null)
 {
     Identifier = identifier;
     Data       = data;
     Type       = type;
     Result     = result;
 }
 public FirebasePushNotificationResponseEventArgs(IDictionary <string, string> data, string identifier = "", NotificationCategoryType type = NotificationCategoryType.Default)
 {
     Identifier = identifier;
     Data       = data;
     Type       = type;
 }
 public NotificationResponse(IDictionary <string, string> data, string identifier = "", NotificationCategoryType type = NotificationCategoryType.Default)
 {
     Identifier = identifier;
     Data       = data;
     Type       = type;
 }
 /// <summary>
 /// Category for the notification.
 /// In Android Must be one of the predefined notification categories
 /// </summary>
 public NotificationRequestBuilder WithCategoryType(NotificationCategoryType type)
 {
     _request.CategoryType = type;
     return(this);
 }
 public NotificationUserCategory(string category, List <NotificationUserAction> actions, NotificationCategoryType type = NotificationCategoryType.Default)
 {
     Category = category;
     Actions  = actions;
     Type     = type;
 }
 /// <summary>
 /// CategoryType is the unique identifier for the Category
 /// </summary>
 /// <param name="categoryType">A unique identifier for the Category</param>
 public NotificationCategory(NotificationCategoryType categoryType)
 {
     CategoryType = categoryType;
 }
Example #8
0
        internal static void RegisterAction(IDictionary <string, object> data, string identifier = "", NotificationCategoryType type = NotificationCategoryType.Default)
        {
            var response = new NotificationResponse(data, data.ContainsKey(DefaultPushNotificationHandler.ActionIdentifierKey) ? $"{data[DefaultPushNotificationHandler.ActionIdentifierKey]}" : string.Empty);

            _onNotificationAction?.Invoke(CrossFirebasePushNotification.Current, new FirebasePushNotificationResponseEventArgs(response.Data, response.Identifier, response.Type));
        }
Example #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 protected static string ToNativeCategory(NotificationCategoryType type)
 {
     return(type.ToString());
 }