Search code examples
flutterfirebasedartdeep-linkingfirebase-dynamic-links

Issue with Firebase Dynamic Link in Flutter


This is the created dynamic link, while dynamic link creation. https://xyz.page.link/r?id=ABCDEFG

But, the problem is when I'm trying to read dynamic link using

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

It's giving me incomplete URL only, not the parameters i.e. https://xyz.page.link/r

I'm using firebase_dynamic_links: ^5.0.11


Solution

  • You should provide query parameters in deep link field while creating firebase dynamic link. Here in your example I can see you have provided id=ABCDEFG in dynamic link itself. Dynamic link Step

    Deeplink Step

    https://xyz.page.link/r?id=ABCDEFG you should insert this in deeplink field. Hope this will help you.

    You can create dynamic link using code 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();
      }