Skip to content

Latest commit

 

History

History
227 lines (162 loc) · 5.05 KB

File metadata and controls

227 lines (162 loc) · 5.05 KB

android-sdk.md

Grovs SDK for Android – Methods and Usage Guide

Grovs is a powerful SDK that enables deep linking, universal linking, attribution, and in-app messaging for Android applications. This guide provides a complete reference for configuration, API methods, and practical usage examples.


📦 Installation

Gradle

Add the following dependency to your build.gradle:

implementation("io.grovs:Grovs:1.0.12")

⚙️ Configuration

Initialize in Application class

override fun onCreate() {
    super.onCreate()
    Grovs.configure(this, "your-api-key", useTestEnvironment = false)
    Grovs.setDebug(Grovs.DebugLevel.INFO) // Optional
}

Handle Intents in Launcher Activity

override fun onStart() {
    super.onStart()
    Grovs.onStart()
}

override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    Grovs.onNewIntent(intent)
}

Add Intent Filters in AndroidManifest.xml

<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>

🧩 SDK Methods

Configuration

fun configure(application: Application, apiKey: String, useTestEnvironment: Boolean)

SDK Control

fun setSDK(enabled: Boolean)
fun setDebug(level: LogLevel) // INFO or ERROR

🔗 Link Generation

With Listener

Grovs.generateLink(
    title = "Title",
    subtitle = "Subtitle",
    imageURL = "https://example.com/image.png",
    data = mapOf("key" to "value"),
    tags = listOf("promo"),
    customRedirects = null,
    showPreviewIos = true,
    showPreviewAndroid = false,
    lifecycleOwner = this,
    listener = { link, error ->
        link?.let { Log.d("Grovs", "Link: $it") }
        error?.let { Log.e("Grovs", "Error: $it") }
    }
)

With Coroutines

val link = Grovs.generateLink(
    title = "Title",
    subtitle = "Subtitle",
    imageURL = "https://example.com/image.png",
    data = mapOf("key" to "value"),
    tags = listOf("promo")
)

📥 Payload Retrieval

fun setOnDeeplinkReceivedListener(activity: Activity, listener: GrovsDeeplinkListener)

or use Kotlin Flow:

Grovs.Companion::openedLinkDetails.flow.collect { deeplinkDetails ->
    Log.d("Grovs", "Link: ${deeplinkDetails?.link}, Payload: ${deeplinkDetails?.data}")
}

📡 Passing Intents

fun onStart()
fun onNewIntent(intent: Intent?)

💬 Message Handling

Display message list

Grovs.displayMessagesFragment {
    // Called when dismissed
}

Get unread count

val count = Grovs.numberOfUnreadMessages()

🔍 Link Details

Using Listener

fun linkDetails(path: String, lifecycleOwner: LifecycleOwner?, listener: GrovsLinkDetailsListener)

Using Coroutines

val details = Grovs.linkDetails(path = "123456")

🧑‍💼 User Data

Grovs.identifier = "user123"
Grovs.attributes = mapOf("name" to "Alice", "tier" to "Premium")
Grovs.pushToken = "FCM_TOKEN"

✅ Properties Overview

Property Type Description
useTestEnvironment Boolean Enables test environment.
identifier String? Set user ID to help track in dashboard.
attributes Map<String, Any>? Attach user attributes for analytics and personalization.
openedLinkDetails DeeplinkDetails? (Flow) Kotlin Flow to receive deeplink info.
pushToken String? Push notification token.

📬 Using Messages

val token = FirebaseMessaging.getInstance().token
Grovs.pushToken = token

val unreadCount = Grovs.numberOfUnreadMessages()
Grovs.displayMessagesFragment {}

🆘 Further Assistance

  • Refer to official documentation for full SDK reference.
  • Contact support@grovs.io for technical support.

Thank you for using Grovs SDK! 🚀