using System; namespace Unity.Notifications.iOS { /// /// Options for notification actions. /// These represent values from UNNotificationActionOptions. /// /// [Flags] public enum iOSNotificationActionOptions { None = 0, Required = (1 << 0), Destructive = (1 << 1), Foreground = (1 << 2), } /// /// Represents action for an actionable notification. /// Actions are supposed to be added to notification categories, which are then registered prior to sending notifications. /// User can choose to tap a notification or one of associated actions. Application gets feedback of the choice. /// /// /// public class iOSNotificationAction { /// /// An identifier for this action. /// Each action within an application unique must have unique ID. /// This ID will be returned by iOSNotificationCenter.GetLastRespondedNotificationAction if user chooses this action. /// public string Id { get; set; } /// /// Title for the action. /// This will be the title of the button that appears below the notification. /// public string Title { get; set; } /// /// Options for the action. Can be a combination of given flags. /// Refer to Apple documentation for UNNotificationActionOptions for exact meanings. /// /// public iOSNotificationActionOptions Options { get; set; } /// /// Creates new action. /// /// Unique identifier for this action /// Title for the action (and button label) public iOSNotificationAction(string id, string title) : this(id, title, 0) { } /// /// Creates new action. /// /// Unique identifier for this action /// Title for the action (and button label) /// Options for the action public iOSNotificationAction(string id, string title, iOSNotificationActionOptions options) { Id = id; Title = title; Options = options; } internal virtual IntPtr CreateUNNotificationAction() { #if UNITY_IOS && !UNITY_EDITOR return iOSNotificationsWrapper._CreateUNNotificationAction(Id, Title, (int)Options); #else return IntPtr.Zero; #endif } } /// /// Represents a special notification action with text input support. /// Each action within an application unique must have unique ID. /// When user chooses this action, a prompt for text input appears. /// If this action is responded to by the user, iOSNotificationCenter.GetLastRespondedNotificationAction will return it's ID, /// while iOSNotificationCenter.GetLastRespondedNotificationUserText will return the text entered. /// public class iOSTextInputNotificationAction : iOSNotificationAction { /// /// Text label for the button for submitting the text input. /// public string TextInputButtonTitle { get; set; } /// /// The placeholder text for input. /// public string TextInputPlaceholder { get; set; } /// /// Creates new text input action. /// /// Unique identifier for this action /// Title for the action (and button label) /// Label for a button for submitting the text input public iOSTextInputNotificationAction(string id, string title, string buttonTitle) : base(id, title) { TextInputButtonTitle = buttonTitle; } /// /// Creates new text input action. /// /// Unique identifier for this action /// Title for the action (and button label) /// Options for the action /// Label for a button for submitting the text input public iOSTextInputNotificationAction(string id, string title, iOSNotificationActionOptions options, string buttonTitle) : base(id, title, options) { TextInputButtonTitle = buttonTitle; } internal override IntPtr CreateUNNotificationAction() { #if UNITY_IOS && !UNITY_EDITOR return iOSNotificationsWrapper._CreateUNTextInputNotificationAction(Id, Title, (int)Options, TextInputButtonTitle, TextInputPlaceholder); #else return IntPtr.Zero; #endif } } }