0

I have an app in which I'm using push notifications. What I really want to do is when a user slides to view from the lock screen he should be able to go to a specific view controller, and not just simply open the app.

Is this possible? Can anyone direct me towards right direction?

Thanks a lot!

aopsfan
  • 2,451
  • 19
  • 30
iPhoneDev
  • 303
  • 1
  • 2
  • 10
  • Try this link: http://stackoverflow.com/questions/8257888/how-to-open-a-viewcontroller-before-application-starts-in-ios – aopsfan Nov 24 '11 at 15:46

2 Answers2

3

In your application:didFinishLaunchingWithOptions: method you can check whether your app was started due to a remote notification by looking into the launchOptions dictionary. The key UIApplicationLaunchOptionsRemoteNotificationKey will give you the remote notification, if any, and you would then need to present your view controller.

If your app is still running while the remote notification arrives your app delegate's application:didReceiveRemoteNotification: method is called.

See the UIApplicationDelegate documentation.

DarkDust
  • 90,870
  • 19
  • 190
  • 224
  • Is this wat u r suggesting ? 'if([launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey] != nil) { [window addSubview:*some controller*]; [window makeKeyAndVisible]; }' – iPhoneDev Nov 24 '11 at 16:16
  • Something along this line, yes. Or maybe something like `[mainViewController presentModalViewController:anotherViewController animated:YES];`, I have no idea what your app design looks like. – DarkDust Nov 24 '11 at 16:27
0

The app needs to figure out and show the right view controller when it is opened after a push notification.

progrmr
  • 75,956
  • 16
  • 112
  • 147
  • Could you be more specific please. Where do i get the control of controller slider to *some specific controller* – iPhoneDev Nov 24 '11 at 15:40
  • See [APNS Programming Guide](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW1) for details but the app is notified via `application:didFinishLaunchingWithOptions:` – progrmr Nov 24 '11 at 15:44