3

I created the DynamicLink for my firebase project when I am trying to receive the link I am getting "That's weird. My dynamic link object has no url".

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        if let incomingURL = userActivity.webpageURL{
                   print("Incoming URL is \(incomingURL)")
                   let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL)
                   {(dynamicLink, error) in
                       guard error == nil else{
                           print("Found an error! \(error!.localizedDescription)")
                           return
                       }
                       if let dynamicLink = dynamicLink{
                        self.handleIncomingDynamicLink(dynamicLink)
                       }
                   }
                   if linkHandled{
                       return true

                   }
                   else{
                       return false
                   }
               }
               return false
    }


 func handleIncomingDynamicLink(_ dynamicLink: DynamicLink){
        guard let url = dynamicLink.url else{
            print("That's weird. My dynamic link object has no url")
            return
        }
        print("Your incoming link parameter is\(url.absoluteString)")
}
5
  • I am facing similar issues, mine works during debug but is nil when I make a release build, did you find out a solution? Commented Dec 26, 2019 at 8:28
  • same problem here did anyone found any solution, please. Commented Mar 4, 2020 at 8:01
  • did you find out any solution ? Commented Mar 25, 2020 at 12:00
  • did anyone found any solution? Please update here. Commented May 8, 2020 at 10:20
  • @Madhuri Doppalapudi any solutions ? Commented May 8, 2020 at 10:26

2 Answers 2

4

After checking all the blogs and posted this issue on firebase, I didn't find any solution for this but I came up with this concrete solution and it will work definitely


here: dynamicLinkURL is your main dynamic link and shortHandURL is your deeplink URL which is associated with your dynamic link. I hope the below snippet will help you.


func dynamicLinkhandler(_ dynamicLinkURL: URL, onCompletion: @escaping(_ success: Bool) -> Void) {
    URLSession.shared.dataTask(with: dynamicLinkURL) { (data, response, error) in
        guard error == nil else {
            print("Found Error \(String(describing: error?.localizedDescription)))")
            return
        }
        guard let shortHandURL = response?.url, shortHandURL != dynamicLinkURL else {
            print("Thats Weird, my dynamic link has no URL")
            onCompletion(false)
            return
        }
        onCompletion(true)
    }.resume()
}
Sign up to request clarification or add additional context in comments.

Comments

0

Double check that the bundle id you set up in the dynamic link wizard creation within the firebase console it's the one you are running the app into.

I have three different bundle ids (dev, enterprise, production) and, for instance, if a set in the link the production bundle id but the app runs the dev bundle id, instead of returning back some error it returned an honest dynamicLink object but with a nil value in the url.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.