Firebase iOS / Swift and Deep Links

2019-07-19 03:51发布

问题:

We have just integrated firebase, and all of a sudden our deep links are no longer working. We're using AppAuth for authentication, so we're reliant on deep links to direct us to the right place. I'm getting the following error:

<Debug> [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {...}

Initialization of firebase as follows:

let bundleId = Bundle.main.bundleIdentifier
let filePath = Bundle.main.path(forResource: "GoogleService-Info-" + bundleId!, ofType: "plist")!
let options = FIROptions(contentsOfFile: filePath)
FIRApp.configure(with: options!)

And here's the deep linking functions:

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
        return application(app, open: url, sourceApplication: nil, annotation: [:])
    }

    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        if url.host == AppHost.deeplink {
        ...
   }

If i remove the call to FIRApp.configure, everything in the app works fine. My AppAuth redirects flow into the function above without any issue. However, with the call to configure(), it never gets into either one of the functions. As a result, i can't do a token exchange and complete authentication.

I suspected the AppDelegate proxy might be the issue, so i tried disabling it in the plist file. I've validated that the plist file passed to FIRApp.configure has the appropriate keys:

<key>FirebaseAppDelegateProxyEnabled</key>
<false/>

But no matter what i do, it's still activating the proxy:

[Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist

I'm using only FirebaseCrash and FirebaseCore (and FirebaseAnalytics indirectly through crash)

回答1:

Instead of adding the FirebaseAppDelegateProxyEnabled key to the GoogleServices-Info.plist, add it to your App's info.plist. The Google Services plist should not be modified once it's generated.

As for disabling the proxy, it's fine to do this long term. The proxy is a convenience thing (it's just swizzling some methods), and you can reimplement it manually. There's some examples here of how to handle the lack of the proxy (non-swizzling case).