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. In your FirebaseMessagingService:

Kotlin
class MyMessagingService : FirebaseMessagingService() {
    override fun onNewToken(token: String) {
        super.onNewToken(token)
        Grovs.pushToken = token
    }
}

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>

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
}

Unread count

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

Kotlin
val count = Grovs.numberOfUnreadMessages()
Log.d("Grovs", "Unread: $count")