
Firebase Dynamic Links- Everything You Need to Know
Understanding Deep Links and Firebase Dynamic Links
10 years ago, when we clicked on a link (like the one below), what would happen?
We would simply land on a webpage, complete our task, and that’s it! But with the rise of mobile phones, clicking a link can now take us to a website, an Android app, or an iOS app. This shift brought challenges, and that’s where deep linking comes into play.
What is a Deep Link?
A deep link is a hyperlink that redirects users not just to an app but to specific content within an app. For example, when you see an ad for sneakers on a website and click the link, it directly opens the product page in the Amazon app. This is the magic of deep linking.
Challenges with Deep Links
Despite their advantages, deep links come with certain challenges:
- You need separate links for iOS and Android apps.
- There’s no easy way to track how many users clicked the link and made a purchase.
- What if the user doesn’t have the app installed?
To address these issues, Firebase Dynamic Links provides an effective solution.
What is a Firebase Dynamic Link?
Firebase Dynamic Links solves the above challenges by allowing developers to create links that work seamlessly across different platforms. With dynamic links, you can:
✔ Define different behaviors for iOS, Android, and web users.
✔ Provide a fallback URL to direct users to the app store if the app isn’t installed.
✔ Track clicks and conversions using the Firebase Console.
Why Firebase Dynamic Links Matter for Mobile App Development?
For businesses investing in Mobile App Development Services, Firebase Dynamic Links ensure a seamless user experience. Whether it’s an e-commerce store, social media platform, or service-based app, deep linking helps retain users and improve conversions by directing them to the right content within the app.
Configuring an Android Project for Firebase Dynamic Links
Let’s get started by setting up Firebase Dynamic Links in an Android project.
- Go to Firebase Console
- Create a new project or open an existing one.
- Configure Firebase in your Android app. You can do this manually or through Firebase Assistant in Android Studio.
- Add the Firebase Dynamic Links dependency to your
app/build.gradle
file:
implementation 'com.google.firebase:firebase-dynamic-links:19.0.0'
5. now we have to add an intent filter to the activity which will receive and handle the dynamic link
<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="shinyshoes.page.link"
android:scheme="https"/>
</intent-filter>
This intent filter allows our app to handle all the links that are from the domain name shinyshoes.page.link and the scheme is https.
Now our app is ready so it’s time to create the dynamic link and the simplest way to create them is by using the Firebase console.
Creating our first dynamic link
1. Go to your Firebase project click on the dynamic link on the right side and click on the “New Dynamic Link” button.
2. Now choose the default subdomain or add your custom domain.
3. If everything goes right you will see this success dialog.
4. Now we have set up the short link. You can enter any name according to your app.
5. You have to give a deep link URL. On the desktop, the user will be redirected to this link. You can provide a link to your website here or you can provide any old URL.
6. Here define the behavior of the link on an Android or IOS app. Make sure the app is connected to the Firebase project.
7. We will enter our dynamic link title, image, and description to finish things off. You can also add a UTM parameter if you want to track the campaign. As of now, we will skip that.
8. YAY !! Our link is ready. To test it just copy the link and open it in your browser or send it to anyone on mail or WhatsApp.
Passing data with dynamic links
-
In some cases, you need to pass data through your link as well. For example product id of shoe in our shiny shoe app. For this, you can add parameters directly in your link in the following way.
https://shinyshoes.page.link/?link=https://example.com/?shoeid=123
as you can see here we have added a “should” parameter in the link. Make sure that the parameter is the deep link(example.com) and not in the dynamic link(shiny shoes.page.link)
2 Now you can retrieve these parameters in the activity that is handling the links. (an activity with intent filter)
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
String shoeid=deepLink.getQueryParameter("shoeid");
}
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "getDynamicLink:onFailure", e);
}
});
Here we have used the getLink() method to get the link and get the query parameter (your_param_name) to get the parameter from that link.
Conclusion
I hope this guide helped you understand Firebase Dynamic Links and their importance in deep linking. Whether you are working on an e-commerce platform, mobile app development service, or any other application, deep linking can enhance user experience and engagement.