singular-labs / Singular-Flutter-SDK

MIT License
4 stars 13 forks source link

There is a conflict between SingularLink and Firebase DynamicLink on iOS #27

Closed 9oya closed 1 year ago

9oya commented 1 year ago

After adding the below code block for SingularLink(singular_flutter_sdk: ^1.0.12) in the iOS AppDelegate, my Firebase Dynamic Links (firebase_dynamic_links: 5.0.11) stopped working. Removing the code block restores Firebase Dynamic Link functionality, but causes issues with SingularLink.

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

    // Singular
    if let singularAppDelegate = SingularAppDelegate.shared() {
        singularAppDelegate.continueUserActivity(userActivity, restorationHandler: nil)
    }

   return true
}

[✓] Flutter (Channel stable, 3.3.10, on macOS 13.2.1 22D68 darwin-arm, locale en-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2)
[✓] Connected device (5 available)
[✓] HTTP Host Availability
9oya commented 1 year ago

I fixed this issue by adding the following code

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

    // Singular
    if let singularAppDelegate = SingularAppDelegate.shared() {
        singularAppDelegate.continueUserActivity(userActivity, restorationHandler: nil)
    }

    if userActivity.webpageURL?.path.contains("sng.link") ?? false {
        return true
    }
    return super.application(application, continue: userActivity, restorationHandler: restorationHandler);
}
jzviaginSingular commented 1 year ago

Hi , @9oya thanks for the proposition :) We updated our flutter integration docs at: Singular Flutter SDK

The solution is to call return super.application(application, continue: userActivity, restorationHandler: restorationHandler); in any case, even if the URL does not contain "sng.link".

Please keep in mind that not all singular links contain "sng.link" in them