I'm currently facing problem while viewing action buttons on time-interval notification on iOS 10. I have created two UNNotificationAction objects 'OK' & 'Cancel' added as notification category.
I'm getting notification on simulator without any action button. Below is my code.
let ok = UNNotificationAction(identifier: "OKIdentifier",
title: "OK", options: [])
let cancel = UNNotificationAction(identifier: "CancelIdentifier",
title: "Cancel",
options: [])
let category = UNNotificationCategory(identifier: "message",
actions: [ok, cancel],
minimalActions: [ok, cancel],
intentIdentifiers: [],
options: [])
UNUserNotificationCenter.current().setNotificationCategories([category!])
let content = UNMutableNotificationContent()
content.title = contentTitle
content.subtitle = contentSubtitle
content.body = contentBody
let model: TimeIntervalNotificationModel = notificationsModel as! TimeIntervalNotificationModel
trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: model.timeInterval!, repeats: notificationsModel.repeats) as UNTimeIntervalNotificationTrigger
let request = UNNotificationRequest(identifier:requestIdentifier, content: content, trigger: trigger)
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().add(request){(error) in
if (error != nil){
//handle here
print("Error: Adding notification failed:\(error?.description)")
self.delegate?.didFailToAddNotification(error: error!)
}
}