Using Flutter Firebase Dynamic Links, users get the best experience for the platform they open dynamic links on.
These are the URLs through which we can directly guide the user to any page within Android and iOS applications by a single click.
If a user opens a dynamic link in the browser, they can be redirected to parallel content on your website.
Flutter Firebase Dynamic links work across applications installed on your platform.
If a user opens Firebase Dynamic Links on the Android/iOS platform and doesn’t have your app installed, the user can be redirected to Playstore or AppStore to install it and then, the app starts and the user can access it.
Tech Stack We’re using:
Tools We’re using:
Inside pubspec.yaml add the following plugin under dependencies and run flutter pub get in the terminal.
dependencies:
firebase_dynamic_links: latest
Enter the Project name and click the “Continue” button.
Enter package name that can be found in you project/android/app/build.gradle
After successfully adding google-services.json inside android/app, add Firebase Sdk to build.gradle.
Here firebase will automatically provide some domains. You can edit the domain as you like and click the “Continue” button.
You can edit that or keep it as it is and click the “Next” button.
Then the user will be redirected to the play store. Enter “Dynamic Link name”.
If not, select another option.
Select “Open the deep link in your Android App” and click the Next button.
If you want to open app directly without being redirected to the browser, add the following lines of code inside android/app/src/main/AndroidManifest.xml
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
<data
android:scheme="https"
android:host="https://itoneclick.page.link" />
</intent-filter>
To create a dynamic link we have to add title, image and itemId.
Here I have added “id = itemId” after the link to identify specific items while handling dynamic links.
Future createDynamicLink(
BuildContext context,
String title,
String image,
String itemId,
) async {
bool short = true;
final DynamicLinkParameters parameters = DynamicLinkParameters(
//add urlPrefix as per point 3.2
uriPrefix: 'https://itoneclick.page.link',
//add link as per point 4.7
link: Uri.parse('https://itoneclick.page.link/testing/?id=$itemId'),
androidParameters: AndroidParameters(
//android/app/build.gradle
packageName: 'android package name',
minimumVersion: 0,
),
socialMetaTagParameters:
SocialMetaTagParameters(title: title, imageUrl: Uri.parse(image)),
dynamicLinkParametersOptions: DynamicLinkParametersOptions(
shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
),
iosParameters: IosParameters(
bundleId: 'ios bundleId',
minimumVersion: '0',
),
);
Uri url;
if (short) {
final ShortDynamicLink shortLink = await parameters.buildShortLink();
url = shortLink.shortUrl;
} else {
url = await parameters.buildUrl();
}
return url.toString();
}
To receive a firebase dynamic link call, getInitiaLink().
getInitiaLink() will return the URL that opened the app, otherwise, it will return null.
If the dynamic link is not null you can use the navigator inside the following method.
Future<void> initDynamicLinks() async {
FirebaseDynamicLinks.instance.onLink(
onSuccess: (PendingDynamicLinkData dynamicLink) async {
final Uri deepLink = dynamicLink.link;
if (deepLink != null) {
//We have added id parameter while creating dynamic link
//It will help you to find specific item from list and
String id = deepLink.queryParameters['id'];
print(id);
}
}, onError: (OnLinkErrorException e) async {
print(e.message);
});
//To Handle pending dynamic links add following lines
final PendingDynamicLinkData data =
await FirebaseDynamicLinks.instance.getInitialLink();
final Uri deepLink = data?.link;
if (deepLink != null) {
String id = deepLink.queryParameters['id'];
print(id);
}
}
So, here we end up with successful creation and handle firebase dynamic links using Flutter and Firebase.
At last, Flutter firebase dynamic links are of great importance for Android/iOS users. It can help you to improve the user experience with your application. It can let you use these dynamic links in your applications to read all of their benefits more amazingly.
Dynamic links create a connection to send users to an application directly without redirecting any browser.
Using Flutter, firebase dynamic links are very useful to create a straight path between users and beneficial, productive content of the app.
Firebase dynamic links are free to use. Mobile app developers can deserve all the benefits and features of it without any cost.
Firebase dynamic links create productive, Straight and fascinating social and email campaigns in a more effective way.
Here is the list of advantages:
Using dynamic packaging technology, one can encapsulate flights, accommodation, cars,…
In today’s contemporary era of accelerated digital evolution, the importance…
The fact is that in today’s internet environment the only…
This website uses cookies.