Firebase Dynamic Links in iOS
Tags: ios, firebase, dynamiclink, swift
Published: 2020-03-11 18:16:05

Firebase introduces [Dynamics Links](https://firebase.google.com/docs/dynamic-links/) which is migrated from [Firebase invites](https://firebase.google.com/docs/invites/). Dynamic Link is a deep-linking platform of firebase for the developers to share any content or your application with others by creating a short link. We can also use it as promotional campaigns and also for referrals.

**Dynamic link follow the basic pattern when someone tapped on a link:**
1. If the application installed in the mobile it will redirect to the Application.
2. If the application is not installed in the mobile then it will redirect to the description web page from where you can open the application on the App Store/Play store.
3. If you open the application on desktop or laptop then it will redirect to the respective website that we will mention while creating the dynamic link.

For example, you have a shopping application and recently you see a product that your friend is searching and then you share it with your friend. when he/she tapped the link you share, it will open the application and if he/she didn’t have the application then he/she will be redirected to the store. And if he/she opens the link on desktop or laptop then it will redirect to the website of the application.

Today we will discuss how can we manage it on firebase console and implement it in our application. so, let’s get started.

## Creating Dynamic Link
  let’s get started, Dynamic link has 2 parts [Prefix](https://en.wikipedia.org/wiki/Prefix) and [Suffix](https://en.wikipedia.org/wiki/Suffix). First, we create the Prefix for the dynamic link.
Open the [Console](https://console.firebase.google.com/u/0/?pli=1) of the firebase and make a project if you don’t have any. then open the project and redirect it to the [Dynamic Link](https://console.firebase.google.com/u/0/project/test-project-149c0/durablelinks?pli=1) section where you can see the get started view.

![Get Started](https://ucarecdn.com/6ee59a0c-5f8d-42ed-9048-933423b6a14e/)

Press the get started button and then a popup appears where you can write the domain name of the prefix make sure that your prefix should be unique and relevant to the application (For batter practice use application name ). and then click finish it will take some time to finalize and then redirect to the dashboard.

Press the get started button and then a popup appears where you can write the domain name of the prefix make sure that your prefix should be unique and relevant to the application (For batter practice use application name ). and then click finish it will take some time to finalize and then redirect to the dashboard.

![Prefix](https://ucarecdn.com/c329f72f-62c7-4695-8386-0b3fe781bedf/-/crop/1414x842/15,11/-/preview/)

![Dashboard](https://ucarecdn.com/8bbb5700-7c1e-4faf-b464-544f402e68a3/)

On the dashboard left top, you can see the prefix of the deep link. Now we confirm that our prefix is created fine or not for that we will use apple-app-site-association to confirm it:
```
https://appnamee.page.link/apple-app-site-association
```
if your app is connected with apple-app-site-association then it will show reference to your app's App Store ID and bundle ID and if you didn't configure the setting then app's App Store ID and bundle ID will be not shown.
```
{"applinks":{"apps":[],"details":[{"appID":"1234567890.com.example.ios","paths":["/*"]}]}}
```



Now its time to create a dynamic link under the prefix we just created. After creating prefix you have to create suffix to make a complete dynamic link. we can generate a dynamic link in two different ways.
1. Manually.
2. Programmatically.

## 1. Manually
If you have a static dynamic link that you don’t want to edit before sharing the link so its good practice to make it manually e.g you want to share your application. You can also track the number of clicks. We can create the dynamic link manually from console but when we create a dynamic link from console it can’t be editable but only properties of it. If you try to edit it by self then it will not work and shows an error so make sure if you are making it manually then make it properly.
For creating dynamic link manually follow this [article](https://muneebaliarshad.com/firebase-dynamic-links-manually/).

## 2. Programatically
If you want to share some content of your application for that the prefix is not fixed and you surely need a random dynamic link that you will create on runtime for that you will create dynamic link programmatically.