Example app for iOS SDK
Build, run, and navigate the example app included with the iOS SDK
The Exponea iOS 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:
- Xcode
- CocoaPods
The example app uses CocoaPods only to install the libraries that build the SDK and run its tests. This doesn't affect your app.
To install the SDK in your app, use Swift Package Manager.
In Xcode, navigate to Xcode > Settings > Locations and make sure Command Line Tools is set to your Xcode version.
Build and run the example app
-
Clone the exponea-ios-sdk repository on GitHub:
git clone https://github.com/exponea/exponea-ios-sdk.git -
Run the following CocoaPods command:
pod install - Open the
ExponeaSDK.xcworkspacefile to open the project in Xcode. - Navigate to Product > Scheme and select Example.
- Select Product > Build (
Cmd + B). - Select Product > Run (
Cmd + R) to run the example app in the simulator.
To enable push notifications in the example app, you must also Configure Apple Push Notification Service for iOS SDK in the Marketing web app. The example app includes notification service and content extensions for rich push notifications. Rich push notifications require a physical device.
In debug builds on a physical device, the example app enables the SDK's push setup self-check. A few seconds after you initialize the SDK, an alert shows which push setup steps succeeded. While the self-check runs, the SDK tracks the push token even before you grant notification permission, and the
notification_stateevent reportsvalid=falseuntil you do.
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 the 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. For more details, see SDK auth token authorization.
- Enter the API Base 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 an Application ID 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 iOS SDK. - Click Start to initialize the SDK.
The Clear Local Data button invokes Exponea.shared.clearLocalCustomerData(appGroup:) to delete all locally stored data without initializing the SDK. It also clears the values the app saved from the form.
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 (tap the Bloomreach logo)
- Logs sheet
- Reset action that returns to the SDK Configuration screen or stops the SDK integration
-
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_topandexample_listin your in-app content block settings, andph_x_example_iOSto test platform-specific content blocks. Turn on Show carousels to display theexample_carouselandexample_carousel_ioscarousels, including a carousel that filters and sorts its content blocks.
The app also logs segmentation data, in-app message actions, and opened push notifications to the logs sheet, so you can see the SDK callbacks in action.
The app handles universal links on mobile-sdk-example-apps.web.app and links with the exponea:// scheme. Links containing fetch, track, flush, anonymize, or inappcb open the matching screen.
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 building the example app, the following may help:
- Remove the
Podsfolder and thePodfile.lockfile from the project folder and rerun thepod installcommand. - In Xcode, select
Product>Clean Build Folder(Cmd + Shift + K), thenProduct>Build(Cmd + B).
Updated 2 days ago

