- Access to a Business Profile
- Created Client API Key
- Recommended Environment:
- Xcode 11
- iOS SDK 13
- Target Deployment: iOS 9.0+
- Valid architectures:
- armv7, armv7s, arm64 for devices
- i386, x86_64 for simulators
The Synerise SDK references the following frameworks:
CocoaPods is a dependency manager for Cocoa projects.
If you don’t have CocoaPods installed yet and don’t know it, please start with CocoaPods - Getting Started.
Once you have CocoaPods installed you should add dependency to Synerise SDK into your
use_frameworks! target YOUR_PROJECT_TARGET do pod 'SyneriseSDK' end
After that, execute the following shell command in directory depending on your project configuration:
pod repo update pod install
Carthage is simple, decentralized dependency manager for Cocoa projects.
If you don’t have Carthage installed yet and don’t know it, please start with Carthage project on GitHub.
Once you have Carthage installed you should add dependency to Synerise SDK into your
Then, you should execute shell command in directory depending on your project configuration:
Go to Xcode project target’s General section.
<YOUR_XCODE_PROJECT_DIRECTORY>/Carthage/Build/iOSin Finder and drag
SyneriseSDK.frameworkto Embedded Binaries.
Make sure Copy items if needed is selected and click Finish.
Import Synerise SDK
You will need to import Synerise SDK header into the files that contain code relating to SDK.
Go to Xcode project target’s General section, find Other Linker Flags property and add -ObjC flag.
If you are going to use Push Notifications:
- Go to
- Add a row for Required background mode of type Array with App downloads content in response to push notifications or add code below directly:
<key>UIBackgroundModes</key> <array> <string>remote-notification</string> </array>
- Go to
If you are going to use HTTP addresses (instead only HTTPS), you will need to change whitelist domains in your app by adding appropriate configuration to
- You can add configured domain/domains that you need.
- Give permission for all domains.
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>yourdomain.com</key> <dict> <!--Include to allow subdomains--> <key>NSIncludesSubdomains</key> <true/> <!--Include to allow HTTP requests--> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <!--Include to specify minimum TLS version--> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.1</string> </dict> </dict> </dict>
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key><true/> </dict>
First of all, you need to initialize Synerise SDK and provide Client API Key.
You may initialize it wherever you want and when you need.
let clientApiKey = "YOUR_CLIENT_API_KEY" Synerise.initialize(clientApiKey: clientApiKey) // 1 Synerise.setDebugModeEnabled(true) // 2 Synerise.setCrashHandlingEnabled(true) // 3 Synerise.setDelegate(self) // 3
Let’s dive into some configurable functionalities:
Synerise.initialize(clientApiKey:)- initializes Synerise SDK.
Synerise.setDebugModeEnabled(_:)- enables debug mode for Synerise SDK. See Debug logs section for more information.
Synerise.setCrashHandlingEnabled(_:)- enables crash handling. Synerise SDK sends a crash event automatically when an uncaught exception occurs.
Synerise.setDelegate(_:)- sets delegate to handle actions from Synerise SDK. See Synerise SDK Delegate section for more information.
Initialization with custom API environment
There is option to change API base URL for on-premise installations.
One thing you have to do for that is using different initialization method:
Synerise.initialize(clientApiKey: "YOUR_CLIENT_API_KEY", baseUrl: "YOUR_API_BASE_URL")
This is an example of advanced initialization with:
- custom API base URL for on-premise installations
- debug mode enabled
- crash handling enabled
- most of settings options available
- main delegate SNRSyneriseDelegate
Synerise.setDebugModeEnabled(true) Synerise.setCrashHandlingEnabled(true) Synerise.settings.sdk.appGroupIdentifier = "YOUR_APP_GROUP_IDENTIFIER" Synerise.settings.sdk.keychainGroupIdentifier = "YOUR_KEYCHAIN_GROUP_IDENTIFIER" Synerise.settings.sdk.shouldDestroySessionOnApiKeyChange = false Synerise.settings.notifications.disableInAppAlerts = true Synerise.settings.notifications.encryption = false Synerise.settings.tracker.minBatchSize = 5 Synerise.settings.tracker.maxBatchSize = 20 Synerise.settings.tracker.autoFlushTimeout = 5.0 Synerise.settings.tracker.autoTracking.mode = .fine Synerise.settings.tracker.locationAutomatic = true Synerise.settings.injector.automatic = true Synerise.initialize(clientApiKey: "YOUR_CLIENT_API_KEY", baseUrl: "YOUR_API_BASE_URL") Synerise.setDelegate(self) Client.setClientStateDelegate(self)
You can enable debug logs for Synerise SDK by method
Synerise.setDebugModeEnabled(true) // 1 Tracker.setLoggingEnabled(true) // 2
- It enables logging for all modules.
- It enables/disables for concrete module, in this case - Tracker.
You can receive some logs about:
- Core: push notifications
- Tracker: autotracking events, declarative events, sending process
- Customer: customer state, authorization
- Injector: campaigns, UI
- Promotions: promotions, vouchers
- Content: content widget, documents, recommendations
Crash handler allows you to find customers whose mobile applications crashed and to see information about that in their customer cards in CRM as events.
You can enable crash handling for Synerise SDK by using the
When it is enabled, SyneriseSDK passes info about customer application crashes as dedicated events to the backend (
client.applicationCrashed is the
action parameter of those events).
Synerise SDK Delegate
You can handle Synerise SDK initialization result by two methods:
snr_initialized()- This method is called when Synerise is initialized.
snr_initializationError(error:)- This method is called when an error occurs while Synerise initialization.
You can specify your custom action when a customer clicks on simple push, banner or walkthrough. Synerise SDK implements two main actions that customer may invoke - open URL and Deeplink:
snr_handledAction(url:)- This method is called when Synerise handles URL action from campaign activities.
snr_handledAction(deepLink:)- This method is called when Synerise handles deeplink action from campaign activities.
snr_handledAction(url:activity:completionHandler:)- This method is called when Synerise handles URL action from campaign activities.
snr_handledAction(deepLink:activity:completionHandler:)- This method is called when Synerise handles deeplink action from campaign activities.
There is also another method, that invokes when Synerise SDK needs re-registration for push notifications:
snr_registerForPushNotificationsIsNeeded()- This method is called when Synerise needs registration for Push Notifications.