GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

Initialize the iOS SDK

Best practice: Initialize the Experiences SDK as early as possible when your app loads (for example, in applicationDidFinishLaunching). Early initialization improves performance and keeps analytics stable.

The iOS SDK initialization section guides on setting up the Experiences SDK, detailing the method signature and parameters like API key, externalUserId, and more for custom configuration. It covers initialization errors like invalid API keys or network failures and emphasizes managing user sessions for personalized experiences.

SDK Init

func initialize(apiKey: String,
                externalUserId: String? = nil,
                cachingSize: Int? = nil,
                prefetchingPolicy: BlazeCachePolicyLevel = .Default,
                geo: String? = nil,
                delegate: BlazeSDKDelegate? = nil,
                resultBlock: BlazeResultBlock?)

Description

Initialization method of the BlazeSDK.

Parameters:

ParameterDescription
apiKeyThe API key
externalUserIdThe viewer ID for a logged-in viewer. Your app supplies this value. See Viewer ID specifications.
cachingSizeThe amount of possible cached content size restricted in MBs
prefetchingPolicyThe level of content prefetching, which is determined by the BlazeCachePolicyLevel enum type.
geoAn optional country code to filter Geo-blocked content. This value overrides the default IP-based country detection used to define the viewer's location
delegateAn object that receives global delegate events callbacks. optional.
resultBlockA closure that captures success or a possible initialization error of BlazeSDK

Initialization errors:

  • invalidApiKey: Invalid API Key passed to the initializer. Please carefully check the provided API Key.
  • networkFailure: Failed to initialize due to a network error.
  • alreadyInitialized: SDK can be initialized only once.
  • initializationIsRequired: SDK must be initialized before attempting to perform any operations.
  • invalidGeoCode: The Geo code provided to the initialization method is not a valid ISO 3166 country code.
📘

Overview

The externalUserId parameter is used to uniquely identify a user session when initializing our SDK. This identifier serves as a key for customizing and tracking user-related activities during the SDK session.

  • Overriding Behavior
    If you re-initialize the SDK with a new externalUserId, the SDK will override the previous user identifier. The new externalUserId will be used for all subsequent activities and tracking. The previous viewer's unsynced activity is sent to WSC Sports, and their activity is cleared from the device. The previous identifier stays valid: set it again and that viewer's activity is restored.
  • Clearing Previous User Identifier
    If you initialize the SDK with externalUserId set to nil, it will clear the previous user identifier, effectively anonymizing the session. Activities in this state will not be associated with any user identifier until a new externalUserId is set.
  • Recommended Practice
    Due to our overriding and clearing behavior, it is crucial to use careful logic in your application to manage when and how to initialize new sessions. Make sure that you are intentionally setting or clearing externalUserId based on the desired outcome for user tracking and activity management.

Did this page help you?