Integrate Firebase Dynamic Links to iOS Apps

Onur Kara
Onur Kara
Mar 30, 2020 · 4 min read

Have you ever wanted to be notified once your app is first time installed by a user that is redirected to App Store via a link? This is the question that lead me to the Firebase Dynamic Links.

This framework lets you know the app is installed with the dynamic link you have created on Firebase or opened by clicking this link which is known as universal linking. In this blog post, I want to show you how to create a dynamic link on Firebase console and integrate it properly for your iOS app.

First, click on the link console.firebase.google.com create a new iOS app and do not forget to add App Store ID and Team ID in the project settings. This is essential to let your dynamic link know which App Store page will be opened when it is interacted on an iPhone where your app is not installed.

Then, tap on the Dynamic Links in the left menu and create your first dynamic link. You can add an existing domain as dynamic link domain but you need to verify that domain belongs to your organization.

How to verify your domain

I also prefer another option which is creating custom dynamic link domain. Firebase creates Apple App Site Association file automatically for custom dynamic link url: usualdevelopmentapp.page.link/apple-app-site-association. The Apple App Site Association is a file that should be in your domain and specified with appID to make universal linking unique.

After setting this domain, tap on New Dynamic Link button to set up dynamic link details properly.

  • First step is to set up short link url. This is the public url that user interacts to install or launch your app.
  • In second step, you need to set a deep link url which is handled by your app to initialize it with a custom logic. Deep link must be a valid url because any user can open short link in a desktop web browser will be redirected to the this link.
  • In third step, if the app is not installed to device, you should determine whether to redirect to app store or open a custom url in the web browser.
  • Fourth step is the same link defining behavior but this time for the android app.
  • Fifth step is an optional step to set a preview page which will be opened when user tapped on the short link that you have created. You can set image, title and description for the preview page or you can prefer skip this page and redirect user directly to the application. Firebase does not recommend to skip preview page. According to documentation:

The app preview page increases your click to install rate. It more reliably sends users to the appropriate destination (app or store) when they click on your link in social apps.

When all the configurations are ready on the Firebase console do not forget to enable Associated Domains option for your app in developer.apple.com.

Now, all configurations are done. Open up the Xcode and add dynamic link url to associated domains in the Signing & Capabilities section.

iOS can be aware of the dynamic linking in two different ways. The first one is to click the short link on a device that app already installed in and launch the app. This way is also known as Universal Linking. Second, install the app from app store with the redirection of the link. These two ways are handled in different methods in the AppDelegate file.

Handle dynamic links that received as Universal Link

If the user clicks on the short link which you created on the console when the app is installed on the device, this method will be called and it will print:

Host is the main host of your dynamic link.

Url is the deep link url that is embedded on the dynamic link in the second step above. You can initialize your app with the logic that depends on this url.

Match type value of dynamic link is unique which raw value is 3 when the app is already installed on the device and opened by clicking the link.

Handle dynamic links that received as Custom Url

When the user clicked on the link on a device where the app is not installed and redirected app store then installed and launched the app, this is the method that will be triggered by iOS.

Url is the same as expected but this time match type has changed.

Match type value of dynamic link is default which raw value is 2 when the app is installed to the device from the app store and launched for the first time via the link.

In this post, I tried to share with you what i have learned from integrating Firebase Dynamic Links to the app that i am working on. I hope this comes as a helpful post to you and your valuable feedback is appreciated.

Mac O’Clock

The best stories for Apple owners and enthusiasts

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store