Example app for 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 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:

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

  1. Clone the exponea-ios-sdk repository on GitHub:
    git clone https://github.com/exponea/exponea-ios-sdk.git
  2. Run the following CocoaPods command:
    pod install
  3. Open the ExponeaSDK.xcworkspace file to open the project in Xcode.
  4. In the Project navigator in Xcode, select the ExponeaSDK project.
  5. Navigate to the Example application target's settings. On the General tab, find the Frameworks, Libraries, and Embedded Content section and verify that ExponeaSDK.framework is listed.
  6. Navigate to Product > Scheme and select Example.
  7. Select Product > Build (Cmd + B).
  8. 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 Engagement web app.

Navigate the example app

Example app screens: authorization
Example app screens: fetching, tracking, track event, identify customer

When you run the app in the simulator, you'll see the Authentication view. The screen fields change depending on the selected integration type. Here's how to set it up:

  1. Select your integration type from the dropdown: Stream ID or Project token.
  2. For Stream ID:
    • Enter your Stream ID.
    • Optional: Enter Key ID and Key secret to enable local JWT token generation for testing. Both must be provided together. Refer to SDK auth token authorization for details.
    • Optional: Enter a Registered customer ID to identify the customer at startup. When Key ID and Key secret are provided, the registered customer ID is required.
  3. For Project token:
    • Enter your Project token.
    • Optional: Enter the Authorization (API key).
    • Optional: Enter the Advanced Auth key to enable customer token authorization.
  4. Enter the Base (API) URL (API base URL for the Bloomreach platform).
  5. Optional: Enter an Application ID if your Engagement project supports multiple mobile apps. If you leave this blank, the SDK uses the default value default-application. Learn more about Configuration for iOS SDK.
  6. 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.

AuthenticationViewController.swift

👍

When using Project token, make sure to prefix your API key with Token , for example:
Token 0b7uuqicb0fwuv1tqz7ubesxzj3kc3dje3lqyqhzd94pgwnypdiwxz45zqkhjmbf.

The app provides several views, accessible using the bottom navigation, to test the different SDK features:

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.

If you enter a Registered customer ID on the authentication screen (Stream ID mode), the customer is identified from startup and can be found in the Engagement web app by their registered ID.

If you left the Registered customer ID field blank, or are using Project token mode, 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 use Identify Customer in the app to set the registered hard ID (use an email address as value), the customer is identified and can be found in the Engagement web app by their email address.

📘

Refer to Customer identification for more information on soft IDs and hard IDs.

Example app screens: flushing, anonymize, logging, content blocks

Troubleshooting

If you encounter any issues building the example app, the following may help:

  • Remove the Pods folder and the Podfile.lock file from the project folder and rerun the pod install command.
  • In Xcode, select Product > Clean Build Folder (Cmd + Shift + K), then Product > Build (Cmd + B).

© Bloomreach, Inc. All rights reserved.