Example app for Flutter SDK
Build, run, and navigate the example app included with the Flutter SDK
The Exponea Flutter SDK includes an example application you can use as a reference implementation. You can build and run the app, test Marketing features, and compare the code and behavior of your implementation with the expected behavior and code in the example app.
Prerequisites
You must have the following software installed to be able to build and run the example app:
- Flutter SDK
- Git
- Android Studio with a virtual or physical device set up to run the app on Android
- Xcode and CocoaPods with a virtual or physical device set up to run the app on iOS
Follow Flutter's Get started guide if you are new to Flutter.
Build and run the example app
-
Clone the exponea-flutter-sdk repository on GitHub:
git clone https://github.com/exponea/exponea-flutter-sdk.git -
Enter the
exampledirectory containing the example app and install dependencies:cd exponea-flutter-sdk/example flutter pub get - To run the app on iOS:
-
Run CocoaPods in the
iosdirectory to install dependencies:cd ios pod install cd .. - Connect a virtual or physical iOS device.
-
Run the app:
flutter run
-
- To run the app on Android:
- Connect a virtual or physical Android device.
-
Run the app:
flutter run --flavor gmsAlternatively, use
--flavor hmsfor Huawei devices without Google Play services but with HMS Core.If you use Visual Studio Code, you can create a launch configuration to use the flavor flag.
To enable push notifications in the example app, you must also configure the Firebase integration or Huawei integration in the Marketing web app. Use the
gmsproduct flavor for Firebase or thehmsflavor for Huawei. On iOS, the example app includes notification service and content extensions for rich push notifications. Rich push notifications require a physical device.
Navigate the example app
Run the app to open the SDK Configuration screen. The fields change depending on the selected integration type. To set it up:
- Select your integration type using the Project or Stream toggle.
- For Project:
- Enter your Project token.
- Enter your Authorization token (API key).
- Optional: Enter Advanced auth key to enable customer token authorization.
- For Stream:
- Enter your Stream ID. Find the stream ID in the Data hub app under Event streams > select your stream > Access Security.
- Optional: Enter JWT Key ID and JWT Secret to enable local JWT token generation for testing. Both must be provided together. Refer to SDK auth token authorization for details.
- Enter the API URL (API base URL for the Bloomreach platform).
- Optional: Enter an email address hard ID in the Registered customer ID field to identify the customer. Leave blank for anonymous tracking.
- Optional: Enter Application ID (optional) if your Marketing project supports multiple mobile apps. If you leave this blank, the SDK uses the default value
default-application. For more details, see Configuration for Flutter SDK. - Click Start to initialize the SDK.
The Clear local data button invokes ExponeaPlugin().clearLocalCustomerData() to delete all locally stored data without initializing the SDK.
When using Project integration, prefix your API key with
Token, for example:
Token 0b7uuqicb0fwuv1tqz7ubesxzj3kc3dje3lqyqhzd94pgwnypdiwxz45zqkhjmbf.
After initialization, the main screen provides bottom navigation to test different SDK features. The app bar also includes:
- SDK status indicator
- SDK configuration overview
- Logs bottom sheet
- Reset action that returns to the SDK Configuration screen
-
The Fetching screen enables you to fetch consents, recommendations, and segments, and open the App Inbox.
-
The Tracking screen shows the customer's cookie ID and enables you to identify the customer, set the SDK auth token (Stream integration), track custom events, payments, and page views, request push permission, and track push tokens and push delivered and clicked events. The Track Custom Event dialog includes presets that trigger the test in-app messages, for example
Modal,Fullscreen,Slide-in, andAlert Rich. -
The Flushing screen lets you read and change the flush mode and flush period, trigger a manual data flush, and read and change the SDK log level.
-
The Anonymize screen lets you anonymize the current customer and stop the SDK integration.
-
The In-app CB screen displays in-app content blocks. Use the placeholder IDs
example_top,example_list, andexample_carouselin your in-app content block settings. Useph_x_example_iOSandph_x_example_Androidto test platform-specific content blocks, andexample_carousel_iosandexample_carousel_andfor platform-specific carousels. The Runtime Control tab drivesExponeaPlugin().inAppContentBlocksController(prefetch, availability, invalidate) and logs each result. For more information, see Try the runtime controller in the example app.
The app also logs segmentation data, in-app message actions, and received and opened push notifications to the logs bottom sheet, so you can see the SDK callbacks in action.
Try out the different features in the app, then find the customer profile in the Marketing web app (under Data & Assets > Customers) to see the properties and events tracked by the SDK.
If you left the Registered customer ID field blank, the customer is tracked anonymously using a cookie soft ID. You can look up the cookie value on the Tracking screen and find the corresponding profile in the Marketing web app.
If you entered a hard ID — for example, an email address — in the Registered customer ID field, you can find the customer in the Marketing web app by their email address.
For more information on soft IDs and hard IDs, see Customer identification.
Troubleshooting
If you encounter any issues running the example app, the following may help:
- In the
exampledirectory, runflutter clean, thenflutter pub get. - If the app doesn't start on Android, you may have forgotten to include the
--flavor gmsor--flavor hmsflag. - If Android refuses to install the app over an existing installation (
INSTALL_FAILED_UPDATE_INCOMPATIBLE), uninstall the previous build once. The example app is signed with a shared demo key.
Updated 17 days ago

