Android
Migrate your Android app from Firebase Dynamic Links to Grovs for deep linking, link generation, and more.
Overview
This guide walks you through transitioning your Android app from Firebase Dynamic Links to Grovs for deep linking, link generation, referral tracking and user identity handling.
Prerequisites
- You have an active Grovs account and have integrated the Grovs SDK into your project.
- If not, refer to the Grovs SDK integration guide for instructions on integrating the SDK.
- Your app previously used Firebase Dynamic Links and you are now transitioning to Grovs.
Key Steps in Migration
To ensure full functionality, you'll need to replace Firebase Dynamic Links methods with their Grovs equivalents. Below are the detailed steps.
1. Initialization
Firebase Dynamic Links
Firebase Dynamic Links doesn't require explicit initialization for link handling but needs Firebase initialized.
Grovs
Grovs SDK initialization is done using the Grovs.configure() method in your Application class:
import io.grovs.Grovs
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
Grovs.configure(application = this, apiKey = "your-api-key", useTestEnvironment = false)
Grovs.setDebug(Grovs.DebugLevel.INFO) // Optional
}
}2. Universal Links and URL Handling
Firebase Dynamic Links
Firebase requires an intent filter declaration in AndroidManifest.xml to be able to open links:
<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="example.com"
android:scheme="https"/>
</intent-filter>Firebase handles dynamic links like this in your activity:
Firebase.dynamicLinks
.getDynamicLink(intent)
.addOnSuccessListener { pendingDynamicLinkData ->
val deepLink: Uri? = pendingDynamicLinkData?.link
// Handle the deep link
}Grovs
Grovs requires similar intent filter declarations in AndroidManifest.xml to be able to open links. your_app_scheme and your_app_host are configured in your Grovs project dashboard.
<intent-filter>
<data android:scheme="your_app_scheme" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="your_app_host" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="your_app_test_host" />
</intent-filter>Add Grovs handling in onNewIntent() and onStart():
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
Grovs.onNewIntent(it)
}
override fun onStart() {
super.onStart()
Grovs.onStart()
}Then you can listen for deeplinks using:
Grovs.setOnDeeplinkReceivedListener(this) { link, payload ->
// Handle the deep link
}or
Grovs.Companion::openedLinkDetails.flow.collect { deeplinkDetails ->
// Handle the deep link
}3. Generating Links
Firebase Dynamic Links
val shortLinkTask = Firebase.dynamicLinks.shortLinkAsync {
link = Uri.parse("https://www.example.com/")
domainUriPrefix = "https://example.page.link"
androidParameters { }
iosParameters("com.example.ios") { }
socialMetaTagParameters {
title = "Welcome to My App!"
description = "Some social description."
imageUrl = Uri.parse("https://www.example.com/images/social_preview.png")
}
}.addOnSuccessListener { (shortLink, flowchartLink) ->
// Link created
}.addOnFailureListener {
// Error
}Grovs
Grovs simplifies link creation by having all the configurations on the Grovs dashboard so developers can focus just on link generation.
Grovs.generateLink(title = "Welcome to My App!",
subtitle = "Some social description.",
imageURL = "https://www.example.com/images/social_preview.png",
listener = { link, error ->
link?.let { link ->
// Link created
}
error?.let { error ->
// Error
}
})Or using Kotlin coroutines:
try {
val link = Grovs.generateLink(title = "Welcome to My App!",
subtitle = "Some social description.",
imageURL = "https://www.example.com/images/social_preview.png")
} catch (e: GrovsException) {
// Handle generation error
}4. User Identification and Attributes
Firebase Dynamic Links
Firebase uses FirebaseAuth for identity.
Grovs
Grovs supports direct identity and attribute setting:
Grovs.identifier = "user123"
Grovs.attributes = hashMapOf(
"name" to "Alice Smith",
"tier" to "Premium"
)Notes for Migration
- Smooth transition: Grovs can work alongside Firebase and Firebase Dynamic Links. In some cases it might make sense to keep both integrations for a period to have a smooth transition.
- Simplified SDK: Grovs is designed for minimal boilerplate and faster integration in Android apps while keeping the configurations one click away in the dashboard.