Messages
In-app messaging and push notifications with the Grovs Flutter SDK
If console messages have automatic display enabled in your dashboard, they will appear in your app without any additional integration.
Automatically displayed messages are shown by the native SDKs. The Flutter plugin's part is small: it forwards the push token you give it with setPushToken. Message requests follow the SDK's consent state; see Privacy & Consent.
Push notifications
To receive push notifications for messages sent from the Grovs dashboard, pass the device token to the SDK. The examples below use the firebase_messaging package, but any package that gives you the token works.
Android (Firebase Cloud Messaging)
Follow the Firebase setup for Flutter to add FCM to your project, then pass the registration token:
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:grovs_flutter_plugin/grovs.dart';
final grovs = Grovs();
// Get and set the FCM token
final token = await FirebaseMessaging.instance.getToken();
if (token != null) {
await grovs.setPushToken(token);
}
// Keep it current
FirebaseMessaging.instance.onTokenRefresh.listen((newToken) {
grovs.setPushToken(newToken);
});Upload your Firebase Service Account JSON key and Project ID in the Grovs dashboard under Android Setup → Push Notifications. The steps, the Android 13 notification permission, and how the native SDK's own FirebaseMessagingService interacts with one you declare yourself are covered in Android Messages.
iOS (APNs)
- In Xcode, add the Push Notifications capability and enable Remote notifications under Background Modes
- Upload your APNs
.p8key, Key ID, and Team ID in the Grovs dashboard under Settings → Push Notifications - Request permission and pass the token:
import 'dart:io' show Platform;
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:grovs_flutter_plugin/grovs.dart';
final grovs = Grovs();
final settings = await FirebaseMessaging.instance.requestPermission();
if (settings.authorizationStatus == AuthorizationStatus.authorized) {
// Grovs delivers iOS pushes through APNs directly, so pass the APNs
// token on iOS and the FCM registration token on Android.
final token = Platform.isIOS
? await FirebaseMessaging.instance.getAPNSToken()
: await FirebaseMessaging.instance.getToken();
if (token != null) {
await grovs.setPushToken(token);
}
}On iOS, getAPNSToken() can return null for a moment after permission is granted; retry after a short delay, or call it again from your onTokenRefresh handler.
Push notifications require a physical device. They do not work in the iOS Simulator.
What the plugin does not expose
The native SDKs can present the full message list and report the unread count (displayMessagesFragment on Android, displayMessagesViewController and numberOfUnreadMessages on iOS). The Dart Grovs class has no methods for these in 3.0.0, so the only messages you can show from a Flutter app are the ones flagged for automatic display. Call the native SDK from platform code if you need the list or a badge count; see Android Messages and iOS Messages.