Notification Group Summary(iOS12 Grouped Notifications)

Viewed 172

How to do it like Notification Group Summary of LINE?(Separate counts)as shown in figure1. figure1:Red boxed word

The following is the program I wrote.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

            UNUserNotificationCenter.current().delegate = self

            let videoLikeAction = UNNotificationAction(identifier: "videoLike", title: "進入APP", options: [.foreground])
            let videoCommentAction = UNNotificationAction(identifier: "videoComment", title: "關掉通知", options: [])
            //群組摘要設定
            let hiddenPreviewsPlaceholder = "鎖屏時還有%u個%@"
            let summaryFormat = "還有%u個%@"
            let summaryVideoCategory = UNNotificationCategory(identifier: "Video-APNs", actions: [videoLikeAction, videoCommentAction], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: hiddenPreviewsPlaceholder, categorySummaryFormat: summaryFormat, options: [])
            UNUserNotificationCenter.current().setNotificationCategories(
                                      [photoCategory, summaryVideoCategory])

            let center = UNUserNotificationCenter.current()
            center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in

                if granted {

                   DispatchQueue.main.async {
                        application.registerForRemoteNotifications()
                    }
                }
            }
            return true
    }

The results I wrote are as follows:(Combined counts)as shown in figure2. figure2:Red boxed word

0 Answers
Related