Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase dynamicLink not working from cold start - Xcode 11, iOS 13

If you launch your app directly from the dynamic link (and assuming your app is not already running in the background) then application:continueUserActivity is not called.

In the past, we used to rely on the application:didFinishLaunchingWithOptions however as of iOS13 and Xcode 9, that doesn't work anymore. Now when you launch the app from a dynamicLink, the launchOptions is nil and so this doesn't work anymore (An example of this solution that does NOT work anymore is here: https://stackoverflow.com/a/46722785/6553577 )

Does anyone know how to deal with this issue? (Thanks for your response)

like image 315
MegaMaziar Avatar asked Jul 11 '26 19:07

MegaMaziar


1 Answers

Thanks to Matt, and following his suggestion to use scene delegate, I was able to get this to work. For reference, and to help friends from spending hours on this, here is my swift code: (This is tested on iOS v13.3, with Xcode v11.3 and Firebase iOS SDK v6.14.0)

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let _ = (scene as? UIWindowScene) else { return }

        if let userActivity = connectionOptions.userActivities.first {
            if let incomingURL = userActivity.webpageURL {
                _ = DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL) { (dynamicLink, error) in
                    guard error == nil else { return }
                    if let dynamicLink = dynamicLink {
                    //your code for handling the dynamic link goes here
                    }
                }
            }
        }
    }
like image 51
MegaMaziar Avatar answered Jul 13 '26 11:07

MegaMaziar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!