Flutter中的Firebase Dynamic Link问题

qpgpyjmq  于 2023-10-22  发布在  Flutter
关注(0)|答案(1)|浏览(140)

这是创建的动态链接,同时创建动态链接。https://xyz.page.link/r?id=ABCDEFG
但是,问题是,当我试图阅读动态链接使用

PendingDynamicLinkData? data = await FirebaseDynamicLinks.instance.getInitialLink();
String url = data?.link.toString();

它只给我不完整的URL,而不是参数。https://xyz.page.link/r
使用firebase_dynamic_links:^5.0.11

ej83mcc0

ej83mcc01#

创建firebase动态链接时,需要在deep link字段中提供查询参数。在你的例子中,我可以看到你在动态链接本身中提供了id=ABCDEFG。Dynamic link Step
Deeplink Step
https://xyz.page.link/r?id=ABCDEFG你应该在deeplink字段中插入这个。希望这对你有帮助。
您可以使用代码Dynamic link Package创建动态链接

Future<String> generateDynamicLink( {
    String? title,
    String? description,
    Uri? thumbnail,
  }) async {
    FirebaseDynamicLinks dynamicLinks = FirebaseDynamicLinks.instance;

    final DynamicLinkParameters parameters = DynamicLinkParameters(
      // uriPrefix: dynamicLinkPrefix,
      uriPrefix: "https://xyz.page.link",
      link: Uri.parse("https://xyz.page.link/r?id=ABCDEFG"),
      androidParameters: AndroidParameters(
        packageName:"your package name",
      ),
      googleAnalyticsParameters: const GoogleAnalyticsParameters(
        source: "your source",
        medium: "your medium",
        campaign: "none",
      ),
      iosParameters: IOSParameters(
        appStoreId: appstoreId,
        bundleId:"iosBundleId",
      ),
      socialMetaTagParameters: thumbnail != null
          ? SocialMetaTagParameters(
              imageUrl: thumbnail,
              title: title,
              description: description,
            )
          : null,
    );
    final ShortDynamicLink shortLink =
        await dynamicLinks.buildShortLink(parameters);
    Uri uri = shortLink.shortUrl;
    return uri.toString();
  }

相关问题