Swift 无法识别到macOS应用程序的深层链接

Swift 无法识别到macOS应用程序的深层链接,swift,macos,hyperlink,deep-linking,Swift,Macos,Hyperlink,Deep Linking,我试图在macOS应用程序中实现一个深层链接,但似乎没有任何效果 到目前为止,my AppDelegate.swift包含以下内容 func application(app: NSApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { print("opened by link"); return true } 我还将info.plist配置为URLSchemes being my

我试图在macOS应用程序中实现一个深层链接,但似乎没有任何效果

到目前为止,my AppDelegate.swift包含以下内容

func application(app: NSApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    print("opened by link");
    return true
}
我还将info.plist配置为URLSchemes being my bundle identifier和URLIdentifier being simply
zst

在一个简单的html文件中,我使用以下代码来测试深层链接

<a href="zst://test/link">Test</a>

我的应用程序被打开(或在已经运行时变为活动状态),但不会执行print语句


我做错了什么?

多亏了@Ssswift,我找到了解决方案。 使用此代码:

并通过以下方式将其转换为swift:

与Swift 3合作 在
AppDelegate.swift
中添加了这些行

func applicationDidFinishLaunching(_ aNotification: Notification) {
    var em = NSAppleEventManager.shared()
    em.setEventHandler(self, andSelector: #selector(self.getUrl(_:withReplyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
}

func getUrl(_ event: NSAppleEventDescriptor, withReplyEvent replyEvent: NSAppleEventDescriptor) {
    // Get the URL
    var urlStr: String = event.paramDescriptor(forKeyword: keyDirectObject)!.stringValue!
    print(urlStr);

}

我自己从来没有做过这件事,但这个答案的一部分似乎很有用:@Ssswift thx buddy-这很有效!至少在打开链接时我得到了一个“hello world”:我知道这是4年前的事了,但我想知道你是否可以分享你的
.plist