'FirebaseDynamicLinks.instance.getInitialLink() always returning null on Android

I'm using firebase_dynamic_links for passwordless login with firebase and getInitialLink() is always returning null on version 0.5.0+8. If I use version 0.4.0+4 and retrieveDynamicLink() instead of getInitialLink() it works fine.

Since it's working in version 0.4.0+4 I assume the problem is not on Firebase settings. This is how I'm sending the email:

final FirebaseAuth user = FirebaseAuth.instance;
    try {
      user.sendSignInWithEmailLink(
          email: _email,
          androidInstallIfNotAvailable: true,
          iOSBundleID: "com.mydomain.myappname",
          androidMinimumVersion: "16",
          androidPackageName: "com.mydomain.myappname",
          url: "https://myAppName.page.link/fJc4",
          handleCodeInApp: true);
    } catch (e) {
      _showDialog(e.toString());
      return false;
    }

And then to retrieve it:

@override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) {
      _retrieveDynamicLink();
    }
  }

  Future<void> _retrieveDynamicLink() async {
    final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
    print('data == ' + data.toString());

    final Uri deepLink = data?.link;
    print(deepLink.toString());

    if (deepLink != null) {
      _link = deepLink.toString();
      _signInWithEmailAndLink();
    }
    return deepLink.toString();
  }

data is always null on the new version with getInitialLink(). It works on the previous version with retrieveDynamicLink().

I created a new project just to test it and the problem persists. The only other change I made to the project, besides the view files was add firebase_auth: ^0.15.0+1 to pubspc.yaml

Doctor summary (to see all details, run flutter doctor -v): [√]

Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [Version 10.0.17763.864], locale pt-BR)

[√] Android toolchain - develop for Android devices (Android SDKversion 28.0.3)

[√] Android Studio (version 3.5)

[!] VS Code (version 1.40.0) X Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (1 available)

! Doctor found issues in 1 category.

Any help is appreciated.



Solution 1:[1]

please you may use this plugin instead app_links

because firebase_dynamic_links has bugs at the moment.

Solution 2:[2]

ensure that you get started dynamic link in firebase projectenter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohammed_7aafar
Solution 2 Abdelrahman Mohamed Elakliby