Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Custom protocol handlers in OS X?

Is there a way to add handlers for different protocols in URLs apart from the standard ones like http and ftp? I'm specifically interested making the notes protocol work on my Mac so that clicking a notes:// link will open Lotus Notes as it does on Windows.

iMac G5 20, Mac OS X (10.5.1)

Posted on Dec 7, 2007 1:03 AM

Reply
9 replies

Dec 7, 2007 9:24 AM in response to Knut Harald Støre

The technical term you want is LSRegisterURL, which is the system-level command for registering URL types.

Typically, though, this is done within the application and I can't think of anything off-hand that lets you hand-craft the mapping.

One thought may be to edit the application's /Contents/info.plist file which includes the document types it supports, but you're delving into dangerous territory with that one.

Dec 7, 2007 11:49 AM in response to etresoft

I didn't know about the message URLs but they won't help me I'm afraid.
1. We don't use Notes as an email client anymore. I have to use Entourage to access our Exchange server
2. I doubt that Notes supports the message URLs
3. The links that I want to click are not and will never be message URLs. My coworkers send me links to documents in various databases in Notes which all use the notes:// prefix.

Dec 11, 2007 6:25 AM in response to Knut Harald Støre

I've never done it, so I can't give you explicity directions.

I assume you have the URL scheme that your application can handle listed in its Info.plist file. The Finder should automatically pick up on that when your application is installed. If it doesn't you can call LSRegisterURL. You can test it by doing the following on the command line: "open notes://12345" and it should start your application with the given URL. Your application should be setup to open documents via URL in the normal fashion. Well, not entirely normal, you'll do funky things with the "notes:" URL.

Dec 12, 2007 4:17 AM in response to etresoft

Thanks for the info. I'm not so keen to get into programming unless it can be done in AppleScript. But I dug into the info.plist file. It contains no URL registrations but I opened up Safari's info.plist file, found its URL registrations, copied into Notes's info.plist file and modified it appropriately. I then restarted Notes and closed it again hoping that it would be registered but it still doesn't work. When I try to open a "notes://" url from Terminal nothing happens. Do I have to do anything else to make the system rescan the info.plist file and register the association? Here is what I added to info.plist:

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Lotus Notes Document URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>notes</string>
</array>
<true/>
</dict>
</array>

Dec 12, 2007 5:49 AM in response to Knut Harald Støre

Knut Harald Støre wrote:
Thanks for the info. I'm not so keen to get into programming unless it can be done in AppleScript.


I have an odd relationship with AppleScript. I have written software in just about every language, from Assembly to million-line C++ monsters. But I can't get an AppleScript to work the same way twice. If I need a scripting language, I'll use Perl. If it is something that Perl can't handle, I'll use Objective-C because it is almost as easy.

But I dug into the info.plist file. It contains no URL registrations but I opened up Safari's info.plist file, found its URL registrations, copied into Notes's info.plist file and modified it appropriately. I then restarted Notes and closed it again hoping that it would be registered but it still doesn't work. When I try to open a "notes://" url from Terminal nothing happens. Do I have to do anything else to make the system rescan the info.plist file and register the association? Here is what I added to info.plist:


I'm pretty sure it will be more complicated than that. As I already mentioned, I can't get "Hello, World" to work in AppleScript so I can't help with that. Here is what I was thinking:

1) Write a program that knows how to handle a "notes:" URL. Look at the Bwana source for an example. All you need at this point is a program that recognizes the URL and displays an alert with everything after "notes:" in the URL string. Test it by doing "open notes:yadayadayada" in the Terminal. I would do this in Objective-C. You may be able to do it in AppleScript. There is an AppleScript forum where anyone will know more than me.
2) Find out what Apple script command are needed to tell Notes to open a particular message, given the contents of a Notes "notes:" URL. Hopefully Lotus Notes is scriptable and hopefully it has such a command. This is not guaranteed, however.
3) Change your first program from displaying an alert to executing the Applescript commands in Step 2. You're done.

Custom protocol handlers in OS X?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.