在Mac OSX上注册一个协议?

9

我已经在Windows上完成了这项工作,如何在Mac OS X上注册协议?我想要在Firefox中点击链接(a href="somename://mylinkAndData"),并启动一个二进制文件。

1个回答

14

请查看苹果公司的启动服务编程指南。您需要将CFBundleURLTypes添加到应用程序的Info.plist文件中,并使用LSRegisterURL()注册您的应用程序。

Firefox.app/Contents/Info.plist摘录:

    <key>CFBundleURLTypes</key>
    <array>
            <dict>
                    <key>CFBundleURLIconFile</key>
                    <string>document.icns</string>
                    <key>CFBundleURLName</key>
                    <string>http URL</string>
                    <key>CFBundleURLSchemes</key>
                    <array>
                            <string>http</string>
                    </array>
            </dict>
 ....

编辑:请参阅在Cocoa中处理URL方案进行操作的如何文章。


一个更近期的如何操作:https://css-tricks.com/create-url-scheme/ - Mikeumus

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接