Getting Started

Requirements


  • 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

Frameworks


The Synerise SDK references the following frameworks:

  • Foundation.framework
  • UIKit.framework
  • UserNotifications.framework
  • CommonCrypto.framework
  • CoreTelephony.framework
  • WebKit.framework

Installation


CocoaPods

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.

  1. Once you have CocoaPods installed you should add dependency to Synerise SDK into your Podfile:

    use_frameworks!
    
    target YOUR_PROJECT_TARGET do
      pod 'SyneriseSDK'
    end
    
  2. After that, execute the following shell command in directory depending on your project configuration:

    pod repo update
    pod install
    

Carthage

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.

  1. Once you have Carthage installed you should add dependency to Synerise SDK into your Cartfile:

    github "synerise/ios-sdk"
    
  2. Then, you should execute shell command in directory depending on your project configuration:

    carthage update
    
  3. Go to Xcode project target's General section.

  4. Open <YOUR_XCODE_PROJECT_DIRECTORY>/Carthage/Build/iOS in Finder and drag SyneriseSDK.framework to Embedded Binaries.

  5. Make sure Copy items if needed is selected and click Finish.

Configuration


Import Synerise SDK

You will need to import Synerise SDK header into the files that contain code relating to SDK.

import SyneriseSDK
Note: In Objective-C, you can either include it in your Prefix Header (PCH) and Synerise SDK will be imported to all files automatically.

Setting up

  1. Go to Xcode project target's General section, find Other Linker Flags property and add -ObjC flag.

  2. If you are going to use Push Notifications:

    • Go to Info.plist.
    • 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>
    
  3. 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 Info.plist.

    • 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>
    

Initialization


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:

  1. Synerise.initialize(clientApiKey:) - initializes Synerise SDK.
  2. Synerise.setDebugModeEnabled(_:) - enables debug mode for Synerise SDK. See Debug logs section for more information.
  3. Synerise.setCrashHandlingEnabled(_:) - enables crash handling. Synerise SDK sends a crash event automatically when an uncaught exception occurs.
  4. 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:

let clientApiKey = "YOUR_CLIENT_API_KEY"
let apiBaseUrl = "YOUR_API_BASE_URL"

Synerise.initialize(clientApiKey: clientApiKey, baseUrl: apiBaseUrl)

Debug logs


You can enable debug logs for Synerise SDK by method Synerise.setDebugModeEnabled(_:).

Synerise.setDebugModeEnabled(true) // 1
Tracker.setLoggingEnabled(true) // 2
  1. It enables logging for all modules.
  2. 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
  • Client: client state, authorization
  • Injector: campaigns, UI
  • Promotions: promotions, vouchers
  • Content: content widget, documents, recommendations
Important: It is not recommended to use debug mode in a release version of your app.

Crash handling


Crash handler allows you to find users 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 Synerise.setCrashHandlingEnabled(_:) method.

When it is enabled, SyneriseSDK passes info about user application crashes as dedicated events to the backend (client.applicationCrashed is the action parameter of those events).

Synerise.setCrashHandlingEnabled(true)

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 user clicks on simple push, banner or walkthrough. Synerise SDK implements two main actions that user 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.
Note: For more information about handling actions from Synerise SDK, see Campaigns section.

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.
Note: For more information about notifications, see Configure Notifications section.
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.