Docs

Messages

In-app messaging and push notifications with the Grovs Android SDK

If console messages have automatic display enabled in your dashboard, they will appear in your app without any additional integration.

Push notifications

Follow the steps below to enable push notifications for messages sent from the Grovs dashboard.

1. Add Firebase Cloud Messaging to your project

If your app doesn't already use Firebase:

  1. Go to the Firebase Console and add your Android app
  2. Download the google-services.json file and place it in your app's app/ directory
  3. Add the Firebase dependencies to your project:
Groovy
// project-level build.gradle
plugins {
    id("com.google.gms.google-services") version "4.4.2" apply false
}
 
// app-level build.gradle
plugins {
    id("com.google.gms.google-services")
}
 
dependencies {
    implementation(platform("com.google.firebase:firebase-bom:33.7.0"))
    implementation("com.google.firebase:firebase-messaging")
}

2. Upload your Firebase credentials to Grovs

Grovs uses the Firebase Cloud Messaging v1 API, which requires a Service Account JSON key and your Firebase Project ID.

Generate a Service Account key

  1. In the Firebase Console, go to Project Settings → Service Accounts
  2. Click Generate new private key
  3. A .json file will be downloaded — keep it safe

Find your Firebase Project ID

  1. In the Firebase Console, go to Project Settings → General
  2. Copy the Project ID (e.g. my-app-12345)

Upload to Grovs

  1. In the Grovs dashboard, go to your app's Android Setup → Push Notifications
  2. Upload the Service Account JSON key file
  3. Enter your Firebase Project ID
  4. Save your changes

3. Request notification permission

On Android 13 (API 33) and above, you must request the POST_NOTIFICATIONS permission at runtime. Add it to your AndroidManifest.xml:

XML
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Then request it in your activity:

Kotlin
import android.Manifest
import android.os.Build
 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
    requestPermissions(arrayOf(Manifest.permission.POST_NOTIFICATIONS), 0)
}

4. Pass the FCM token to Grovs

Retrieve the FCM token and forward it to the SDK:

Kotlin
FirebaseMessaging.getInstance().token.addOnSuccessListener { token ->
    Grovs.pushToken = token
}

You should also update the token when it refreshes. The SDK ships its own FirebaseMessagingService that displays Grovs messages, and Android delivers each push to only one such service. If you declare your own, it takes precedence, so it must hand Grovs pushes back to the SDK from onMessageReceived:

Kotlin
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import io.grovs.Grovs
import io.grovs.handlers.handleGrovsNotification
 
class MyMessagingService : FirebaseMessagingService() {
    override fun onNewToken(token: String) {
        super.onNewToken(token)
        Grovs.pushToken = token
    }
 
    override fun onMessageReceived(message: RemoteMessage) {
        if (handleGrovsNotification(message)) return   // a Grovs message, shown by the SDK
        // Handle your own pushes here
    }
}

handleGrovsNotification returns false for pushes that did not come from Grovs, so your own handling is unaffected. Register the service in your AndroidManifest.xml:

XML
<service
    android:name=".MyMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

To use your own small icon for Grovs notifications, add a meta-data entry naming a drawable:

XML
<meta-data android:name="io.grovs.NotificationIconSmall" android:value="ic_notification" />

Push notifications require a physical device or an emulator with Google Play Services.

Displaying messages

Show the full list of messages as a modal fragment:

Kotlin
Grovs.displayMessagesFragment {
    // Fragment was dismissed
}

Nothing is shown while the SDK is disabled or not yet configured — see Privacy & Consent.

Automatically displayed messages

Messages flagged for automatic display open on their own. To know when the user closes one — to resume a flow you paused, for example — register a listener. isLast is true when no other automatically displayed message is still on screen:

Kotlin
Grovs.setOnAutomaticNotificationsListener { isLast ->
    if (isLast) resumeOnboarding()
}

Unread count

Get the number of unread messages — useful for showing a badge:

Kotlin
// Using coroutines
lifecycleScope.launch {
    val count = Grovs.numberOfUnreadMessages()
    Log.d("Grovs", "Unread: $count")
}
 
// Using a callback
Grovs.numberOfUnreadMessages(lifecycleOwner = this) { count ->
    Log.d("Grovs", "Unread: $count")
}

Both forms return null when the SDK is not configured, not authenticated, or disabled.

Edit this page on GitHubLast updated 2026-10-07