Initial SDK setup
Install and configure the iOS SDK
Install the SDK
The Exponea iOS SDK can be installed or updated using CocoaPods, Carthage, or Swift Package Manager.
The instructions below are for Xcode 15.1 and may differ if you use a different Xcode version.
CocoaPods
-
Install CocoaPods if you haven't done so yet.
-
Create a file named
Podfile
in your Xcode project folder. -
Add the following to your
Podfile
platform :ios, '13.0' use_frameworks! target 'YourAppTarget' do pod "ExponeaSDK" end
(Replace
13.0
with your desired iOS deployment target andYourAppTarget
with your app target's name) -
In a terminal window, navigate to your Xcode project folder and run the following command:
pod install
-
Open the file
HelloWorld.xcworkspace
, located in your project folder, in XCode. -
In Xcode, select your project, then select the
Build Settings
tab. UnderBuild Options
, changeUser Script Sandboxing
fromYes
toNo
.
Optionally, you can specify the ExponeaSDK
version as follows to let pod
automatically any smaller than minor version updates:
pod "ExponeaSDK", "~> 3.0.1"
For more information, refer to Specifying pod versions in the Cocoapods documentation.
Carthage
- Install Carthage if you haven't done so yet.
- Create a file named
Cartfile
in your Xcode project folder. - Add the following line to your
Cartfile
github "exponea/exponea-ios-sdk"
- In a terminal window, navigate to your Xcode project folder and run the following command:
carthage update exponea-ios-sdk --use-xcframeworks --platform iOS
- Open your Xcode project and navigate to your application target's settings. On the
General
tab, find theFrameworks, Libraries, and Embedded Content
section. - Open Finder, navigate to the
Carthage/Build
folder inside your project folder, and drag and drop every*.xcframework
folder inside it to theFrameworks, Libraries, and Embedded Content
section in Xcode.
Swift Package Manager
- In Xcode, navigate to
Xcode -> Settings -> Accounts
and add your GitHub account if you haven't done so yet. - Open
File -> Add Package Dependencies...
- In the dialog that appears, enter the Exponia iOS SDK repository URL
https://github.com/exponea/exponea-ios-sdk
in the search box. - In the
Dependency Rule
section, select the SDK version.
- Click on
Add Package
. - In the next dialog, make sure
ExponeaSDK
andExponeaSDK-Notifications
are both selected.
- Click on
Add Package
.
Initialize the SDK
Now that you have installed the SDK in your project, you must import, configure, and initialize the SDK in your application code.
The required configuration parameters are projectToken
, authorization.token
, and baseUrl
. You can find these as Project token
, API Token
, and API Base URL
in the Bloomreach Engagement webapp under Project settings
> Access management
> API
:
Refer to Mobile SDKs API access management for details.
Import the SDK:
import ExponeaSDK
Initialize the SDK:
Exponea.shared.configure(
Exponea.ProjectSettings(
projectToken: "YOUR PROJECT TOKEN",
authorization: .token("YOUR API KEY"),
baseUrl: "https://api.exponea.com"
),
pushNotificationTracking: .disabled
)
Your AppDelegate
's application:didFinishLaunchingWithOptions
method is typically a good place to do the initialization but, depending on your application design, it can be anywhere in your code.
At this point, the SDK is active and should now be tracking customers and events in your app.
SDK initialization immediately creates a new customer profile with a new cookie soft ID unless the customer has been identified previously.
Refer to Tracking for details on which events are automatically tracked by the SDK.
Configuring the SDK using a
plist
file is deprecated but still supported for backward compatibility.
Other SDK configuration
Advanced configuration
The SDK can be further configured by providing additional parameters to the configure
method. For a complete list of available configuration parameters, refer to the Configuration documentation.
Log level
The SDK supports the following log levels:
Log level | Description |
---|---|
.none | Disables all logging |
.error | Serious errors or breaking issues |
.warning | Warnings and recommendations + .error |
.verbose | Information about all SDK actions + .warning + .error . |
The default log level is .warn
. While developing or debugging, setting the log level to .verbose
can be helpful.
You can set the log level at runtime as follows:
Exponea.logger.logLevel = .verbose
For better visibility, log messages from the SDK are prefixed with
[EXP-iOS]
.
Authorization
Read Authorization to learn more about the different authorization modes supported by the SDK and how to use customer token authorization.
Data flushing
Read Data flushing to learn more about how the SDK uploads data to the Engagement API and how to customize this behavior.
Updated about 1 month ago