Open specific tab / view when user receives push notification

I want to do something like a Twitter application: when someone writes to me, I get a push notification; if I โ€œclose the notificationโ€, the application will start, but not in the usual stream, it starts from a certain view with a tweet that someone wrote to me!

In my application, I have something like an RSS reader, and a push notification comes when new news arrives. So, I want to open the "only news view", and not the main view (what is happening now).

What can I do?

thanks

+6
source share
1 answer

You can do two things.

One of them is to check the launchOptions dictionary of the launchOptions method

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

to find out if the application was launched through the user clicking on the notification. If so, then in this method you can push the appropriate view controller onto the stack, as usual using the application.

If the application is already open but the same theory is applied in the background, use the UIApplicationDelegate method UIApplicationDelegate

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 

For more information on handling incoming notifications, see this link .

+11
source

All Articles