简体   繁体   中英

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

I want to send parameter through dynamic link and also to receive the same.

I have passed the custom parameter through my short dynamic link. Here is my link: https://pc988.app.goo.gl/vQaV?test=1

And I am using the following code to receive the dynamic 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)")
}

And my exact problem was, I cannot get the 'test' parameter that I passed in dynamic short link which I mentioned above.

Help me to get rid off this problem.

To append custom parameter you need to append the parameter to the deep link, not to the dynamic link.

In your example the deep link is https://www.fitview.com/ (you can see this in debug page https://pc988.app.goo.gl/vQaV?d=1 ).

To accomplish your goal, set the deep link to https://www.fitview.com?test=1 , create dynamic link, and then shorten dynamic link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM