NSAPP Custom URL Handling

310 views Asked by At

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

<a href="openApp:[email protected]">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

1

There are 1 answers

1
Caleb On BEST ANSWER

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.