Implement DeepLinks for Android apps with Firebase|Implement DeepLinks for Android apps with Firebase

📢 Tatvic is now a global partner of Usercentrics, world’s leading consent management platform

Tangled up in DeepLinking? Firebase has a solution!

Last Updated:

Services:    

Deeplinks

DeepLinking

Deep Links simply help you merge the two different worlds of app & web. They allow the user to land on a specific screen or section in the app by clicking a web URL. The user can dive into the app seamlessly rather than fumbling on various pages of the website on mobile devices.

I was actually scrapping my head off when I first sat to implement Deep Linking. Do you also find Deep Links complex? Then worry not! Because there’s Firebase to the rescue!

Firebase is a platform that provides various tools and infrastructure to build better apps. One of its awesome features is Dynamic Links. With the help of Dynamic Links, we can set up Deep Links. This is actually the crux of this blog.

Now let’s put our heads together to learn:

  1. Why do we need Deep Link?
  2. How does Deep Linking actually work?
  3. How to implement Deep Link in your app using Firebase?

Why Deep Linking?

Let’s talk about a practical issue that everyone faces.
Suppose, you have an app installed in which you have already logged in.

Mobile Deep Linking

One fine day you receive an email regarding a tempting offer and you click on the link in the mail.

All it does is opens your browser in the mobile web asking you to login again. And then all you do is blurt out crap in frustration!

Deep Linking Android

Instead of the browser, the installed app should’ve opened, right? And that would be possible with Deep Linking.

Deep Links are also useful for promotional notifications as they take users to the most relevant screen in the App. That’s pretty magical, isn’t it?

How does Deep Linking Work?

Within a mobile phone and its native app ecosystem, the operating system uses a mechanism that allows any native app installed on the phone to register for a specific URI scheme.

A URI scheme will tell the operating system which app to open up when the URI is clicked.

Mechanisam

Mechanism of Deep Linking

For example, an app is listening to http://shop.tatvic.com/shop. If anyone clicks on this link, and an app is installed on the device then the app will open. If there is no app registered with this URI, then the link will open in the browser.

How to implement Deep Linking in android using Firebase?

To implement the Deep Link, you need to make changes in:

  1. The Firebase Console
  2. The Native coding in your android app
Firebase Console:

To work with Firebase, you need to first register your app with Firebase.
Post registration, add the following dependency for Firebase Dynamic Links to your app-level build.gradle file.

compile 'com.google.firebase:firebase-invites:9.4.0'

You can now proceed to create a dynamic link in firebase console. Here’s how:

  1. Open the Dynamic Links section by clicking Dynamic Links on the sidebar menu of Firebase Console.
  2. Click on New Dynamic Link and proceed to accord the basic details of the dynamic link in the form that appears on the screen, as shown in below image.

Firebase Android
Advance Option:

Use Advanced options if required, to add more attribute to our deep link.

Mobile app deep linking

Below are the optional fields that can be provided in your deep link.

Mobile app deep linking

Advanced options details for Deep Link

  1. This is the fallback link that will be fired if in case the Link set for deep link is not fired.
  2. Here, you can also provide a minimum version of the app that can open the deep link that is configured.
  3. This can use any link scheme if specified, it takes priority over the link parameter on Android.
  4. 5 and 6 are related to the campaign.

After you provide all the relevant details, just click the CREATE LINK button. The link generated will be as follows :

http://shop.tatvic.com/shop&apn=com.rj.firebasedemo&amv=4&afl=http://shop.tatvic.com/&utm_source=demo_source&utm_medium=demo_medium&utm_campaign=demo_campaign

Also along with the above link, a short deep link is generated which will be used in your deep link configuration, in the native app coding.

https://uw55y.app.goo.gl/?n9ro
Native coding in your android app

Now follow below steps for coding configuration in native coding part in android app also.

    1. In the intent filter of the activity (i.e activity of splash screen or main screen) that will handle the deep link, in Android Manifest.xml , append the following code.

Dynamic links Firebase

  1. In the java file of the activity, that will handle the deep link, append this code.

Dynamic link android

Now I would happily say that we have successfully implemented Deep Linking in the app!

But wait!!!

Don’t you want to know whether the configured deep link is working?
Well, here’s how you check it!

  1. You can send a long URL(Generated by Firebase console) to your device.
  2. Click URL from the device. Your device will either ask you to open the link in the app (if the app is already installed) or in the web browser. Preferably, you should opt for the app to test your configurations.

If the app opens up, pat your back! If not, then just take a nap break and follow up the steps again!
Before winding up with this post, I would also like to dispense an astonishing feature of Firebase. It automatically logs a few Analytics events of Deep Linking. Refer below screenshot for the same…
Dynamic link android

For any assistance on Deep Linking or Mobile App Analytics, please drop us a comment in the section below & our experts will be glad to assist you!!

Ravi Pathak

Ravi Pathak

Ravi is the co-founder of Tatvic and expert at managing different web analytics tools. Ravi actively works on conversion optimization projects to improve conversion rate and test newer hypothesis with e-commerce companies.

Sign up for
our monthly newsletter

This field is for validation purposes and should be left unchanged.

Other Blog

Scroll to Top

Leverage Tatvic's comprehensive approach to 

Enquire Now

This field is for validation purposes and should be left unchanged.

Leverage Tatvic's comprehensive approach to 

Contact Us

Checkbox
This field is for validation purposes and should be left unchanged.