New in v2.4.0

Cloud Messaging

Send push notifications to your Flutter and React Native users via FCM — without touching Firebase directly. Register device tokens, send targeted notifications, and broadcast to all users from the Koolbase dashboard or SDK.

How it works

  1. Your app obtains an FCM token using firebase_messaging
  2. The SDK registers the token with Koolbase — tied to a stable device ID
  3. You send notifications via the dashboard broadcast UI or the SDK
  4. Koolbase routes through FCM to deliver to Android and iOS

FCM handles both platforms

Firebase Cloud Messaging delivers to both Android and iOS. You only need one FCM server key — no separate APNs certificates required for v1.

Setup

Add your FCM server key as a project secret named FCM_SERVER_KEY in the Koolbase dashboard under Secrets.

Getting your FCM server key

Go to the Firebase Console → Project Settings → Cloud Messaging → Server key. Copy it and add it as a secret named FCM_SERVER_KEY in your Koolbase project.

Flutter SDK

Install firebase_messaging in your Flutter project, then register the FCM token with Koolbase after initialization.

dart
// main.dart
await Koolbase.initialize(KoolbaseConfig(
  publicKey: 'pk_live_xxx',
  baseUrl: 'https://api.koolbase.com',
  messagingEnabled: true, // default: true
));

// After Firebase is initialized
final fcmToken = await FirebaseMessaging.instance.getToken();
if (fcmToken != null) {
  await Koolbase.messaging.registerToken(
    token: fcmToken,
    platform: 'android', // or 'ios'
  );
}

// Refresh token when it changes
FirebaseMessaging.instance.onTokenRefresh.listen((newToken) {
  Koolbase.messaging.registerToken(
    token: newToken,
    platform: 'android',
  );
});

Send a notification

dart
// Send to a specific device
await Koolbase.messaging.send(
  to: deviceToken,
  title: 'Your order is ready',
  body: 'Pick up at counter 3',
  data: {'order_id': '123'},
);

Attach authenticated user

dart
// After login — attach user ID to token
final session = await Koolbase.auth.login(email, password);
final fcmToken = await FirebaseMessaging.instance.getToken();
if (fcmToken != null) {
  await Koolbase.messaging.registerToken(
    token: fcmToken,
    platform: 'android',
    userId: session.user.id,
  );
}

React Native SDK

Install @react-native-firebase/messaging, then register the FCM token with Koolbase.

typescript
// App.tsx
await Koolbase.initialize({
  publicKey: 'pk_live_xxx',
  baseUrl: 'https://api.koolbase.com',
  messagingEnabled: true, // default: true
});

// Register token
const fcmToken = await messaging().getToken();
await Koolbase.messaging.registerToken({
  token: fcmToken,
  platform: 'android', // or 'ios'
});

// Refresh token when it changes
messaging().onTokenRefresh(async (newToken) => {
  await Koolbase.messaging.registerToken({
    token: newToken,
    platform: 'android',
  });
});

Send a notification

typescript
await Koolbase.messaging.send({
  to: deviceToken,
  title: 'Your order is ready',
  body: 'Pick up at counter 3',
  data: { order_id: '123' },
});

Dashboard broadcast

Send a notification to all registered devices from the Koolbase dashboard. Go to your project → Messaging → fill in the title, body, and optional data payload → click Broadcast.

  • Total registered devices — Android and iOS count
  • Sent today / Failed today — delivery stats
  • Recent sends log — status per message
  • Broadcast to all — one-click send to every registered token

What Koolbase does not handle

  • Receiving messages in the app — use firebase_messaging for that
  • Notification permissions — request via the platform SDK
  • Background message handlers — configure in firebase_messaging
  • Web push notifications — mobile only in v1

API reference

MethodDescription
Koolbase.messaging.registerToken(token, platform, userId?)Register an FCM device token with Koolbase.
Koolbase.messaging.send(to, title, body, data?)Send a push notification to a specific device token.
Dashboard → Messaging → BroadcastSend to all registered devices for the project.