UANotificationCategories

Objective-C

@interface UANotificationCategories : NSObject

Swift

class UANotificationCategories : NSObject

Utility methods to create categories from plist files or NSDictionaries.

Notification Catagories Factories

  • Creates a set of categories from the specified .plist file.

    Categories are defined in a plist dictionary with the category ID followed by an NSArray of user notification action definitions. The action definitions use the same keys as the properties on the action, with the exception of “foreground” mapping to either UIUserNotificationActivationModeForeground or UIUserNotificationActivationModeBackground. The required action definition title can be defined with either the “title” or “title_resource” key, where the latter takes precedence. If “title_resource” does not exist, the action definition title will fall back to the value of “title”. If the required action definition title is not defined, the category will not be created.

    Example:

    { “category_id” : [ { “identifier” : “action ID”, “title_resource” : “action title resource”, “title” : “action title”, “foreground” : @YES, “authenticationRequired” : @NO, “destructive” : @NO }] }

    Declaration

    Objective-C

    + (nonnull NSSet *)createCategoriesFromFile:(nonnull NSString *)filePath;

    Swift

    class func createCategories(fromFile filePath: String) -> Set<AnyHashable>

    Parameters

    filePath

    The path of the .plist file.

    Return Value

    A set of categories.

  • Creates a user notification category with the specified ID and action definitions.

    Declaration

    Objective-C

    + (nullable UANotificationCategory *)
        createCategory:(nonnull NSString *)categoryId
               actions:(nonnull NSArray *)actionDefinitions;

    Swift

    class func createCategory(_ categoryId: String, actions actionDefinitions: [Any]) -> UANotificationCategory?

    Parameters

    categoryId

    The category identifier

    actionDefinitions

    An array of user notification action dictionaries used to construct UANotificationAction for the category.

    Return Value

    The user notification category created or nil if an error occurred.

  • Creates a user notification category with the specified ID, action definitions, and hiddenPreviewsBodyPlaceholder.

    Declaration

    Objective-C

    + (nullable UANotificationCategory *)
                       createCategory:(nonnull NSString *)categoryId
                              actions:(nonnull NSArray *)actionDefinitions
        hiddenPreviewsBodyPlaceholder:
            (nonnull NSString *)hiddenPreviewsBodyPlaceholder;

    Swift

    class func createCategory(_ categoryId: String, actions actionDefinitions: [Any], hiddenPreviewsBodyPlaceholder: String) -> UANotificationCategory?

    Parameters

    categoryId

    The category identifier

    actionDefinitions

    An array of user notification action dictionaries used to construct UANotificationAction for the category.

    hiddenPreviewsBodyPlaceholder

    A placeholder string to display when the user has disabled notification previews for the app.

    Return Value

    The user notification category created or nil if an error occurred.

  • Factory method to create the default set of user notification categories. Background user notification actions will default to requiring authorization.

    Declaration

    Objective-C

    + (nonnull NSSet *)defaultCategories;

    Swift

    class func defaultCategories() -> Set<AnyHashable>

    Return Value

    A set of user notification categories.

  • Factory method to create the default set of user notification categories.

    Declaration

    Objective-C

    + (nonnull NSSet *)defaultCategoriesWithRequireAuth:(BOOL)requireAuth;

    Swift

    class func defaultCategories(withRequireAuth requireAuth: Bool) -> Set<AnyHashable>

    Parameters

    requireAuth

    If background actions should default to requiring authorization or not.

    Return Value

    A set of user notification categories.