firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.71k stars 3.97k forks source link

🐛 [DYNAMIC_LINK] Android don't keep the link after installation #11911

Closed arnair closed 11 months ago

arnair commented 11 months ago

Bug report

Describe the bug

On android if the app is installed from the store after clicking the deep link it will not get the value.

It works well on IOS ! I tried on the android simulator pressing a button to lunch the url and it open a web and it go back to the app and it works.

Steps to reproduce

Steps to reproduce the behavior:

  1. Added the code to the main androidmanifest
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:host="myname.page.link" android:scheme="http"/>
        <data android:host="myname.page.link" android:scheme="https"/>
      </intent-filter>
        </activity>
  2. I added this code to the first page it opens (It works on IOS)
    @override
    void initState() {
    super.initState();
    initDynamicLinks();
    }
    void initDynamicLinks() async {
    FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) {
      affiliatedUid = dynamicLinkData.link.pathSegments.first;
      ref.read(loginScreenControllerProvider.notifier).affiliatedUid =
          affiliatedUid;
    }).onError((error) {
      // print("We got error $error");
    });
    }

Expected behavior

I want to maintain the url to extract a code after a new installation in Android

Flutter doctor

[✓] Flutter (Channel stable, 3.13.2, on macOS 14.0 23A344 darwin-arm64, locale en-ES) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.1) [✓] VS Code (version 1.84.2) [✓] Connected device (3 available) [✓] Network resources

Flutter dependencies

firebase_dynamic_links: ^5.4.4

danagbemava-nc commented 11 months ago

Hi @arnair, can you try using a package like uni_links to see if the url is still preserved after the installation from the store? Android and iOS handle deep links differently so this may be why it works for iOS but not android