Firebase Dynamic Links are links that work the way you want, on multiple platforms, and whether the app is installed or not.
App is not Installed?
Yes, Firebase dynamic link still works if the app is not installed on android and ios devices.
Users will be taken directly to the linked content in the app, after clicking on the dynamic link.
they can be taken to the equivalent content on your website when used in the browser.
How to create Dynamic Link
Create a link by using the Firebase console, using a REST API, iOS or Android Builder API.
You can also create a link by forming a URL by adding Dynamic Link parameters to a domain-specific to your app.
To know about individual parameters use while creating the link, please refer to this
What happens when the user will click on Link?
Two scenarios can be there when a user will click on the link.
1. App is not installed on the device :
If the app is not installed then user will be redirected to the app store or Playstore to download the app.
After installing the app you can retrieve the link that was passed to your app and handle the deep link as appropriate for your app.
2. App is installed on the device:
In this scenario, the app will open and show the content as per the app flow.
You can also understand this flow with the help of the below image.
Add Firebase Dynamic link support to the Android app.
Adding firebase dynamic link dependency in app’s build.gradle file.
1 2 3 4 5 |
dependencies { implementation 'com.google.firebase:firebase-dynamic-links-ktx:21.0.1'// Dynamic link implementation 'com.google.firebase:firebase-analytics-ktx:21.1.0' // Firebase analytics } |
Add Intent filter to handle deep link
We have to declare the below intent filter, as we declare the intent filter to handle plane/normal deep link in the Manifest.xml file.
1 2 3 4 5 6 7 8 |
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:host="sample.com" android:scheme="https"/> </intent-filter> |
When the user will open a Dynamic Link with a deep link to the scheme, your app will start the activity with this intent filter to handle the link.
Receive and Handle Deep Link In Activity
To receive the link we have to call getDynamicLink()
method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Firebase.dynamicLinks .getDynamicLink(intent) .addOnSuccessListener(this) { pendingDynamicLinkData: PendingDynamicLinkData? -> // Get deep link from result (null if no link is found) var deepLink: Uri? = null if (pendingDynamicLinkData != null) { deepLink = pendingDynamicLinkData.link } } .addOnFailureListener(this) { //Failure listener } |
You normally call getDynamicLink()
in the main activity as well as any activities launched by intent filters that match the link.
For more information about Firebase Dynamic Link refer to this.
Hope this post will give a idea about Firebas Dynamic Link.
Thank you !!