using System; using System.Collections.Generic; namespace Unity.Notifications.iOS { /// /// Options for notification category. Multiple options can be combined. /// These represent values from UNNotificationCategoryOptions. /// /// [Flags] public enum iOSNotificationCategoryOptions { None = 0, CustomDismissAction = (1 << 0), AllowInCarPlay = (1 << 1), HiddenPreviewsShowTitle = (1 << 2), HiddenPreviewsShowSubtitle = (1 << 3), } /// /// Represents notification category. /// Notification categories need to be registered on application start to be useful. /// By adding actions to category, you make all notification sent with this category identifier actionable. /// /// /// public class iOSNotificationCategory { List m_Actions = new List(); List m_IntentIdentifiers = new List(); /// /// A unique identifier for this category. /// public string Id { get; set; } /// /// Get actions set for this category. /// /// public iOSNotificationAction[] Actions { get { return m_Actions.ToArray(); } } /// /// Intent identifiers set for this category. /// /// public string[] IntentIdentifiers { get { return m_IntentIdentifiers.ToArray(); } } /// /// The placeholder text to display when the system disables notification previews for the app. /// /// public string HiddenPreviewsBodyPlaceholder { get; set; } /// /// A format string for the summary description used when the system groups the category’s notifications. /// /// public string SummaryFormat { get; set; } /// /// Options for how to handle notifications of this type. /// public iOSNotificationCategoryOptions Options { get; set; } /// /// Create notification category. /// Category must be registered using iOSNotificationCenter.SetNotificationCategories. /// /// A unique identifier for this category public iOSNotificationCategory(string id) { Id = id; } /// /// Create notification category. /// Category must be registered using iOSNotificationCenter.SetNotificationCategories. /// /// A unique identifier for this category /// Add provided actions to this category public iOSNotificationCategory(string id, IEnumerable actions) : this(id) { if (actions != null) m_Actions.AddRange(actions); } /// /// Create notification category. /// Category must be registered using iOSNotificationCenter.SetNotificationCategories. /// /// A unique identifier for this category /// Add provided actions to this category /// Add provided intent identifiers to this category public iOSNotificationCategory(string id, IEnumerable actions, IEnumerable intentIdentifiers) : this(id, actions) { if (intentIdentifiers != null) m_IntentIdentifiers.AddRange(intentIdentifiers); } /// /// Add action to this category. /// Actions must be added prior to registering the category. /// /// Action to add public void AddAction(iOSNotificationAction action) { if (action == null) throw new ArgumentException("Cannot add null action"); m_Actions.Add(action); } /// /// Add actions to this category. /// Actions must be added prior to registering the category. /// /// Actions to add public void AddActions(IEnumerable actions) { if (actions == null) throw new ArgumentException("Cannot add null actions collection"); m_Actions.AddRange(actions); } /// /// Add intent identifier to this category. /// Intent identifiers must be added prior to registering the category. /// /// Intent identifier to add public void AddIntentIdentifier(string identifier) { if (identifier == null) throw new ArgumentException("Cannot add null intent identifier"); m_IntentIdentifiers.Add(identifier); } /// /// Add intent identifier to this category. /// Intent identifiers must be added prior to registering the category. /// /// Intent identifiers to add public void AddIntentIdentifiers(IEnumerable identifiers) { if (identifiers == null) throw new ArgumentException("Cannot add null intent identifiers collection"); m_IntentIdentifiers.AddRange(identifiers); } } }