My app works perfectly on ios 10 but on ios 11 it does not push local Notification. Is there any error in my code?. I have searced a lot but couldn't find appropriate solution is this a bug in ios 11 ?
class AddReminderViewController: UIViewController , UNUserNotificationCenterDelegate{
// variables
var preControllerReference : ReminderViewController?
let center = UNUserNotificationCenter.current()
override func viewDidLoad() {
super.viewDidLoad()
center.delegate = self
center.requestAuthorization(options: [.alert, .sound]) { (granted, error) in
// Enable or disable features based on authorization.
if error != nil {
print("Request authorization failed!")
} else {
print("Request authorization succeeded!")
}
}
setReminder()
// Do any additional setup after loading the view.
}
This is the function which is setting notification
func setReminder(){
let content = UNMutableNotificationContent()
content.title = "Bee Productive"
content.body = "Buy some time"
content.sound = UNNotificationSound.default()
content.categoryIdentifier = "reminder-category"
let snoozAction = UNNotificationAction(identifier:"snooze", title: "Snooze", options:[])
let deleteAction = UNNotificationAction(identifier:"deleteAction", title: "Delete", options:[.destructive])
let category = UNNotificationCategory(identifier: "reminder-category", actions: [snoozAction,deleteAction], intentIdentifiers:[], options: [])
center.setNotificationCategories([category])
let date = self.reminderDatePicker.date
print(date)
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 3, repeats: false)
let identifier = "reminder-notification"
let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger )
center.add(request) { (error) in
if let err = error {
print("something wrong \(err)")
}
}
}
any idea whats wrong. Thanks in advance