Firebase Dynamic Links in flutter seems to recognize it was opened through a link but the link is always null

Viewed 784

I'm using dynamic links ^0.7.0+1 When I press the link it loads the app, but doesn't navigate to the page I wanted, I've printed the link I receive, and it's always null, both when the app is in the background or not running at all.

  Future<void> retrieveDynamicLink(BuildContext context) async {
    List<String> linkData;
    print('in retrieve link');

    final PendingDynamicLinkData data =
          await FirebaseDynamicLinks.instance.getInitialLink();
    _handleDynamicLink(data);

    FirebaseDynamicLinks.instance.onLink(
          onSuccess: (PendingDynamicLinkData dynamicLink) async {
        linkData = await _handleDynamicLink(dynamicLink);
    }, onError: (OnLinkErrorException e) async {
      print('onLinkError');
      print(e.message);
    });

    if (data != null) {
      AppRoutes.pushLinkEntryPage(
        context: context, spreadsheetId: linkData[0], grade: linkData[1]);
    }
  }

  static Future<List<String>> _handleDynamicLink(
        PendingDynamicLinkData data) async {
    String ssId = '';
    String grade = '';

    final Uri deepLink = data?.link;
    print('deepLink = $deepLink');
    if (deepLink == null) {
      return null;
    }

    if (deepLink.queryParameters.containsKey('ss')) {
      ssId = deepLink.queryParameters['ss'];
      print('in retrieve link: ssID = $ssId');
    }
    if (deepLink.queryParameters.containsKey('gd')) {
      grade = deepLink.queryParameters['gd'];
      print('in retrieve link: gd = $grade');
    }

    return [ssId, grade];
  }
1 Answers

I wasted couple of hours on this, and found the fix to be using the "Long dynamic link" instead of the "Deep link".

See attached image below:(This show details of the dynamic link in console) enter image description here

Related