Firebase – Android: Dynamic Links

Tram Ho

I have introduced about Dynamic Links, so everyone knows what it is and what it was born to do, right? 😄 . Of course there is an overview, it must have details to complete it. Therefore, today I will present my knowledge to learn about Dynamic Links!

1. Which situations should Dynamic Links be used?

Here are some cases where your app might use Dynamic Links:

a, Transfer user from web to app

  • For example, I have a sales app, without Dynamic Links, you are using the web to view product A suddenly need to navigate to CH Play to install the app, after installing the app, you can not return to the product. A product that you are viewing before. But when the app has Dynamic Links, you can return to see product A after installing the app. This has many benefits for your app:
  • This transition makes users feel more comfortable
  • Users can start using the app with the same content as previously viewed on the web.
  • But do not need much code anymore.

b, Strategies for advertising apps on social networks, email or SMS

  • For example, with this shopping app that has a stimulus campaign, you send promotions using links that can work on any platform. Current and future users can redeem your offers whether they use iOS, Android or web browser and regardless of whether or not they have installed your app.

c, User wants to share with each other

  • One of the most effective ways to get new users to install your app is to allow users to share content from the app with their friends. With Dynamic Links, you can create sharing experiences between users and users more conveniently: when users receive links from friends, they can click the link and be taken directly to the content. share in the app, even if they have to visit the App Store or Google Play Store to install your app first.
  • By combining user referrals and the convenience of Dynamic Links, you can create sharing and referral features between users and new users to serve promotions for the benefit of users. Referrals and Referrals.

d, Switch users from desktop to app

  • Create Dynamic Links when web users bookmark a page or send a link. When they open the link on another device, they get the best experience on any device.

** The Android system map will look like this: **

2. How to create Dynamic Links?

Dynamic Links and Deep Links

Firebase’s Dynamic Links concept is covering deep links. By nature, deep links are still the actual link that users want to interact, want to see. Firebase will use that deep link, combined with other information to build a final link called Dynamic Links. Dynamic Links carries more information such as:

  • Domain
  • Deep Links
  • Project Information: some project information such as package name, version app, … is also included in this link.
  • Fallback url: backup link in case the app cannot be installed on the target device.

Another difference is that in case the app has not installed Dynamic Links will redirect users to the store to install the app. Once successfully installed, it will open a screen corresponding to the information the deep link carries, and Deep Links will open the link in the browser.

A small comparison between Deep links and App Links:

  • Deep Links: When there is a link that you click on, your app will handle the Intent sent to it, but if there are many other apps that also handle this Intent, the system will open a dialog box for you to select one of the apps that is included. show out:

  • With App Links, only your app can receive and handle that Intent, when you click on the link, the user will be redirected to the right app you want to open, without showing a selection dialog. Because App Links uses HTTP URLs to link to the domain of the web that you own, no app can use that link. Therefore, one of the requirements of App Links is that you must verify the domain you own through the Firebase website. (This one does not go deep). With App Links, you can also open content directly in the app when you click on search results on the Google Search tool, in the search section on the Android screen or Google Assistant.

There are 4 ways to create Dynamic Links as follows:

a. Use Firebase Console.

  • This is good in case you create links to share on social media. This way, you can customize the surffix link and the name of the link on the Firebase console. You can also monitor the performance of this Dynamic Links on Firebase console or Rest API Analytics.
  • If you have not yet created a domain, Firebase will display a notification form for you to complete this. This domain will be a prefix of Dynamic Links later. It will look like this:

You fill out the information here following the steps are okay:

b. Use the Dynamic Link Builder API on iOS or Android.

  • This is an appropriate way to automatically create links in your application to share between users and users or in any situation where many links are needed. You can also monitor the performance of Dynamic Link with the Dynamic Links Analytics API.

c. Use the REST API.

  • This method is a method of method 3, if any platform does not have a Builder API then use this method. The Analytics REST API can track advertising performance on consoles.

d. Self-created manually.

  • This way is easy to calculate, if you do not care about long or short links, no matter whether the user clicks the link or not, use this method. Avoid walking around like the above ways. And when doing a project, I also use this method to test my Dynamic Links code in the project whether it works fine or not. Of course, customers will create links for me later, so I don’t have to.
  • To create Dynamic Links, you need to follow the following form:

  • Parameters in the link:
  • yoursubdomain : This is the domain, if the app has a domain then throw it here.
  • yourdeeplink : this is the deep link, throw your deep link here.
  • packagename : go back to the project and drag the package name thrown here. The package name is the value of the apn parameter, used to link your application to the Firebase console.
  • minimumversion : this is the lowest versionCode that can open the link. This is the value of the amv parameter, if the version in this link is larger than the current version you have, then you must go to the Store to reinstall the app. This paragraph must be processed in code, I code like this:

  • fallbacklink : as mentioned, this is a backup link. You can redirect users to the web page or advertisement page if the app is not already installed.

3. How to get Dynamic Links?

If the app has not linked to FireBase, you can refer to the following instruction link:

B1: add dependences to the file app / build.gradle:

B2: Add intent-filter to Mainifest:

  • In case the device has already installed the app, firebase will use the deep-link directly and open the app. Also if the device has not installed the app, open store -> After the installation is complete and press Continue and open the app. When the user opens Dynamic Links, this Intent-filter will filter by the deep link attached to Dynamic link, go to Activity that handles this Intent.

B3: Receive and process Dynamic Links:

  • To get the deep link, we use the function getDynamicLink () as follows:

  • This paragraph I usually put in MainActivity so that when opening the app will handle navigating the user to the corresponding screen.

Bug finding corner 😄 : When working with Dynamic Links, I encountered a bug like on the stack:

==== >>> And the solution is that you have to add SHA256 straight to the setting, add like this;

Above is the knowledge about Dynamic Links I have learned, wish everyone happy coding! 😄


Firebase docs: 😄

Share the news now

Source : Viblo