UILocalNotification - How do I know if a user action has come from the notification center?

In the method that is called when the notification is executed:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 

Is there a way to find out if a notification was received from the user by clicking on the warning in the notification center, or was the warning received while the application was running?

The reason is because I want to direct the user to a specific page when they click on a warning. This method above is called if the warning is disabled when the user is inside the application (therefore, they did not click the notification in the notification center), and I do not want to kick them to another screen.

However, if the application is running or is in the background, and they pulled out the notification center, I want to bring them to a specific screen and the same method is called in these situations.

+4
source share
1 answer

Unfortunately, you cannot do what you want. The closest you can find is

 - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { if (application.applicationState == UIApplicationStateActive) // They didn't come from the notification area else // They did } 

Unfortunately, contextual information is not provided upon receipt of warnings.

+4
source

All Articles