4771
What are dynamic links? Dynamic links are links whose behavior you can decide – you’ll learn about that in the next section. firebase dynamic links may behave differently or similarly across platforms – Android, iOS, web platform – based on what you need. It will show the appropriate content for that platform. You can also configure Firebase Dynamic Links to change the behavior depending on whether or not the user has the application installed. These links can be used for various purposes, especially marketing campaigns for your new apps.
Being an iOS and Android Application Development Company, we develop apps that use Firebase dynamic links. For example, we developed the PayNowlink payment app which generates dynamic links to complete transactions without any human contact. We decided to write this tutorial to help Android developers, as well as mobile app beginners, understand what dynamic links are, how they can be created and how they can be used.
Dynamic links are created to provide the best experience for your app users. You can create a dynamic link in a number of ways. You can use the Firebase console, an iOS or Android Builder API, a REST API, or form a URL by adding dynamic link parameters to a specific domain of your app. These parameters specify the behavior of the link when opening based on the user’s platform and whether the application is installed or not.
When a user opens a dynamic link on an iOS or Android device, they are taken directly to the linked content on their native app. In the case of a desktop browser, they are brought to content equivalent to the content linked on your site. For users who don’t have your app installed, you can upload them to your website or take them to the Play Store or show them an interstitial describing your app’s benefits before taking them to the app store for a smoother transition.
Now that you know what dynamic links are and how they work, it’s time to see how to create a dynamic link in firebase. Below are step-by-step tutorials for creating dynamic links for Android and iOS platforms.
Step 1: Dynamic link creation starts by creating a project with an empty activity
Step 2: Configure Project Name, Package Name, and Minimum SDK Version
Step 3: Create a Firebase project and add a JSON file to your project
Step 4: Add the following dependencies to your App Gradle
- implementation 'com.google.firebase:firebase-dynamic-links-ktx:19.1.0' - implementation 'com.google.firebase:firebase-analytics-ktx:17.4.4'
Step 5: Pass the link parameters
val invitationLink = "http://www.yopmail.com/?invitedby=${refferCode.value}" //Pass parameters in link as query parameters
Step: 5.1 Long dynamic link
Generate dynamic link using the following function
val dynamicLink = Firebase.dynamicLinks.dynamicLink { link = Uri.parse(invitationLink) domainUriPrefix = "https://spaceo.page.link" // Open links with this app on Android androidParameters { // The versionCode of the minimum version of your app that can open the link. // If the installed app is an older version, the user is taken to the Play Store to upgrade the app. minimumVersion = 1 } // Open links with com.example.ios on iOS // iosParameters("com.example.ios") { } } val dynamicLinkUri = dynamicLink.uri // get Link
Step 5.2: Short Firebase Dynamic Link
val shortLinkTask = Firebase.dynamicLinks.shortLinkAsync { link = Uri.parse(invitationLink) domainUriPrefix = "https://spaceo.page.link" androidParameters { // The versionCode of the minimum version of your app that can open the link. // If the installed app is an older version, the user is taken to the Play Store to upgrade the app. minimumVersion = 1 } // Set parameters // ... }.addOnSuccessListener { result -> // Short link created val shortLink = result.shortLink //val flowchartLink = result.previewLink this.shortLink.value = shortLink.toString() }.addOnFailureListener { // Error // ... Log.d("log_tag", "==> ${it.localizedMessage}", it) this.shortLink.value = it.localizedMessage }
Step 1: Add an intent filter to the activity tag as below
<activity android:name=".DeepLinkReceiveActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="www.yopmail.com" android:scheme="http" /> <data android:host="www.yopmail.com" android:scheme="https" /> </intent-filter> </activity>
Step 2: Use the code below to get data from your activity.
Firebase.dynamicLinks .getDynamicLink(intent) .addOnSuccessListener(this) { pendingDynamicLinkData -> // Get deep link from result (may be null if no link is found) var deepLink: Uri? = null if (pendingDynamicLinkData != null) { deepLink = pendingDynamicLinkData.link Log.d("TAG", "==> ${deepLink.toString()}") if (deepLink?.getBooleanQueryParameter("invitedby", false) == true) binding.linkData = deepLink.getQueryParameter("invitedby") } // Handle the deep link. For example, open the linked // content, or apply promotional credit to the user's // account. // ...
Want to create an Android app?
Validate your app idea and get a free quote.
This demo shows how you can create firebase dynamic links on android and get a specific Reference Code opening a specific dynamic link. This can be used to promote offers in your app.
Here are some ways to use dynamic links.
The problem with standard hard links is that they don’t survive the application installation process. If a user clicks on a direct link and is taken to the application’s installation page, all of the link’s original content will be lost. Dynamic links overcome this problem. Therefore, if the user installs your app by clicking a dynamic link, all this information will be available when the user opens the app for the first time.
You can use Firebase Dynamic Link for marketing campaigns, from emails to social media, banner ads and even QR Codes. You can see which campaigns are getting the highest quality users. You can also offer your users a personalized first-time experience based on the campaign that brought them there.
So if users installed your music app because you showed them a classical music ad, you can ensure that your app takes them to the classical music section the first time they open your app.
Read too: How to read QR code on Android
Any dynamic link, Firebase or not, is also great for sharing. Users can use these links to share recipes, links to their favorite level in a game or even coupon codes. In fact, dynamic links are the technology that drives Firebase invites.
Since dynamic links are Firebase products, you can view your stats directly in the Firebase Console. You can find out how many people clicked on a link or use Firebase Analytics to find out which of your users opened your app for the first time via a particular link.
Read here: Direct links tutorial on mobile app
So we hope that by now even you can create Firebase dynamic links to your app without the hassle. You can also refer to this GitHub source code for Android if you need more details.
If you have any questions implementing this code during application development, please feel free to ask us. We always appreciate constructive feedback, you can also give us feedback on this tutorial and help us improve. If you need to hire Android developers for your project, please contact us.
useful resource
Are you guys excited about Mathhew Lillard's show Five Nights at Freddy. we are sure…
Fox News selected Jesse Watters as a new prime time host for its new 8…
Jill Tracy Biden an American educator, and the current first lady of the United States…
Xi Jinping made a three-day visit to Moscow and it has been marked as a…
The chairman of the Indian Space Research Organisation Sreedhara Panicker Somanath stated on Wednesday…
According to the reports, British minister Oliver Dowden said in recent meeting, that the government…