Don't implement applicationDidFinishLaunching:
. Use application:didFinishLaunchingWithOptions:
instead. Likewise don't use application:handleOpenURL:
, use application:openURL:sourceApplication:annotation:
instead.
If you are launched from a URL the options dictionary will contain a UIApplicationLaunchOptionsURLKey key, and the value for that key will be the URL.
However, if your app is already running but is in the background and the user invokes a URL that re-opens your app, you will get a application:openURL:sourceApplication:annotation:
message instead.
What you really need to do is implement a handleURL method, and then call that method from both application:didFinishLaunchingWithOptions:
and application:openURL:sourceApplication:annotation:
EDIT:
Note that in iOS 9, Apple deprecated application:openURL:sourceApplication:annotation:
and added the new method application:openURL:options:
.
If your app is iOS 9 and later only, you should implement the new application:openURL:options:
method. If you need to support iOS 9 and earlier versions, you should probably implement both application:openURL:sourceApplication:annotation:
and the new iOS 9 method application:openURL:options:
. The OS will call the correct version for the OS version you are running. I would then create a common method that both of those call. That way you get called from both OS versions, but your code to handle opening an URL is only in one place.