Borja
Borja

Reputation: 1471

Detect when user taps on a notification while app is in foreground

userNotificationCenter(...,didReceive,...) and userNotificationCenter(...,willPresent,...) are used respectively to:

But how do we handle the event in which the user taps on the notification while the app is in the foreground? (to, for instance, take the user to the relevant view controller when tapping on the notification)

Upvotes: 3

Views: 3269

Answers (1)

pacificpelican
pacificpelican

Reputation: 363

There are two didReceive methods, and they act differently. As it says on the page for the didReceiveRemoteNotification:fetchCompletionHandler:

"Unlike the application(_:didReceiveRemoteNotification:) method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background."

Upvotes: 1

Related Questions