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

查看:34
本文介绍了如何将自定义协议映射到 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.

谢谢!

推荐答案

我没有机会使用它,但前段时间我收藏了 用于打开本地文件链接的 OS X URL 处理程序,这正是您要查找的内容.

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.

链接过程的重要部分是添加适当的CFBundleURLTypes 到描述该方案的应用程序的 Info.plist.那里给出的示例如下所示:

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天全站免登陆