I am scheduling new notifications in iOS10, like this:
func scheduleNotification (event : Meeting, todaysBadgeCounter: Int) {
if #available(iOS 10.0, *)
Make sure your AppDelegate implementing UNUserNotificationCenterDelegate protocol.
For Swift
let center = UNUserNotificationCenter.current()
center.delegate = self
For Objective-c
//set delegate to self
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
Assigning delegate to self will trigger following methods.
// App in foreground
private func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) {
print("willPresent")
}
//On Action click
private func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
print("didReceive")
}