简体   繁体   English

Firebase flutter 中的动态链接似乎可以识别它是通过链接打开的,但链接始终是 null

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

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.我正在使用动态链接 ^0.7.0+1 当我按下链接时,它会加载应用程序,但没有导航到我想要的页面,我已经打印了收到的链接,并且它始终是 null,当应用程序在后台或根本没有运行。

  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];
  }

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)请参阅下面的附图:(这显示了控制台中动态链接的详细信息) 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 处理链接并使用 flutter 中的 firebase 动态链接导航 - handle link and navigate with firebase dynamic links in flutter Flutter 上的 Firebase 动态链接 - Firebase Dynamic Link on Flutter flutter firebase 动态链接 - 在应用程序中捕获了错误的链接 - flutter firebase dynamic links - wrong link is captured in app flutter + firebase 无密码 email 登录-动态链接数据返回 null - flutter + firebase passwordless email login - dynamic link data returns null Flutter firebase 动态链接在应用程序上处理 url 时使用自定义参数自定义链接 - Flutter firebase dynamic links customise link with custom params when handling url on the app 带有 Flutter 的 Firebase 动态链接在创建链接时自动删除自定义 QueryParameters - Firebase Dynamic Links with Flutter Automatically Removing Custom QueryParameters while link is being created firebase 存储的图像链接返回 null - Flutter - Image link of firebase storage is returning null - Flutter Firebase 与 flutter 动态链接:深层链接 URL 未打开应用程序 - Firebase dynamic link with flutter: Deep link URL doesnt open app Flutter iOS Firebase 带链接值的动态链接推送命名页面 - Flutter iOS Firebase dynamic link push named page with the link value 为什么以编程方式创建的动态链接没有列在 Firebase 控制台的“动态链接”中? - Why dynamic link created programmatically is not listed in "Dynamic Links" of Firebase Console?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM