Firebase Dynamic Links

What Is Firebase Dynamic Links

Yusuf Kasım Temel
6 min readSep 20, 2021

Dynamic Link is a link that can act differently on different platforms. When a person click a dynamic link, Firebase detects user’s platform and open’s the content accordingly. Suppose that you have one IOS to-do app, one Android game app and one sport website. If you create a Firebase project ,add your apps to the project and create a dynamic link with the required app information on the query string, people who click the link will be directed to the respective app or website.

Dynamic Links are Firebase endpoints which takes deeplinks as query string.

URL Prefix is a firebase endpoint. This URL prefix tells firebase to find the right Firebase project. However, the query string or dynamic link attributes tells how to behave on different platforms and other informations that should be passed to the platform.

How To Create A URL Prefix

On the firebase console project, click dynamic links. If you did not create any URL prefix before, you can only see get started button. When you click it, a pop up is going to appear and guide you to create a URL prefix. There are two types of URL prefixes which are custom domains and google provided domains. We will move on with google provided domains and come back to custom domains later.

A google provided domain need to be unused and have “page.link” at the end.

If you provide a valid google provided domain the guide will end after the first step and direct you to dynamic links dashboard where you can create short dynamic links on Firebase Console.

You can create multiple URL Prefixes for your project.

From now on, when someone enters this domain with the correct query string Firebase will direct them to the according platform.

Long and Short Dynamic Links

Long dynamic links are the real dynamic links. They are not being created or stored. The query string in the dynamic link has all the instructions Firebase needed.

You can find all the parameters and the description on this link.

However, short links are needed to be created. You can not create them manually. If you want to create short links, you need to use Firebase Console, Rest API or Firebase’s software libraries. Additionally, Query string of short links does not effect anything. For example, putting utm parameters on a short links query string would not make any sense.

Create Dynamic Link On Firebase Console

After creating URL Prefix, you can create your dynamic links on the Firebase Console as well. Creating links manually or using Firebase Console would not make any difference. Putting necessary information on dynamic link creation form instead of query string would do it. However, if you use Firebase Console, you can not see your long link. You can only get your short link to use.

Debugging a Dynamic Link

Putting d=1 as query string on a dynamic link, whether it is a long link or short link, opens a debugging page on browsers.

Warning at the top of the page tells you what you did wrong and should correct.

The graph tells you how your dynamic link will react on different devices.

Receiving Firebase Dynamic Links

1. Receiving Dynamic Links on IOS

When you create your URL Prefix, your /apple-app-site-association json file is being created. So you need to add your IOS apps ,their App-Store ID and their Team ID if to your Firebase project before creating the prefix.

After creating the prefix you need to check https://<your url prefix>/apple-app-site-association. You need to see your app ID there in order dynamic links to work on IOS apps.

After that you need to add Associated Domains in your app. Click project file on xcode. Then select Signing & Capabilities and click “+ Capabilities”.

Type Associated Domains and add it as capability. Then add your URL Prefix like “applinks:<your URL Prefix>”in the Associated Domains part.

You need to add ‘Firebase/DynamicLinks’ in to your pod file and install this library. If you are not familiar with Cocoapods you can check here.

1.a) Receiving Dynamic Links on Swift UI

Be sure that you initilized firebase with FirebaseApp.configure() in your app.

In swift UI you can handle universal links with View.onOpenUrl() method. Since app’s default view is being opened when you open the app, you need to add this method to the default view. onOpenUrl() method triggers when someone opens the app with a universal link. Firebase dynamic link is a special universal link when we work on IOS. So, the url you are working with after calling the onOpenUrl() method, is unparsed Firebase Dynamic Link.

You need to call DynamicLinks.dynamiclinks().handleDynamicLink(url: The Universal Link) to parse this Dynamic Link.

s

handleDynamicLink(url) method gives a optinal dynamic link so you need to check if it has value or not.

If you want to see dynamic links on Firebase Analytics you need to add Firebase Analytics into your project as weel. If you do not know how to add Firebase Analytics into your app or how to check it if works in debug mode you can check my other Story.

If you add Firebase Analytics into your app and activate debug mode, you can see dynamic_link_app_open event being send into Firebase Analytics.

2. Receiving Dynamic Links on Android

Add Firebase Dynamic Links dependency into your app’s module level build.gradle file

Then add intent-filter in your AndroidManifest.xml file. In this intent-folder you are declaring the domain you are going to accept as Dynamic Link.

In the above example my URL Prefix is “teletabi.page.link”. You need to add this intent-filter object in manifest > application > activity object.

After that you need to add Firebase Dynamic Link receiving code into your main activity onCreate() function.

If you use regular Navigation Component, you can add deep links to your fragments in the navigation_graph.

After those, if you receive a dynamic link which has a deeplink which one of your fragment has, your app will automatically direct to the corresponding fragment.

Firebase Debug View

You can see your debug events on the Firebase Console’s Debug View like this.

Analytics Campaign Attribution Parameters

If you want to see your attribution parameters (utm_source, utm_medium, etc) on GA4 acquisition panel, you need to mark dynamic_link_app_open, dynamic_link_first_open event as conversion.

Otherwise, your campaign attribution parameters will not show in the acquisition panel.

--

--