How can I tell if handleOpenURL is called app startup or while app is running?

ios

Solution

You should not use `handleOpenURL` since it's deprecated. Instead, use `application:openURL:sourceApplication:annotation:` (available since iOS 4.2).

Apple's documentation gives the answer to your question here regarding `application:openURL:sourceApplication:annotation`:

If your app had to be launched to open the URL, the app calls the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods first, followed by this method. The return values of those methods can be used to prevent this method from being called. (If the application is already running, only this method is called.)

Problem

As the sequence of events is slightly different depending on which of these two scenarios is in progress, I would like to be able to tell the difference. Any suggestions?

Original source