Android
Migrate your Android app from Branch.io to Grovs for deep linking, link generation, event tracking, and more.
Overview
This guide will help you migrate from Branch.io to Grovs for deep linking, universal link handling, event tracking, and more within your Android applications.
Prerequisites
- You already have a Grovs account and have integrated the Grovs SDK into your project.
- If not, refer to the Grovs SDK integration guide for instructions on adding the SDK using Gradle.
- Your app previously used Branch.io, and you are now transitioning to Grovs.
Key Steps in Migration
To ensure full functionality, you'll need to replace Branch.io methods with their Grovs equivalents. Below are the detailed steps.
1. Initialization
Branch.io
Branch.io initialization typically occurs in the onCreate() method of your Application class:
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
Branch.getAutoInstance(this)
}
}Grovs
Grovs SDK initialization is done using the Grovs.configure() method in your Application class:
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
You will handle deep links directly in your Activity or BroadcastReceiver.
Branch.io
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
this.intent = intent
}
override fun onStart() {
super.onStart()
Branch.sessionBuilder(this).withCallback { branchUniversalObject, linkProperties, error ->
if (error != null) {
// Error
} else {
// Handle the deep link
}
}.withData(this.intent.data).init()
}Grovs
Grovs handles deep links in a similar way by calling Grovs.onNewIntent():
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
Grovs.onNewIntent(intent)
}
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
Branch.io
Branch.io uses BranchUniversalObject to generate links:
val buo = BranchUniversalObject()
.setCanonicalIdentifier("item/12345")
.setTitle("Welcome to My App!")
.setContentDescription("Some social description.")
.setContentImageUrl("https://example.com/image.jpg")
buo.generateShortUrl(this) { url, error ->
if (error == null) {
// Link created
} else {
// Error
}
}Grovs
Grovs simplifies this with a direct method:
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. Retrieving Referrals or Attribution Data
Branch.io
Branch.io retrieves user referrals or attribution data via:
Branch.getInstance().getLatestReferringParams(object : Branch.ReferringParamsCallback() {
override fun onSuccess(referringParams: Map<String, String>) {
// Handle referring params
}
})Grovs
Grovs does the same thing using the following method:
Grovs.Companion::openedLinkDetails.flow.collect { deeplinkDetails ->
// Handle the deep link
}5. User Identification and Attributes
Branch.io
To identify a user and associate metadata with their events:
Branch.getInstance().setIdentity("user123")
Branch.getInstance().setRequestMetadataKey("name", "Alice Smith")
Branch.getInstance().setRequestMetadataKey("tier", "Premium")Grovs
In Grovs, user identification and attributes are set directly via properties:
Grovs.identifier = "user123"
Grovs.attributes = hashMapOf(
"name" to "Alice Smith",
"tier" to "Premium"
)Notes for Migration
- Smooth transition: Grovs can work alongside Branch. 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.