Contents

init(identifier:actions:intentIdentifiers:hiddenPreviewsBodyPlaceholder:categorySummaryFormat:options:)

Creates a category object containing the specified actions, options, placeholder text used when previews aren’t shown, and summary format string.

Declaration

convenience init(identifier: String, actions: [UNNotificationAction], intentIdentifiers: [String], hiddenPreviewsBodyPlaceholder: String?, categorySummaryFormat: String?, options: UNNotificationCategoryOptions = [])

Parameters

  • identifier:

    The unique identifier for the category. Each category that your app uses must have a unique identifier. Don’t specify an empty string.

  • actions:

    The actions to display when the system delivers notifications of this type. When minimal space is available, the system displays only the first two actions in the array. You may specify an empty array for this parameter if you don’t want to display custom actions.

  • intentIdentifiers:

    The intent identifier strings that you want to associate with notifications of this type. The Intents framework defines constants for each type of intent that you can associate with your notifications.

  • hiddenPreviewsBodyPlaceholder:

    A placeholder string to display when the user has disabled notification previews for the app. Include the characters %u (the only supported formatting characters) in the string to represent the number of notifications with the same thread identifier. For example, the string “%u Messages” becomes “2 Messages” when there are two messages.

    To specify different strings for the singular and plural cases, use the Localizedusernotificationstring(forkey:arguments:) method of Nsstring to specify the value for this parameter. The key passed to that method contains the identifier of an entry in a .stringsdict property list of your project. A strings dictionary lets you specify different formatted strings based on the language rules, and is as described in 10000171i.

  • categorySummaryFormat:

    A format string for the summary description used when the system groups the category’s notifications.

  • options:

    Additional options for handling notifications of this type. For a list of possible values, see Unnotificationcategoryoptions.

See Also

Essentials