Firebase Setup
Crisp uses Firebase Cloud Messaging (FCM) on Android and Apple Push Notification service (APNs) on iOS to deliver push notifications. This page covers the Firebase project setup required for both platforms.
1. Create a Firebase Project
If you don't already have a Firebase project:
- Go to the Firebase Console
- Click Add project and follow the setup wizard
- Add your Android and iOS apps to the project
For detailed instructions, see the Firebase Get Started guide.
2. Add Firebase Dependencies
Add the Firebase packages to your Flutter project:
shell
flutter pub add firebase_core
flutter pub add firebase_messaging3. Initialize Firebase
In your main.dart:
dart
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'firebase_options.dart';
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
print("Handling a background message: ${message.messageId}");
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(const MyApp());
}Background Handler Requirements
- Must not be an anonymous function
- Must be a top-level function (not a class method)
- Must be annotated with
@pragma('vm:entry-point')(Flutter 3.3.0+)
4. Request Notification Permission
On iOS and Android 13+, you must request permission before receiving notifications:
dart
FirebaseMessaging messaging = FirebaseMessaging.instance;
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
print('Permission: ${settings.authorizationStatus}');5. Configure Crisp Dashboard for Android (FCM)
- Go to your Firebase Project Settings > Cloud Messaging tab
- In the Firebase Cloud Messaging API (V1) section, copy your Sender ID
- Go to Service accounts tab > click Generate new private key and save the file
- Go to your Crisp Dashboard > Settings > ChatBox Settings > Push Notifications
- Under Firebase Cloud Messaging:
- Enable Notify users using Android
- Paste the Sender ID into the Project ID field
- Upload your Firebase Admin private key file
- Click Verify Credentials
- Wait for Crisp to verify your credentials:
- Once verified, the status will show live:
Next Steps
- Android Notifications — Configure your Android app to receive and handle Crisp notifications
- iOS Notifications — Configure APNs for iOS
- Notification Handling — Choose between auto-open and app-first notification behavior
