如何在Mac上将自定义协议映射到应用程序? [英] How to map a custom protocol to an application on the Mac?
问题描述
我正在尝试向Mac上的应用程序注册自定义协议,即:
I'm trying to register a custom protocol to an application on the Mac, i.e:
- 用户点击带有"abcdef://some/url/here"的链接
- 使用上面的字符串作为第一个参数传递的情况下启动已安装的应用程序
我已经使用以下问题的信息在Windows上成功完成了此操作:
I've done this successfully on Windows using the information from this question:
我希望找到与浏览器无关的东西,换句话说,就是在操作系统级别.我还想通过shell脚本自动执行此注册,因此希望有一种不涉及GUI的方法.
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.
谢谢!
推荐答案
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>
这篇关于如何在Mac上将自定义协议映射到应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!