I'm currently working on implementing Firebase Dynamic Links in my Flutter app, and I've encountered an issue with retrieving query parameters from the dynamic link when the app is opened using the link.
I have a function called createDynamicLink that creates a dynamic link, and I use the initDynamicLink function in the main to listen for dynamic links when the app is opened. However, even though the link is not null, the query parameter called 'student' is always coming out as null.
String uriPrefix = 'https://example.page.link';
Future<String> createDynamicLink() async {
String appLink = 'https://example.page.link/zEgN?student=test';
final DynamicLinkParameters parameters = DynamicLinkParameters(
link: Uri.parse(appLink),
uriPrefix: uriPrefix,
androidParameters:
AndroidParameters(packageName: 'package.name'));
final FirebaseDynamicLinks link = FirebaseDynamicLinks.instance;
final refLink = await link.buildLink(parameters);
return refLink.toString();
}
Future<void> initDynamicLink() async {
final PendingDynamicLinkData? initialLink =
await FirebaseDynamicLinks.instance.getInitialLink();
print("DEEP LINK INITIAL $initialLink");
FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) async {
final Uri? deepLink = dynamicLinkData.link;
final PendingDynamicLinkData? initialLink =
await FirebaseDynamicLinks.instance.getInitialLink();
print("DEEP LINK INITIAL ON LISTEN ${initialLink}");
Share.share(' 5555 ${initialLink?.link}');
print(
"DEEP QUERY PARAMETER ON LISTEN ${dynamicLinkData.link.queryParameters['student']}");
print("DEEP LINK ON LISTEN ${dynamicLinkData.link}");
});
The issue is that the query parameter 'student' is always null, even though the deep link itself is not null.
I've double-checked the link creation, and it seems to be correct. Does anyone know why the query parameter is not being retrieved correctly?
- Manually Verified Dynamic Link on Firebase Console
- Confirmed Link Creation in Code
- Tested Dynamic Link on Physical Device: