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:
- Go to the Firebase Console and add your Android app
- Download the
google-services.jsonfile and place it in your app'sapp/directory - Add the Firebase dependencies to your project:
// 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
- In the Firebase Console, go to Project Settings → Service Accounts
- Click Generate new private key
- A
.jsonfile will be downloaded — keep it safe
Find your Firebase Project ID
- In the Firebase Console, go to Project Settings → General
- Copy the Project ID (e.g.
my-app-12345)
Upload to Grovs
- In the Grovs dashboard, go to your app's Android Setup → Push Notifications
- Upload the Service Account JSON key file
- Enter your Firebase Project ID
- 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:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />Then request it in your activity:
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:
FirebaseMessaging.getInstance().token.addOnSuccessListener { token ->
Grovs.pushToken = token
}You should also update the token when it refreshes. In your FirebaseMessagingService:
class MyMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
super.onNewToken(token)
Grovs.pushToken = token
}
}Register the service in your AndroidManifest.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:
Grovs.displayMessagesFragment {
// Fragment was dismissed
}Unread count
Get the number of unread messages — useful for showing a badge:
val count = Grovs.numberOfUnreadMessages()
Log.d("Grovs", "Unread: $count")