简体   繁体   中英

flutter firebase deeplinks params not getting

I am creating a flutter application. I am using Deeplink. It is creating success but the clicking part of the app not working well. The app is retrieving the url but not retrieving the params. I don't know what is the reason? My codes are shown below.

    final DynamicLinkParameters parameters = DynamicLinkParameters(
    uriPrefix: 'https://mydomain.page.link',
    link: Uri.parse(
        // 'https://pachiradev.page.link/circleinvite?token=' + uid1.toString()
        'https://pachiradev.page.link/circleinvite?token=' + '1234'),
    androidParameters: AndroidParameters(
        packageName: 'io.flutter.plugins.firebasedynamiclinksexample',
        minimumVersion: 0,
    ),
    dynamicLinkParametersOptions: DynamicLinkParametersOptions(
        shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
    ),
    iosParameters: IosParameters(
        bundleId: 'com.google.FirebaseCppDynamicLinksTestApp.dev',
        minimumVersion: '0',
    ),
    );

    Uri url;

  final ShortDynamicLink shortLink = await parameters.buildShortLink();
  url = shortLink.shortUrl;

    print(url)

    //https://mydomain.page.link/circleinvite?token=1234
    //https://mydomain.page.link/ARTu

Here I printing the url with params. But in retrieving code I am not getting params

    FirebaseDynamicLinks.instance.onLink(
        onSuccess: (PendingDynamicLinkData dynamicLink) async {
    final Uri deepLink = dynamicLink?.link;


    print(deepLink);
      //https://mydomain.page.link/circleinvite
      //not showing params

    if (deepLink != null) {
        // Navigator.pushNamed(context, deepLink.path);
        final queryParams = deepLink.queryParameters;
        if (queryParams.length > 0) {
        String token = queryParams["token"];

        }
    }
    }, onError: (OnLinkErrorException e) async {
    print('onLinkError');
    print(e.message);
    });

I tried several way but no results. If anyone know the reason please help me.

I found that we need to put proper app package name.

    androidParameters: AndroidParameters(
            packageName: 'com.myapp.android',
            minimumVersion: 0,
        ),
        dynamicLinkParametersOptions: DynamicLinkParametersOptions(
            shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
        ),
        iosParameters: IosParameters(
            bundleId: 'com.myapp.ios',
            minimumVersion: '0',
        ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM