Thread Identifier
Create notification content with threadIdentifier
to create group of that notification. Group will be of the application or specific topic from an application.
|
// Creating Groups with Thread Identifiers let content = UNMutableNotificationContent() content.title = "Notifications Group" content.body = "Tutorial by Ashish Kakkad" content.threadIdentifier = "notify-team-ios" |
Notification payload will be like this
|
{ "aps" : { "alert" : { "title" : "Notifications Group", "body" : "Tutorial by Ashish Kakkad" } "thread-id" : "notify-team-ios" } } |
Give meaningful name to thread identifier for specific purpose of group.
Summary of group
Simple Notification Group Summary
|
let summaryFormat = "%u more messages" return UNNotificationCategory(identifier: "category-identifier", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: nil, categorySummaryFormat: summaryFormat, options: []) |
Hidden Previews Summary Customization
|
let summaryFormat = "%u more messages" let hiddenPreviewsPlaceholder = "%u messages" return UNNotificationCategory(identifier: "category-identifier", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: hiddenPreviewsPlaceholder, categorySummaryFormat: summaryFormat, options: []) |
Notification Group Summary with Arguments
|
let summaryFormat = "%u more messages from %@" return UNNotificationCategory(identifier: "group-messages", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: nil, categorySummaryFormat: summaryFormat, options: []) |
Notification Group Summary Argument
|
let content = UNMutableNotificationContent() content.body = "…" content.threadIdentifier = "notify-team-ios" content.summaryArgument = "Ashish" |
Notification Summary with Argument Count
|
let content = UNMutableNotificationContent() content.body = "…" content.threadIdentifier = "notify-team-ios" content.summaryArgument = "Ashish" content.summaryArgumentCount = 2 |
Updated notification payload will be like this
|
{ "aps" : { "alert" : { "body" : "…", "summary-arg" : "Ashish", "summary-arg-count" : 2 }, "thread-id" : "notify-team-ios" } } |