如何在Mac上将自定义协议映射到应用程序? [英] How to map a custom protocol to an application on the Mac?

查看:243
本文介绍了如何在Mac上将自定义协议映射到应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向Mac上的应用程序注册自定义协议,即:

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

  1. 用户点击带有"abcdef://some/url/here"的链接
  2. 使用上面的字符串作为第一个参数传递的情况下启动已安装的应用程序

我已经使用以下问题的信息在Windows上成功完成了此操作:

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

如何创建自己的URL协议? (例如so://...)

我希望找到与浏览器无关的东西,换句话说,就是在操作系统级别.我还想通过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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆