Swift 动态链接只能在模拟器中工作,不能在实际设备上工作

Swift 动态链接只能在模拟器中工作,不能在实际设备上工作,swift,xcode,firebase,firebase-dynamic-links,Swift,Xcode,Firebase,Firebase Dynamic Links,动态链接过去在实际设备上和模拟器中都工作良好。当我在模拟器中单击链接(或将其粘贴到safari中)时,我会被重定向到“.page.link”站点,其中显示“打开”-然后单击“打开”将完美地打开应用程序。然而,如果我在我的实际设备上重复相同的步骤,我会被重定向到支持url,并且什么也不会发生(即使我的手机上安装了应用程序,它也不会打开) 这是我在其中显示url的代码 if let uid = Auth.auth().currentUser?.uid { guard let

动态链接过去在实际设备上和模拟器中都工作良好。当我在模拟器中单击链接(或将其粘贴到safari中)时,我会被重定向到“.page.link”站点,其中显示“打开”-然后单击“打开”将完美地打开应用程序。然而,如果我在我的实际设备上重复相同的步骤,我会被重定向到支持url,并且什么也不会发生(即使我的手机上安装了应用程序,它也不会打开)

这是我在其中显示url的代码

if let uid = Auth.auth().currentUser?.uid {
            guard let link = URL(string: "https://www.testapp.com/uid=" + uid) else {
                return
            }
            let dynamicLinksDomain = "testapp.page.link"
            let linkBuilder = DynamicLinkComponents(link: link, domain: dynamicLinksDomain)
            linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.burgertralla.theGreat")
            linkBuilder.shorten { (url, _, _) in
                if let url = url {
                  self.shareTopLabel.text = url.absoluteString
                }
            }
        }
这是我的AppDelegate:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
            self.handleIncomingDynamicLink(dynamicLink: dynamicLink)
            return true
        }
        return false
    }

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
        if let incomingUrl = userActivity.webpageURL {
            let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingUrl, completion: { (dynamicLink, _) in
                if let dynamicLink = dynamicLink, let _ = dynamicLink.url {
                    self.handleIncomingDynamicLink(dynamicLink: dynamicLink)
                }
            })

            if linkHandled {
                return linkHandled
            }
        }
        return false
    }

    func handleIncomingDynamicLink(dynamicLink: DynamicLink) {
        guard let pathComponents = dynamicLink.url?.pathComponents else {
            return
        }
        for pathComponent in pathComponents {
            if pathComponent.contains("uid=") {
                let uid = pathComponent.drop(prefix: "uid=")
                Database.database().reference(withPath: "profile/" + uid).observeSingleEvent(of: .value) { (snapshot) in
                    if snapshot.exists(), var data = snapshot.value as? [String: Any] {
                        data["uid"] = snapshot.key
                        let userProfileVC = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "UserProfileViewController") as! UserProfileViewController
                        if let tabBarVc = self.window?.rootViewController as? UITabBarController {
                            tabBarVc.selectedIndex = 1
                            if let discoveryVC = tabBarVc.viewControllers?[1] as? UINavigationController {
                                userProfileVC.selectedUser = data
                                discoveryVC.pushViewController(userProfileVC, animated: true)
                            }
                        }
                    }
                }
            }
        }
    }
有人知道这里发生了什么事吗

谢谢大家的帮助:)


编辑:它在我的iPhone上使用Chrome确实有效,但在Safari上不起作用。我不知道为什么…

@Popmedic谢谢,这让我在iPhone上下载了chrome,这个链接在我的chrome设备上运行。但是它不适用于Safari。。。(我读了关于stackoverflow的问题,但似乎没有任何效果)你有什么进展吗?我们看到了同样的问题。可以在模拟器上使用Safari,但不能在物理设备上使用Safari(没有尝试Chrome)。在尝试使用动态链接打开应用程序时也会遇到同样的问题。它在模拟器中工作正常,但在实际设备上重定向到Safari,动态链接页面无效