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.
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.
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:
Dynamic link host: usualdevelopmentapp.page.link
Dynamic link url: https://usualdevelopmentapp.page.link/urlParameter?parameter=value
Dynamic link match type: 3
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.
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.
Dynamic link url:https://usualdevelopmentapp.page.link/urlParameter?parameter=value
Dynamic link match type: 2
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.