UANotificationCategories

@interface UANotificationCategories : NSObject

Utility methods to create categories from plist files or NSDictionaries.

  • 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

    + (UANotificationCategory *_Nullable)
                       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.