ios – `open URL` is not getting called with Firebase Dynamic Links

0
28

[ad_1]

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { } is not getting called in iOS when we click on Firebase Dynamic Link.

I have implemented

// AppDelegate

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    let googleHandled = GIDSignIn.sharedInstance.handle(url)
    let facebookHandled = ApplicationDelegate.shared.application(app,
                                                                 open: url,
                                                                 sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                                                 annotation: options[UIApplication.OpenURLOptionsKey.annotation])
    let firebaseHandled = application(app,
                                      open: url,
                                      sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                      annotation: "")
    return googleHandled || facebookHandled || firebaseHandled
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { dynamicLink, error in
        print("APPDELEGATE_USER_ACTIVITY", dynamicLink?.url?.absoluteString ?? "")
    }
    return handled
}

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
        // Handle the deep link. For example, show the deep-linked content or
        // apply a promotional offer to the user's account.
        // ...
        return true
    }
    return false
}

// SceneDelegate

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let url = URLContexts.first?.url else {
        return
    }

    ApplicationDelegate.shared.application(
        UIApplication.shared,
        open: url,
        sourceApplication: nil,
        annotation: [UIApplication.OpenURLOptionsKey.annotation]
    )
}

and added FirebaseAppDelegateProxyEnabled to NO as well. But nothing worked. My app is opening on click of dynamic link, but for internal navigation inside app, I need details.

[ad_2]