I'm adding as follows in all categories, but when I add more than 100, the first 100 category id work and the rest are not working.
func setNotificationCategories(application: UIApplication) {
let center: UNUserNotificationCenter = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.sound, .alert, .badge]) { _, error in
if error != nil {
return
}
var notificationCategories: Set<UNNotificationCategory> = []
if let path = Bundle.main.path(forResource: "NotificationCategories", ofType: "plist"),
let notificationCategoriesArray = NSArray(contentsOfFile: path) as? [[String: Any]] {
for item in notificationCategoriesArray {
if let categoryId = item["CategoryId"] as? String,
let buttonText = item["ButtonText"] as? String {
let notificationActions = [UNNotificationAction(identifier: "1", title: firstButtonText, options: [.foreground,
.authenticationRequired])]
let notificationCategory: UNNotificationCategory = UNNotificationCategory(identifier: categoryId,
actions: notificationActions,
intentIdentifiers: [],
options: .customDismissAction)
notificationCategories.insert(notificationCategory)
}
}
}
center.setNotificationCategories(notificationCategories)
self.getNotificationSettings()
}
}
Sample plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>CategoryId</key>
<string>1</string>
<key>ButtonText</key>
<string>check!</string>
</dict>
<dict>
<key>CategoryId</key>
<string>2</string>
<key>ButtonText</key>
<string>approve</string>
</dict>
</array>
</plist>
I couldn't find any information about this when I looked through the apple documentation. Is it possible to add more than 100 categories?