Firebase Dynamic Links are links that work the way you want on multiple platforms. With Dynamic Links, your users get the best available experience for the platform they open your link on. If a user opens a Dynamic Link on iOS or Android, they can be taken directly to the linked content in your native app. If a user opens the same Dynamic Link in a desktop browser, they can be taken to the equivalent content on your website.
Dynamic Links will also work across app installs: if a user opens a Dynamic Link on iOS or Android and doesn’t have your app installed, the user can be prompted to install it; then, after installation, your app starts and can access the link.
In this article, We will see how to create Firebase Dynamic Links With REST APIs On Node.js. Firebase Dynamic Links REST API allow us to create links using long Dynamic Link and an object containing Dynamic Link parameters.
Initial Setup (Firebase project & Web API key)
- Go to Firebase Console (You will be asked to login to your google account if your not logged in)
- Click Add project on Firebase Console then you will be prompted for entering your project name.
- Next, Setup Google Analytics for your Firebase project, We recommended to enable Google Analytics for future analytics information.
- Then Configure Google Analytics if you have enabled it, you will be prompted to link Google Analytics with existing account or with new account.
- Click Create project. Now your project will be created and you will be taken to your dashboard.
- On Settings, You will find the Web API key that need us for authenticate requests in REST APIs.
Setup Dynamic Links URL Prefix & Whitelist
- In the Firebase console, open the Dynamic Links section.
- If you have not already accepted the terms of service and set a domain for your Dynamic Links, do so when prompted. If you already have a Dynamic Links domain, take note of it. You need to provide a Dynamic Links domain when you programmatically create Dynamic Links.
- Also add Whitelist URL pattern to prevent phishing on the domain. For more information regarding pattern refer.
Create a short link from a long link
Create a dynamic link using Firebase Dynamic Links REST API. To do so, We need to make an HTTP POST request to the shortLinks endpoint, specifying the long Dynamic Link in the longDynamicLink parameter.
For Parameters refer, Manually constructing a Dynamic Link URL
Create a short link from parameters
Create a dynamic link using Firebase Dynamic Links REST API. To do so, We need to make an HTTP POST request to the shortLinks endpoint, specifying the long Dynamic Link in the dynamicLinkInfo parameter.
For Parameters refer, Firebase Dynamic Links Short Links API Reference
Note : Short Dynamic Links created with the APIs and client (Android/iOS) SDK do not show up in the Firebase console. Such Dynamic Links are intended for user-to-user sharing