iOS- 如何使用自定义参数获取动态短链接 firebase

iOS- how to get dynamic short links with custom parameters firebase

我想通过动态发送参数 link 并接收同样的参数。

我已经通过我的短动态link传递了自定义参数。这是我的 link:https://pc988.app.goo.gl/vQaV?test=1

我正在使用以下代码接收动态 link:

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

    }
    else{
        let handled = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options)

        return handled
    }
}

@available(iOS 8.0, *)
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    if let incomingURL = userActivity.webpageURL{
        let linkHandled = DynamicLinks.dynamicLinks()!.handleUniversalLink(incomingURL, completion:{ [weak self] (dynamiclink, error) in
            guard let strongSelf = self else{ return }
            if let dynamiclink = dynamiclink, let _ = dynamiclink.url {
                strongSelf.handleIncomingDynamicLink(dynamicLink: dynamiclink)
            }
        })
        return linkHandled
    }
    return false
}

func handleIncomingDynamicLink(dynamicLink: DynamicLink) {

    if dynamicLink.matchConfidence == .weak{
    }else {
        guard let pathComponents = dynamicLink.url?.pathComponents else { return }
        for nextPiece in pathComponents{

        }
    }
    print("incoming link \(dynamicLink.url)")
}

我的确切问题是,我无法获取我在上面提到的动态短 link 中传递的 'test' 参数。

帮我解决这个问题。

要追加自定义参数,您需要将参数追加到深度 link,而不是动态 link。

在您的示例中,深度 link 是 https://www.fitview.com/ (you can see this in debug page https://pc988.app.goo.gl/vQaV?d=1)。

要实现您的目标,请将深度 link 设置为 https://www.fitview.com?test=1,创建动态 link,然后缩短动态 link.