firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.66k stars 1.49k forks source link

After switching to SwiftUI App, the dynamic link does not work when the app is in the background #11822

Closed greatsk55 closed 1 year ago

greatsk55 commented 1 year ago

Description

I recently raised the minimum deployments to 14. Therefore, we migrated our app to comply with the App protocol.

I wrote it like the code below Running a Firebase dynamic link when the app is in the background does not perform any logic.

Has anyone solved this problem?

App.swift

@main struct MyApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @Environment(.scenePhase) var scenePhase

var body: some Scene {
    WindowGroup {
        SplashView()
            .onOpenURL { url in
                print("onOpenURL")
            }.onContinueUserActivity("name") { activity in
                print("name \(activity.description)")
            }
    }
}

} SceneDelegate.swift

class SceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    ~~
}

func scene(
    _ scene: UIScene,
    willConnectTo session: UISceneSession,
    options connectionOptions: UIScene.ConnectionOptions
) {
    ~~
}

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
    ~~
}

} AppDelegate.swift

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { ~~ }

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { ~~
}

func application(_ application: UIApplication, open url: URL, sourceApplication: String?,annotation: Any) -> Bool { ~~ } I recently raised the minimum deployments to 14. Therefore, we migrated our app to comply with the App protocol.

I wrote it like the code below Running a Firebase dynamic link when the app is in the background does not perform any logic.

Has anyone solved this problem?

App.swift

@main struct MyApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @Environment(.scenePhase) var scenePhase

var body: some Scene {
    WindowGroup {
        SplashView()
            .onOpenURL { url in
                print("onOpenURL")
            }.onContinueUserActivity("name") { activity in
                print("name \(activity.description)")
            }
    }
}

} SceneDelegate.swift

class SceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    ~~
}

func scene(
    _ scene: UIScene,
    willConnectTo session: UISceneSession,
    options connectionOptions: UIScene.ConnectionOptions
) {
    ~~
}

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
    ~~
}

} AppDelegate.swift

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { ~~ }

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { ~~
}

func application(_ application: UIApplication, open url: URL, sourceApplication: String?,annotation: Any) -> Bool { ~~ }

Reproducing the issue

No response

Firebase SDK Version

10.15

Xcode Version

14.3.1

Installation Method

Swift Package Manager

Firebase Product(s)

DynamicLinks

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
```json Replace this line with the contents of your Package.resolved. ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

rizafran commented 1 year ago

Please note that the Firebase Dynamic Links service will be shutdown on August 25, 2025. In the meantime, only critical or security issues will be fixed in the SDK.

More at https://firebase.google.com/support/dynamic-links-faq