通用链接在 Safari 浏览器顶部显示横幅

Universal Links is showing banner on top of Safari browser

请帮我解决这个问题。我已经通过 https://www.raywenderlich.com/128948/universal-links-make-connection 实现了通用 links,我遇到的问题是当我点击 link 时,我被重定向到网络浏览器而不是应用程序。在 safari 浏览器中,当我向下滚动页面时,我会看到一个带有 OPEN 按钮的横幅。通过单击它,我的应用程序将打开,并根据逻辑打开特定的视图控制器。那么为什么它首先在浏览器中打开呢?如果安装了应用程序,它应该直接在应用程序而不是网络浏览器中打开。

以下是我的应用委托中的方法:

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {

        if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
            guard let url = userActivity.webpageURL else {
                return false
            }
            openViewController(url)
        }
        return true
    }

func openViewController(url: NSURL) {
        let components = NSURLComponents(URL: url, resolvingAgainstBaseURL: true)
        print(components)
        print(url.absoluteString)
        if url.host == "refit.co" && (url.pathComponents![2] == "supplements" || url.pathComponents![2] == "equipments") {
            print("This is the supplements/equipments universal link")
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let vc = storyboard.instantiateViewControllerWithIdentifier("Home")
            let navController = self.window?.rootViewController as? UINavigationController
            navController?.pushViewController(vc, animated: false)
            let vc2 = storyboard.instantiateViewControllerWithIdentifier("SupplementDetail") as? VCSupplementDetail
            vc2?.itemID = getID(url.query!)
            vc2?.screenName = url.pathComponents![2] == "supplements" ? "Supplements" : "Equipments"
            navController?.pushViewController(vc2!, animated: true)
            print("Query: \(url.query)")
        } else {
            print("This is the url: \(url)")
            print(url.host)
            print(url.path)
            print(url.query)
            print(url.pathComponents)
        }
    }

听起来您无意中停用了通用 Links。如果您在打开通用 Link 后点击屏幕右上角的旁路 link,通常会发生这种情况。有关如何反转该过程的详细信息,请参阅