0

I am developing an application for OSX and have to handle custom URL handling in my application

<a href="openApp:abc@xyz.com">Open My profile!</a>

While Application is Running I am able to get event inside

    - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent{


}

But when Application not running : it did Come to AppDidFinishedLaunching and i am not able to detect whether its invoked normally or by Custom URL ,

Is there any way to detect while App Launching ?

Thanks in advance

Amitg2k12
  • 3,765
  • 10
  • 48
  • 97
  • possible duplicate of [How to handle with a default URL scheme](http://stackoverflow.com/questions/1991072/how-to-handle-with-a-default-url-scheme) – Thomas Zoechling Jan 31 '14 at 09:15
  • I answered that question here: http://stackoverflow.com/questions/1991072/how-to-handle-with-a-default-url-scheme . Note that there is a subtle difference when installing the scheme handler in sandboxed apps vs. non-sandboxed apps. When sandboxing is enabled, you should install the handler in applicationWillFinishLaunching:, otherwise in applicationDidFinishLaunching – Thomas Zoechling Jan 31 '14 at 09:17

1 Answers1

0

Instead of implementing -applicationDidFinishLaunching:, you should implement the more modern delegate method -application:didFinishLaunchingWithOptions:. You can then examine the launchOptions dictionary and look for the key UIApplicationLaunchOptionsURLKey. If you find that key in the dictionary, your app was launched in response to a custom URL. The URL itself is the value that corresponds to that key in the dictionary.

You can use the same method (looking for different keys, of course) to tell if your app was launched in response to a notifications, a location event, etc.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • I am on OSX, not on iOS, and didn't get -application:didFinishLaunchingWithOptions:. equivalent for OSX – Amitg2k12 Jan 31 '14 at 06:01