Take the 2-minute tour ×

My iPhone application has different view controllers and I would like to invoke them based on the push notification received from backend. For example if I have view controllers "A" and "B", I would launch "A" when user receives a message regarding some activity in "A" (e.g. Please complete the activity in "A") and would launch screen "B" if user receives "Please complete the activity in "B"). Can anybody tell me if this is possible in iPhone and if so how?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Sure. Your app delegate is notified of a push notification either through the application:didReceiveRemoteNotification: method (if the notification arrives while the app is active in the foreground of if the app is in the background and the user brings it to the foreground by acting on the push notification) or application:didFinishLaunchingWithOptions: (if the app was neither in the background nor in the foreground and the user launches it by acting on the push notification).

In both cases, the dictionary that is passed to you as a parameter of either method contains the notification's payload/contents. You can use it to identify which type of notification your app received and then act accordingly by displaying the appropriate view controller.

share|improve this answer
+1 correct and entirely complete answer –  Till Dec 9 '11 at 18:38

Your Answer


