According to apple docs, we can identify user's tap on notification by checking whether the application state variable is inactive (link).
iOS Note: In iOS, you can determine whether an application is launched as a result of the user tapping the action button or whether the notification was delivered to the already-running application by examining the application state. In the delegate’s implementation of the application:didReceiveRemoteNotification: or application:didReceiveLocalNotification: method, get the value of the applicationState property and evaluate it. If the value is UIApplicationStateInactive, the user tapped the action button; if the value is UIApplicationStateActive, the application was frontmost when it received the notification.
But I can see a use case where there is a system alert (By system alert, I mean an alert view presented in the foreground of the app which is controlled by iOS) in foreground and the app is in inactive state (When a "system alert" is in view, the app behind is made inactive by iOS by setting app's application state to UIApplicationStateInactive) but the user will still be able to see the app's content on the screen. Refer the attachment below:
At this state if the app receives a notification, it will behave as though user tapped on notification. Is there a solution to solve this use case?
application:didReceiveLocalNotification:
method call when you got notification. – iPatel