5

I have set up a custom deep-linking iOS URL scheme for my app, and I listen for it in

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

I parse the URL and send a notification using NSNotificationCenter, with the URL as the object, to the appropriate class to handle the URL.

This all works great when the app is "backgrounded" but when the app is fully closed out of multitasking, it seems like the notification never gets sent (or received). Am I missing something about the process of notifications when the app isn't in backgrounding? Is there another way to pass along the information from the URL? Or is there at least a way to tell if the app is coming out of backgrounding or if it is a fresh launch?

Thanks!

JeffN
  • 1,575
  • 15
  • 26
  • 1
    I would recommend looking at `applicationDidFinishLaunching:withOptions:`. The notifications should be delivered in the launch options dictionary. http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html – Mike D Jul 29 '13 at 17:01
  • Make sure you return `YES` from `application:willFinishLaunchingWithOptions:` and `application:didFinishLaunchingWithOptions:`. If either return `NO`, then the `application:openURL:sourceApplication:annotation:` method won't be called on app startup. – rmaddy Jul 29 '13 at 17:06
  • @rmaddy both are returning YES, 'application:openURL:sourceApplication:annotation:' is getting called, but notification not being passed – JeffN Jul 29 '13 at 17:15
  • @MikeD checking into that now thanks. – JeffN Jul 29 '13 at 17:15
  • @MikeD solved using the URL from launch options dictionary. Thanks, if you want to submit answer I can mark solved – JeffN Jul 29 '13 at 18:05

1 Answers1

3

You should check the launchOptions dictionary that is passed into applicationDidFinishLuanching:withOptions:.

For full details on what is included in the options dictionary: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html

Mike D
  • 4,938
  • 6
  • 43
  • 99