firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

DynamicLinks does not support SwiftUI App Life Cycle

Open pokryfka opened this issue 4 years ago • 5 comments

Feature proposal

  • Firebase Component: DynamicLinks

Starting from iOS14 it is possible to create app without AppDelegate:

import SwiftUI

@main
struct MyApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
         .onOpenURL { url in
           // handle URL
        }
    }
  }
}

This works well with Universal Links which can be parsed and handled by Firebase DynamicLinks. ~~However links retrieved from Pasteboard are not properly forwarded, even with @UIApplicationDelegateAdaptor.~~

This also works for links retrieved from Pasteboard if @UIApplicationDelegateAdaptor is not implemented, which is contrary to DynamicLinks.performDiagnostics() error:

ERROR: UIApplication delegate <SwiftUI.AppDelegate: 0x600001f85620> does not implements selector application:openURL:options:. FDL depends on this implementation to retrieve pending dynamic link.

Please add official support and document how to integrate DynamicLinks with SwiftUI app.

Please consider extending the interface and allow to check the result of link retrieval, for example:

let link = try DynamicLinks.dynamicLinks().retrievePendingDynamicLink()

pokryfka avatar Feb 22 '22 02:02 pokryfka

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Feb 22 '22 02:02 google-oss-bot

@andrewheard Any insights?

paulb777 avatar Aug 19 '22 22:08 paulb777

Also ran into that issue. Would be great if at least the documentation could be adapted.

pkurzok avatar Sep 02 '22 11:09 pkurzok

Hi, I faced the same issue and these are the things I found so far.

onOpenUrl works fine if the app is already installed. But if the app is not installed, the users will download the app from the App Store and one open the app by clicking "Open" in the App Store page.

First of all, the library successfully fetch the url from - (NSString *)retrievePasteboardContents but fails to pass this url to AppDelegate because the library tries to open the url using - (void)passRetrievedDynamicLinkToApplication:(NSURL *)url method but it fails due to there is no AppDelegate.

I tried to implement @UIApplicationDelegateAdaptor and func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool but it still fails to call this method under AppDelegate

OnurVar avatar Sep 21 '22 16:09 OnurVar

The reason for this failure is the SwiftUI -> Objective-C swizzling interop which is a bit incompatible with the current implementation of Firebase swizzling. I recommend disabling swizzling and adjust your codebase to take that into consideration (under each module integration tutorial there is a section which tells you what to do if you disable swizzling) and it should work. At least this is what has fixed it for me.

fabrizioCorut avatar Oct 28 '22 11:10 fabrizioCorut

Now that Firebase DynamicLinks is planned to shut down, closing its feature requests.

paulb777 avatar Jul 11 '23 03:07 paulb777