Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map a custom protocol to an application on the Mac?

I'm trying to register a custom protocol to an application on the Mac, i.e:

  1. User clicks on link with "abcdef://some/url/here"
  2. An installed application is launched with the above string passed as the first param

I've done this successfully on Windows using the information from this question:

how do I create my own URL protocol? (e.g. so://...)

I would prefer to find something that is browser-independent, in other words at the OS level. I would also like to automate this registration through a shell script, so hopefully there is a way to do this that doesn't involve the GUI.

Thanks!

like image 261
cliff.meyers Avatar asked Jan 23 '09 01:01

cliff.meyers


1 Answers

I've not had occasion to use it, but some time ago I bookmarked OS X URL handler to open links to local files which is exactly what you're looking for.

The important part of the linked procedure is adding an appropriate CFBundleURLTypes to your application's Info.plist that describes the scheme. The example given there looks like this:

<key>CFBundleURLTypes</key> <array>     <dict>         <key>CFBundleURLName</key>         <string>Local File</string>         <key>CFBundleURLSchemes</key>         <array>             <string>local</string>         </array>     </dict> </array> 
like image 117
Jay Avatar answered Sep 23 '22 08:09

Jay