Consider an example. There is a science text book and the same publishers also have an android app that has all the related information and much more. In a particular chapter of the book, there is a QR code. When this QR code is scanned, it should open the app and take the user to the related content on the app.

Another example is that of an app vendor who has a website to promote the app. In the google search results when someone searches for a relevant keyword and come to the website, easy access has to be given to the relevant content in the app. So, let us say the user clicks on a link in the mobile or scans a QR code on the website and has to be taken to some specific page in the app.

We can make use of the firebase dynamic links feature to achieve this.

With Dynamic Links, you can seamlessly transition users from your mobile website to the equivalent content within your app. And because the links survive the app install process, even new users can pick up where they left off on your mobile site without missing a beat.

Deep Links

Deep links let you redirect users to a specific destination inside your app which provides a better user experience.

A deep link is a URL that navigates to a specific destination in your app. When you click a deep link, Android:

  • Opens the user’s preferred app that can handle the link, if it’s available.
  • If the preferred app isn’t available, it opens the only app that can handle the link.
  • If multiple apps can handle the link, it opens a dialog that lets the user select from one of the apps that can open the link.
  • If the app is not installed it redirects to the app in playstore.

A deep link is a URL that navigates to a specific destination in your app. When you click a deep link, Android:

  • https: Identifies the protocol used to access the resource on the internet.
  • www.aksharaontech.com: The host, which is the name or address of the web server being accessed.
  • test: The path which specifies a particular page of content.
  • code: The query parameter you can extract from intents in your destination. abcd is the value of the parameter.

To add deep link & use of this feature we have to add dynamic link support to the app.

You may want to check out the this blog to add dynamic link support to the app and the setup process.

If you are done with setup, add intent filters in the android manifest file.

Add an intent filter for deep links

You must add a new intent filter to the activity that handles deep links for your app.

Intent Filter

The intent filter is required for your app to receive the Dynamic Link data after it is installed/updated from the Play Store and one taps on Continue button. The intent filter catches deep links of your domain, since the Dynamic Link will redirect to your domain if your app is installed.

When users open a Dynamic Link with a deep link to the scheme and host you specify, your app will start the activity with this intent filter to handle the link.

Mobile Development

Handle deep links

To receive the deep link, call the getDynamicLink() method:

Deep Link

You must call getDynamicLink() in every activity that might be launched by the link, even though the link might be available from the intent using getIntent().getData(). Calling getDynamicLink() retrieves the link and clears that data so it is only processed once by your app.

You normally call getDynamicLink() in the main activity as well as any activities launched by intent filters that match the link.

Consider this deep link URL as example.

https://aksharaontech.com?courseid=1234&chapterid=21&subchapterid=12&contenttype=questionbank&contentid=10258cef

Here in the above deep link url we are passing host and required parameters separated with ampersand to access a particular content directly without being following the normal app flow.

We will parse the host-aksharaontech.com and different parameters which we can use to do appropriate action(In this case we can use courseid, chapterid, subchapterid, contenttype and contentid and open the particular content on launch of the app.) in side the app.

After accessing the deep link URL(created earlier while creating dynamic links using firebase console) on launch of app you can parse the URL so you can get your required parameters from it and can use your own execution to open the linked content.

An example of accessing linked content directly by launching the app. Here we have generated a QR code of the dynamic link. By scanning QR code we will launch the app and on the launch it will redirect to the linked content.

Click here to find out how Techpearl can build the best Mobile apps for you.