handleGetURLEvent doesn't get called

It sounds like you may need to clean your project. Sometimes the Launch Services database (which handles URL associations) is not updated correctly when Xcode builds an app. Cleaning the project should delete the built app entirely, so the next time you build the project it is created from scratch, in the process updating the Launch Services database.

You might also want to try copying the app into the /Applications folder, which should make Launch Services re-parse the app's Info.plist file.

You can force Launch Services to rebuild its database by running the following command in Terminal:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Move the event handler code to the init method:

- (id) init
{   
    if ((self = [super init]))
    {
        NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
        [appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];

        // Add the following to set your app as the default for this scheme
        NSString * bundleID = [[NSBundle mainBundle] bundleIdentifier];
        LSSetDefaultHandlerForURLScheme((CFStringRef)@"myscheme", (CFStringRef)bundleID 
    }
return self;
}

Note: myscheme should take the form x-com-companyname-appname so that it never clashes with any other scheme out there.

See Also: For more information on this topic see How do you set your Cocoa application as the default web browser?


Update database OS10.8 Mountain Lion

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f

-kill Reset the Launch Services database before doing anything else -seed If database isn't seeded, scan default locations for applications and libraries to register -lint Print information about plist errors while registering bundles -convert Register apps found in older LS database files -lazy n Sleep for n seconds before registering/scanning -r Recursive directory scan, do not recurse into packages or invisible directories -R Recursive directory scan, descending into packages and invisible directories

-f force-update registration even if mod date is unchanged

-u unregister instead of register -v Display progress information -dump Display full database contents after registration -h Display this help