Quick start
Flutter
Three calls: start the SDK, tell it who the user is, and turn on push. Ten minutes if your push setup already works.
1. Install
terminal
flutter pub add chumbaq2. Start the SDK and identify the user
Find your API key and project ID in your project's settings. Read them from your app's config rather than hard-coding them. Call identify right after login with your own user ID.
app start-up
final config = ChumbaqConfig.builder(
baseUrl: 'https://your-chumbaq-host',
apiKey: '<project API key>',
projectId: '<project id>',
).build();
await Chumbaq.instance.init(config);
// Who this is, once they log in.
await Chumbaq.instance.identify(
IdentifyParams.builder().externalUserId('u_42').build(),
);3. Turn on push
The SDK never intercepts a message. firebase_messaging on Android and APNs on iOS stay yours; hand each message to Chumbaq so it can report it.
push
await ChumbaqPush.instance.init();
FirebaseMessaging.onMessage.listen(
(message) => ChumbaqPush.instance.reportNotificationReceived(message.data),
);
FirebaseMessaging.onMessageOpenedApp.listen((message) async {
// A tap also hands back the campaign's destination, if it has one.
final url = await ChumbaqPush.instance.reportNotificationClicked(message.data);
if (url != null) router.go(url);
});4. Show in-app messages
Tell the SDK when the app opens, which screen is showing and what the user did. Messages wait for their trigger, and the native SDK draws them.
in-app triggers
ChumbaqMessages.instance.events.listen((event) => switch (event) {
MessageLifecycleEvent(:final eventType) => log(eventType),
MessageButtonAction(:final button) => router.go(button.actionUrl!),
MessageCustomEvent(:final eventName) => analytics.track(eventName),
});
await ChumbaqMessages.instance.onAppOpen();
await ChumbaqMessages.instance.onScreenView('Home');
await ChumbaqMessages.instance.onEvent('purchase');Next
- Add your FCM and APNs credentials
- Send traits and events to build segments
- Send a test push from the dashboard, then email us and we'll check your setup with you.