I am using local notifications in my app to alert urgent messages to the user. What happens is the user receives a push notification, then a local notification is created and fired 60 seconds later with a time interval of 60 seconds. This works great and the urgent notification fires every 60 seconds as expected.
The local notification star firing every one minute. But i want to stop them. Can you suggest me how to handle this.
On iOS 9 we did not experience this problem at all and the notification would fire repeatedly overnight even, so I am thinking this might be something related to iOS 10?
The code I use to create the notification is as follows:
let content = UNMutableNotificationContent()
content.body = NSString.localizedUserNotificationString(forKey: notificationMessage, arguments: nil)
content.badge = 1
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
let request = UNNotificationRequest.init(identifier: "", content: content, trigger: trigger)
center.add(request, withCompletionHandler: {(_ error: Error?) -> Void in
if error == nil {
print("add NotificationRequest succeeded!")
// trigger.timeInterval.
}
})
I found the missing point.