I am trying to implement the MarketingCloudSDK for our iOS app and have a question about initialization of the SDK. We need to set the analyticsEnabled value in the ConfigBuilder during initialization based on the users preferences if they want marketing notificatoins or not. We use redux for our architecture, so we do not have access to the app state in our app delegate, as it has not been setup yet. Therefore I need to delay the SDK initialization until we get the app state setup.

I have this working, and the initialization happens when I expect it to happen, based on when the user sets their preferences. I am just curious if there is any downside to initializing the SDK multiple times? Currently on app launch it will initialize based on the default app state, then we will initialize again, when we get the users preferences from user defaults, as well as any time the user manually changes this preference in settings.

We are also setting the ContactKey in the same manner. Is it required to set this after the initialization, or will it remember this value if the SDK is re-initialized?

Here's the current function that I'm calling to initialize the SDK to determine if we need to allow analytics or not.

    private func registerSalesforce(analyticsEnabled: Bool) {

        let configuration = PushConfigBuilder(appId: appID)
            .setMarketingCloudServerUrl(URL(string: appEndpoint)!)
        SFMCSdk.initializeSdk(ConfigBuilder().setPush(config: configuration).build())

        if SFMCSdk.mp.getStatus() == .operational, App.configuration == .debug {


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy