I'm really new to notifications and I tried many of the answers mentioned in other questions and I'm pretty much confused.
So here's the situation. I have an app that receives remote notifications. I managed to configure it using the didReceiveRemoteNotification
to display the message it receives and when the notification is tapped, the user is taken to a specific viewController via the SWReveal library. This works well if the app is in background.
In foreground I was told I should use the willPresent notification
and didReceive response
methods for iOS 10. I managed to get the notification to show up if the app is in foreground but tapping the notification does nothing. I want to perform the same functionality I have in the didReceiveRemoteNotification
.
I also need to add action buttons for some of the notifications I get (background and foreground) and I have no idea how I can handle that.
Any help would really be appreciated.
See if you have set the delegate of UNUserNotificationCenter(i.e UNUserNotificationCenter.current().delegate = self) in your viewDidLoad
and then handle the tap of notification in
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
//Handle notification tap
}