Example app
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 Engagement 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
example
directory containing the example app:cd exponea-flutter-sdk/example
- To run the app on iOS:
- Run CocoaPods in the
ios
directory to install dependencies:cd ios pod install cd ..
- Connect a virtual or physical iOS device.
- Run the app:
flutter run
- Run CocoaPods in the
- To run the app on Android:
- Connect a virtual or physical Android device.
- Run the app:
Alternatively, use
flutter run --flavor gms
--flavor hms
for Huawei devices without GooglePlay 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 Exponea web app.
Navigate the example app
When you run the app in the simulator, you'll see the ConfigPage. Enter your project token, API token, and API base URL. Optionally, disable Automatic Session Tracking
using the switch (default enabled). Then click Configure
to initialize the SDK.
The HomePage provides several buttons to test the different SDK features.
-
In the
Push events
section, you canRequest Push Authorization
and check whether push notifications areConfigured?
. -
In the
Customer
section, you can get the customer's soft ID (Get Cookie
),Identify
the customer (using the hardcoded ID[email protected]
), orAnonymize
the customer. -
In the
Fetch
section, you can fetch the customer'sConsents
andRecommendations
. -
In the
Flush Mode
section, you canGet
andSet
the flush mode, and trigger a manualFlush
. -
In the
Flush Period
section, you can configure the flush period using the slider and theSet
button. -
In the
Track
section, you can track anEvent
(a harcoded eventevent_name
with some sample properties) and, if you disabled automatic session tracking, you can manually trackSession Start
andSession End
. -
In the
Trigger in-app messages by event
section, you can track various test events you can use to trigger in-app messages while testing:Modal
(track atest_msg_modal
event)Fullscreen
(track atest_msg_fullscreen
event)Slide-in
(tracks atest_msg_slide
event)Alert
(tracks atest_msg_alert
event)
-
In the
Log Level
section, you canGet
the current log level. -
In the
App Inbox
section, you can access theApp Inbox
,Fetch all
messages,Fetch first
message, andMark first as read
. -
Using the
In App CB Example Page
button, you can access the InAppCbPage to test in-app content blocks. Use the placeholder IDsexample_top
andexample_list
for the corresponding placeholders. Use the placeholder IDsph_x_example_iOS
andph_x_example_Android
to test platform-specific content blocks in the placeholder labeled "platformSpecificPlaceholderId".
Try out the different features in the app, then find the customer profile in the Engagement web app (under Data & Assets
> Customers
) to see the properties and events tracked by the SDK.
By default, the customer is tracked anonymously using a cookie soft ID. You can look up the cookie value in the logs and find the corresponding profile in the Engagement web app.
If you used the Identify
button, the customer can be found in Engagement web app by the test email address ([email protected]
).
Refer to Customer Identification for more information on soft IDs and hard IDs.
Troubleshooting
If you encounter any issues running the example app, the following may help:
- In the
example
directory, runflutter clean
, thenflutter pub get
. - If the app doesn't start on Android, you may have forgotten to include the
--flavor gms
or--flavor hms
flag.
Updated 9 days ago