0

I'm currently working on implementing Firebase Dynamic Links in my Flutter app, and I've encountered an issue with retrieving query parameters from the dynamic link when the app is opened using the link.

I have a function called createDynamicLink that creates a dynamic link, and I use the initDynamicLink function in the main to listen for dynamic links when the app is opened. However, even though the link is not null, the query parameter called 'student' is always coming out as null.

String uriPrefix = 'https://example.page.link';
  Future<String> createDynamicLink() async {
    String appLink = 'https://example.page.link/zEgN?student=test';
    final DynamicLinkParameters parameters = DynamicLinkParameters(
        link: Uri.parse(appLink),
        uriPrefix: uriPrefix,
        androidParameters:
            AndroidParameters(packageName: 'package.name'));

    final FirebaseDynamicLinks link = FirebaseDynamicLinks.instance;
    final refLink = await link.buildLink(parameters);

    return refLink.toString();
  }

  Future<void> initDynamicLink() async {
    final PendingDynamicLinkData? initialLink =
        await FirebaseDynamicLinks.instance.getInitialLink();
    print("DEEP LINK INITIAL $initialLink");

    FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) async {
      final Uri? deepLink = dynamicLinkData.link;
      final PendingDynamicLinkData? initialLink =
          await FirebaseDynamicLinks.instance.getInitialLink();
      print("DEEP LINK INITIAL ON LISTEN  ${initialLink}");
      Share.share(' 5555 ${initialLink?.link}');
      print(
          "DEEP QUERY PARAMETER ON LISTEN ${dynamicLinkData.link.queryParameters['student']}");
      print("DEEP LINK ON LISTEN ${dynamicLinkData.link}");
    });

The issue is that the query parameter 'student' is always null, even though the deep link itself is not null.

I've double-checked the link creation, and it seems to be correct. Does anyone know why the query parameter is not being retrieved correctly?

  1. Manually Verified Dynamic Link on Firebase Console
  2. Confirmed Link Creation in Code
  3. Tested Dynamic Link on Physical Device:

1 Answer 1

0

FYI Firebase dynamic link is depracated and will be shutdown on August 25, 2025

Can you try this and tell me what is printed?

Future<void> initDynamicLink() async {
    final PendingDynamicLinkData? initialLink =
        await FirebaseDynamicLinks.instance.getInitialLink();

    var deepLink = initialLink?.link;
    final queryParams = deepLink?.queryParameters;

    print("deepLink $deepLink queryParams $queryParams ");

    if (queryParams != null) {
      final params = queryParams["student"]!;

      FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) async {
        var deepLink = dynamicLinkData.link;
        print('DynamicLinks onLink $deepLink');
        Share.share(' 5555 $deepLink');
      }, onError: (e) async {
        print('DynamicLinks onError $e');
      });
    } else {
      print('no query params');
    }
  }

Hope it will help you to debug

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.