Docs
grovs.io Start for free

API reference

Every public type, property and method in the Grovs Android SDK 3.1.

Requires Android SDK 3.1.0

Members are on the Grovs companion object, so Kotlin calls them as Grovs.configure(...) and Java as Grovs.Companion.configure(...). Push helpers for your own messaging service are on GrovsMessaging. Every method works from any thread.

At a glance

AreaMemberKindWhat it does
SetupconfiguremethodConfigures and authenticates the SDK
setSDKmethodTurns collection on or off
setDebugmethodSets the log level
Deep linksonStartmethodResolves the launch link
onNewIntentmethodResolves links while running
setOnDeeplinkReceivedListenermethodRegisters the deep link listener
openedLinkDetailspropertyLast link that opened the app
UsersidentifierpropertyYour ID for the current user
attributespropertyAttributes of the current user
LinksgenerateLinkmethodCreates a smart link
linkDetailsmethodDetails of a link by path
EventstrackmethodTracks a custom event
trackScreenViewmethodTracks a screen view
trackNavigationmethodTracks Jetpack Navigation destinations
setGlobalTagsmethodTags added to every event
setScreenAliasesmethodRenames screens for the dashboard
RevenuelogInAppPurchasemethodLogs a Google Play purchase
logCustomPurchasemethodLogs a purchase outside Google Play
Push notificationspushTokenpropertyFCM token for push campaigns
handleNotificationOpenmethodHandles a tap intent the launcher didn't get
isGrovsNotificationmethodChecks if Grovs sent a push
GrovsMessagingclassCalls for your own messaging service
MessagingServiceclassThe SDK's messaging service
In-app messagessetInAppListenermethodReceives in-app message events
pauseInAppMessagesmethodHolds messages back
resumeInAppMessagesmethodLets messages show again
discardInAppMessagesmethodDrops waiting messages
setInAppExcludedScreensmethodScreens where no message shows
setInAppDebugLoggingmethodLogs why campaigns were skipped
TypesDeeplinkDetailsclassA resolved deep link
GrovsDeeplinkListenerinterfaceDeep link callback
GrovsLinkGenerationListenerinterfacegenerateLink callback
GrovsLinkDetailsListenerinterfacelinkDetails callback
GrovsInAppListenerinterfaceIn-app message callbacks
GrovsInAppListenerAdapterclassGrovsInAppListener for Java
GrovsExceptionclassLink and SDK failures
GrovsErrorCodeenumFailure categories
TrackingParamsclassUTM parameters
CustomRedirectsclassPer-platform link redirects
CustomLinkRedirectclassOne platform redirect
PaymentEventTypeenumBuy, cancel or refund
InstantCompatclassPoint in time for API 21
LogLevelenumLog verbosity
DeprecateddisplayMessagesFragmentmethodShows nothing
numberOfUnreadMessagesmethodAlways 0
setOnAutomaticNotificationsListenermethodNever called
GrovsNotificationsListenerinterfaceNever called
handleGrovsNotificationmethodUse GrovsMessaging.handleMessage

Setup

configure

method
Kotlin
fun configure(application: Application, apiKey: String, useTestEnvironment: Boolean, baseURL: String? = null)
fun configure(application, apiKey, useTestEnvironment, baseURL, autoTrackScreenViews: Boolean)
fun configure(application, apiKey, useTestEnvironment, baseURL, autoTrackScreenViews, clipboardDomains: List<String>?)
fun configure(application, apiKey, useTestEnvironment, baseURL, autoTrackScreenViews, clipboardDomains, enabled: Boolean)

Configures and authenticates the SDK. Call once per launch, in Application.onCreate().

NameTypeDescription
applicationApplicationYour Application instance.
apiKeyStringProject API key from the Grovs dashboard.
useTestEnvironmentBooleantrue targets the test environment, false production.
baseURLString?Domain of a self-hosted backend, for example "https://sdk.example.com". The SDK appends the API path. null targets the Grovs cloud.
autoTrackScreenViewsBooleanTrack Activity and Fragment screen views automatically. Defaults to true.
clipboardDomainsList<String>?Extra link hosts accepted by clipboard-assisted deferred deep linking, for example listOf("links.example.com"). Grovs-owned hosts are always accepted.
enabledBooleanWhether the SDK may collect and send anything this launch. Defaults to true.
  • Calling it again replaces the previous configuration.
  • Shorter overloads use autoTrackScreenViews = true, clipboardDomains = null and enabled = true.
  • enabled isn't persisted. Pass your stored consent value every launch.

Calls made before configure:

CallsEffect
Links passed to onStart or onNewIntentDropped, not held. Configure in Application.onCreate() so it runs before your launcher activity.
A Grovs push tapHeld (the latest one) and handled once configure runs
identifier, attributes, pushTokenKept and sent once the SDK authenticates
setInAppListener and the other in-app callsKept, and survive later configure calls
generateLink, linkDetailsReport a not-configured GrovsException
track, trackScreenView, setGlobalTags, setScreenAliasesIgnored

setSDK

method
Kotlin
fun setSDK(enabled: Boolean)

Turns collection on or off at runtime, for example when consent changes. See Privacy & Consent.

  • Call it only after configure.
  • While disabled, the SDK doesn't authenticate, resolve the device, read the clipboard, or send events, screen views or purchases. Outstanding requests are cancelled.
  • It holds identifier, attributes, pushToken and screen alias updates. Queued events stay on the device.
  • Disabling closes an in-app message on screen and drops unreported push opens.
  • Enabling authenticates if needed and sends everything held.

setDebug

method
Kotlin
fun setDebug(level: LogLevel)

Sets the log level. Default ERROR.

  • Logs go through android.util.Log with tag Logger. Every message is prefixed 🔗GROVS.

See Deep Linking.

onStart

method
Kotlin
fun onStart(launcherActivity: Activity? = null)

Forward from your launcher activity's onStart(). Required for the SDK to resolve the link the app was opened with.

onNewIntent

method
Kotlin
fun onNewIntent(intent: Intent?, launcherActivity: Activity? = null)

Forward from your launcher activity's onNewIntent(). Required for links delivered while the app is running.

setOnDeeplinkReceivedListener

method
Kotlin
fun setOnDeeplinkReceivedListener(launcherActivity: Activity?, listener: GrovsDeeplinkListener)

Registers the listener that gets DeeplinkDetails for every resolved link, including deferred links matched after install.

  • Called on the main thread.

openedLinkDetails

property
Kotlin
val openedLinkDetails: DeeplinkDetails?

The link the app was most recently opened from, or null.

  • Observe it as a StateFlow with Grovs.Companion::openedLinkDetails.flow (import io.grovs.utils.flow). See Using Kotlin Flow.

Users

identifier

property
Kotlin
var identifier: String?

Your identifier for the current user, typically your user_id. Shown in the dashboard and reports, and used to match test messages.

  • Set before configure, it's kept and sent once the SDK authenticates.
  • While the SDK is disabled, the latest value is held until it's enabled.

attributes

property
Kotlin
var attributes: Map<String, Any>?

Attributes of the current user, shown in the dashboard. In-app campaigns can filter on them and personalize text with them.

  • Set before configure, they're kept and sent once the SDK authenticates.
  • Held while the SDK is disabled.

Both methods come in a coroutine form and a callback form.

  • The coroutine form resumes on the caller's dispatcher and throws GrovsException on failure.
  • The callback form runs the listener on the main thread. If the SDK isn't configured, or authentication is still retrying, the listener is called synchronously on the calling thread with a GrovsException.
method
Kotlin
suspend fun generateLink(
    title: String? = null,
    subtitle: String? = null,
    imageURL: String? = null,
    data: Map<String, Serializable>? = null,
    tags: List<String>? = null,
    customRedirects: CustomRedirects? = null,
    showPreviewIos: Boolean? = null,
    showPreviewAndroid: Boolean? = null,
    copyToClipboardIos: Boolean? = null,
    copyToClipboardAndroid: Boolean? = null,
    tracking: TrackingParams? = null
): String
 
fun generateLink(
    /* same parameters */,
    lifecycleOwner: LifecycleOwner? = null,
    listener: GrovsLinkGenerationListener
)

Creates a smart link. See Link Creation.

NameTypeDescription
titleString?Link preview title.
subtitleString?Link preview subtitle.
imageURLString?Link preview image URL.
dataMap<String, Serializable>?Custom payload delivered on deep link open.
tagsList<String>?Tags for filtering and analytics.
customRedirectsCustomRedirects?Per-platform redirect overrides.
showPreviewIosBoolean?Show the preview page on iOS. null uses the project default.
showPreviewAndroidBoolean?Show the preview page on Android. null uses the project default.
copyToClipboardIosBoolean?Copy the link on the iOS preview page, for clipboard-assisted deferred deep linking. null uses the project setting.
copyToClipboardAndroidBoolean?Same, for Android.
trackingTrackingParams?UTM campaign, source and medium.
lifecycleOwnerLifecycleOwner?Callback form only. Scopes the callback to a lifecycle.
listenerGrovsLinkGenerationListenerCallback form only. Gets the link or a GrovsException.

Returns the URL (coroutine form).

linkDetails

method
Kotlin
suspend fun linkDetails(path: String): Map<String, Any>
fun linkDetails(path: String, lifecycleOwner: LifecycleOwner? = null, listener: GrovsLinkDetailsListener)

Gets details for a link generated in the current environment, by path.

Returns the details (coroutine form). Failures throw, or reach the listener, as a GrovsException.


Events

See Events & Screen Tracking.

track

methodSince 3.0
Kotlin
fun track(name: String, properties: Map<String, Any>? = null, tags: List<String>? = null)

Tracks a custom event.

trackScreenView

methodSince 3.0
Kotlin
fun trackScreenView(screenName: String, properties: Map<String, Any>? = null)

Tracks a screen view.

  • A repeat of the same screen within one second is dropped.

trackNavigation

methodSince 3.0
Kotlin
fun trackNavigation(navController: NavController)

Tracks every destination change of a Jetpack Navigation NavController as a screen view. See Jetpack Navigation.

  • Call once per controller. Repeat calls are ignored.
  • Only a weak reference is kept.

setGlobalTags

methodSince 3.0
Kotlin
fun setGlobalTags(tags: List<String>? = null)

Sets tags merged onto every later event. Pass null to clear them.

setScreenAliases

methodSince 3.0
Kotlin
fun setScreenAliases(aliases: Map<String, String>)

Maps Activity and Fragment class names to dashboard names, for example mapOf("MainActivity" to "Home").


Revenue

See Revenue.

logInAppPurchase

method
Kotlin
fun logInAppPurchase(originalJson: String)

Logs a Google Play Billing purchase. Pass purchase.originalJson.

  • The SDK reads the product ID and purchase token.
  • The backend verifies the purchase and resolves price and currency through the Google Play Developer API.
  • Purchases are de-duplicated on purchase token.

logCustomPurchase

method
Kotlin
fun logCustomPurchase(
    type: PaymentEventType,
    priceInCents: Int,
    currency: String,
    productId: String,
    startDate: InstantCompat? = InstantCompat.now()
)

Logs a purchase, cancellation or refund made outside Google Play Billing.

NameTypeDescription
typePaymentEventTypeBUY, CANCEL or REFUND.
priceInCentsIntPrice in cents.
currencyStringISO 4217 code.
productIdStringYour product identifier.
startDateInstantCompat?Defaults to now. See InstantCompat.

Push notifications

Setup: Push Notifications.

pushToken

property
Kotlin
var pushToken: String?

The FCM token, for push campaigns. See Ask for permission and pass the token.

handleNotificationOpen

methodSince 3.1
Kotlin
fun handleNotificationOpen(intent: Intent?): Boolean

Handles the intent of a tapped Grovs push. Only needed when the tap doesn't reach the launcher activity's onStart or onNewIntent, for example a splash activity that doesn't forward its extras.

Returns true when the intent is a Grovs push.

  • Reports a campaign open (push_open, once per device and campaign) and delivers the push to your GrovsDeeplinkListener.
  • data is the push's data merged over the link's data if there is one. The push's keys win.
  • The same tap seen again through onStart or onNewIntent isn't reported or delivered twice.

isGrovsNotification

methodSince 3.1
Kotlin
fun isGrovsNotification(data: Map<String, String>): Boolean
fun isGrovsNotification(intent: Intent?): Boolean

Checks whether Grovs sent the push, without handling it. Pass RemoteMessage.data, or the intent a tap opened.

Returns true when grovs_campaign_id is present and not blank.

GrovsMessaging

classSince 3.1
Kotlin
object GrovsMessaging {
    @JvmStatic var showForegroundNotifications: Boolean = true
    @JvmStatic fun handleMessage(context: Context, message: RemoteMessage): Boolean
    @JvmStatic fun onNewToken(token: String)
}

For an app with its own FirebaseMessagingService. See If your app has its own FirebaseMessagingService.

MemberDescription
showForegroundNotificationsShow Grovs pushes that arrive while the app is open. Defaults to true. Background pushes are shown by Firebase.
handleMessageCall from onMessageReceived. Shows a Grovs push and returns true; returns false for any other message.
onNewTokenCall from onNewToken. Same as setting pushToken.

MessagingService

classSince 3.1
Kotlin
open class MessagingService : FirebaseMessagingService()

io.grovs.handlers.MessagingService, declared in the SDK's manifest. It shows Grovs pushes received in the foreground and forwards token refreshes. Extend it if your app needs its own messaging service, and remove the SDK's declaration with tools:node="remove".


In-app messages

See In-app messages. Every method here works before configure and keeps its effect across later configure calls.

setInAppListener

methodSince 3.1
Kotlin
fun setInAppListener(listener: GrovsInAppListener?)

Receives in-app message events (shown, clicked, dismissed, answered, failed) and can stop a message. See GrovsInAppListener.

  • Held strongly. Pass null to release it.
  • Messages show without it.

pauseInAppMessages

methodSince 3.1
Kotlin
fun pauseInAppMessages()

Holds in-app messages back, during a checkout or video, say. The highest priority one that comes due waits.

resumeInAppMessages

methodSince 3.1
Kotlin
fun resumeInAppMessages()

Lets messages show again, starting with the one that waited, if it still qualifies.

discardInAppMessages

methodSince 3.1
Kotlin
@JvmOverloads
fun discardInAppMessages(dismissCurrent: Boolean = false)

Drops waiting and delayed messages and stays paused. With dismissCurrent = true, also closes the message on screen (reason app).

setInAppExcludedScreens

methodSince 3.1
Kotlin
fun setInAppExcludedScreens(screens: List<String>)

Sets screens where no message shows. Messages wait until the user leaves.

  • Use tracked screen names: from trackScreenView, or the name automatic tracking reports (after aliases).
  • Case is ignored. Each call replaces the list.

setInAppDebugLogging

methodSince 3.1
Kotlin
fun setInAppDebugLogging(enabled: Boolean)

Logs each campaign considered for an event and why it was skipped. Writes to Logcat at INFO under the tag GrovsInApp, whatever the setDebug level.


Types

DeeplinkDetails

class
Kotlin
class DeeplinkDetails(
    var link: String?,
    var data: Map<String, Object>?,
    var tracking: Map<String, Object>?
)

A resolved deep link, passed to GrovsDeeplinkListener.

NameTypeDescription
linkString?The link that opened the app, or null if unavailable.
dataMap<String, Object>?The custom payload attached to the link.
trackingMap<String, Object>?Attribution and campaign metadata for the link.

GrovsDeeplinkListener

interface
Kotlin
fun interface GrovsDeeplinkListener {
    fun onDeeplinkReceived(deeplinkDetails: DeeplinkDetails)
}

Passed to setOnDeeplinkReceivedListener. A functional interface, so a Kotlin lambda works. Runs on the main thread.

GrovsLinkGenerationListener

interface
Kotlin
fun interface GrovsLinkGenerationListener {
    fun onLinkGenerated(link: String?, error: GrovsException?)
}

Callback for generateLink. Runs on the main thread, except not-configured and still-retrying errors arrive on the calling thread.

GrovsLinkDetailsListener

interface
Kotlin
fun interface GrovsLinkDetailsListener {
    fun onLinkDetails(linkDetails: Map<String, Any>?, error: GrovsException?)
}

Callback for linkDetails. Same threading as GrovsLinkGenerationListener.

GrovsInAppListener

interfaceSince 3.1
Kotlin
interface GrovsInAppListener {
    fun shouldShowInAppMessage(campaignId: String): Boolean = true
    fun onInAppMessageShown(campaignId: String) {}
    fun onInAppMessageClicked(campaignId: String, buttonId: String?, payload: Map<String, Any?>?) {}
    fun onInAppMessageDismissed(campaignId: String, reason: String) {}
    fun onInAppMessageAnswered(campaignId: String, value: Any, comment: String?) {}
    fun onInAppMessageFailed(campaignId: String, message: String) {}
}

Passed to setInAppListener. Every method has a default and runs on the main thread.

MethodCalled when
shouldShowInAppMessageA message is about to show. Return false to stop it. It isn't counted as seen, and nothing else is shown for that event.
onInAppMessageShownA message is on screen and its view was counted.
onInAppMessageClickedThe user taps. buttonId is null for a tap on the message itself. payload is set only for a key-value action.
onInAppMessageDismissedA message closes without a click. See the reasons below.
onInAppMessageAnsweredAn answered message has closed, in place of the dismissal. value is an Int for stars, the option's ID for a choice. comment is null unless one was sent.
onInAppMessageFailedA message couldn't be drawn, for example with no visible activity. It isn't counted and is tried again at its next trigger.
Dismiss reasonMeaning
close_buttonThe close button, the back gesture, or the alert's Close.
backdropThe user tapped outside the message.
swipeThe user swiped a banner away.
appThe SDK or your app closed it, for example with discardInAppMessages(dismissCurrent = true).
orientationThe device turned to an orientation the campaign doesn't allow. Not counted as a dismissal in the dashboard.

GrovsInAppListenerAdapter

classSince 3.1
Kotlin
open class GrovsInAppListenerAdapter : GrovsInAppListener

For Java. Kotlin interface defaults aren't Java defaults on the SDK's JVM target, so extend this and override only what you need.

GrovsException

class
Kotlin
class GrovsException(message: String?) : Exception(message) {
    var errorCode: GrovsErrorCode?
}

Thrown by the coroutine forms of generateLink and linkDetails, and passed to the callback forms' listeners.

GrovsErrorCode

enum
Kotlin
enum class GrovsErrorCode {
    LINK_GENERATION_ERROR,
    SDK_NOT_INITIALIZED,
    NOTIFICATIONS_ERROR,
    LINK_DETAILS_ERROR,
    EVENT_DISPATCH_ERROR
}

The category in GrovsException.errorCode.

TrackingParams

class
Kotlin
class TrackingParams(
    val utmCampaign: String? = null,
    val utmSource: String? = null,
    val utmMedium: String? = null
)

UTM parameters for generateLink.

CustomRedirects

class
Kotlin
class CustomRedirects(
    val ios: CustomLinkRedirect? = null,
    val android: CustomLinkRedirect? = null,
    val desktop: CustomLinkRedirect? = null
)

Per-platform redirect overrides for generateLink.

CustomLinkRedirect

class
Kotlin
class CustomLinkRedirect(
    val link: String,
    val openAppIfInstalled: Boolean = true
)

One platform redirect. When openAppIfInstalled is true, the app opens if installed. Otherwise link is always used.

PaymentEventType

enum
Kotlin
enum class PaymentEventType {
    BUY,
    CANCEL,
    REFUND
}

Used with logCustomPurchase.

InstantCompat

class
Kotlin
data class InstantCompat(val epochMillis: Long)

A point in time that works on API 21, for startDate in logCustomPurchase.

FactoryCreates
InstantCompat.now()The current time.
InstantCompat.ofEpochMilli(millis)From epoch milliseconds.
InstantCompat.ofEpochSecond(seconds)From epoch seconds.
InstantCompat.parse(iso8601)From an ISO 8601 string.

LogLevel

enum
Kotlin
enum class LogLevel {
    INFO,
    ERROR
}

Passed to setDebug.

ValueLogs
INFOEverything, including informational messages.
ERRORErrors only (default).

Deprecated

The messages inbox was removed in 3.1. These members remain so existing code compiles, and show nothing. Use in-app messages.

displayMessagesFragment

methodDeprecated in 3.1
Kotlin
fun displayMessagesFragment(onDismissed: (() -> Unit)?)

Shows nothing. Calls onDismissed once, on the main thread.

numberOfUnreadMessages

methodDeprecated in 3.1
Kotlin
suspend fun numberOfUnreadMessages(): Int?
fun numberOfUnreadMessages(lifecycleOwner: LifecycleOwner? = null, onResult: ((Int?) -> Unit)?)

Always yields 0. The callback runs once on the main thread, and is skipped if lifecycleOwner is destroyed by then.

setOnAutomaticNotificationsListener

methodDeprecated in 3.1
Kotlin
fun setOnAutomaticNotificationsListener(listener: GrovsNotificationsListener)

Does nothing. The listener is never called.

GrovsNotificationsListener

interfaceDeprecated in 3.1
Kotlin
fun interface GrovsNotificationsListener {
    fun onAutomaticNotificationClosed(isLast: Boolean)
}

Never called.

handleGrovsNotification

methodDeprecated in 3.1
Kotlin
fun FirebaseMessagingService.handleGrovsNotification(message: RemoteMessage): Boolean

Same as GrovsMessaging.handleMessage(this, message). Use that instead.

Last updated 2026-10-27
Was this page helpful?