MarketingCloudSdk

Overview 

Package: com.salesforce.marketingcloud

Interfaces: ControlChannel.ControlChannelListener, ModuleInterface

The main SDK class for Salesforce Marketing Cloud Unified SDK. This class provides the primary interface for initializing and interacting with the Marketing Cloud SDK.


Nested Types 

InitializationListener 

1interface InitializationListener

An interface that provides an InitializationStatus when SDK initialization completes.

WhenReadyListener 

1interface WhenReadyListener

An interface that provides a valid MarketingCloudSdk instance when ready.


Properties 

analyticsManager 

1@NonNull
2open val analyticsManager: AnalyticsManager

Provides access to the analytics management functionality.


instance 

1@Nullable
2open val instance: MarketingCloudSdk

Returns the current SDK instance, or null if not initialized.


isInitializing 

1open val isInitializing: Boolean

Indicates whether the SDK is currently in the initialization process.


isReady 

1open val isReady: Boolean

Indicates whether the SDK has completed initialization and is ready to use.


Methods 

init 

1@MainThread
2open fun init(
3    @NonNull context: Context,
4    @NonNull config: MarketingCloudConfig,
5    @Nullable listener: InitializationListener
6)

Initializes the SDK with the provided configuration. Must be called from the main thread.

Parameters:

  • context - Android application context
  • config - Marketing Cloud configuration object
  • listener - Optional callback for initialization completion

requestSdk 

1open fun requestSdk(@NonNull listener: WhenReadyListener)

Asynchronous request for an SDK instance.

Parameters:

  • listener - Callback that receives the SDK instance when ready
1open fun requestSdk(
2    @Nullable looper: Looper,
3    @NonNull listener: WhenReadyListener
4)

Asynchronous request for an SDK instance with custom looper.

Parameters:

  • looper - Custom looper for callback execution
  • listener - Callback that receives the SDK instance when ready

unregisterWhenReadyListener 

1open fun unregisterWhenReadyListener(@NonNull listener: WhenReadyListener)

Prevents a WhenReadyListener from receiving the SDK instance.

Parameters:

  • listener - The listener to unregister

getMarketingCloudConfig 

1@NonNull
2open fun getMarketingCloudConfig(): MarketingCloudConfig

Returns: The MarketingCloudConfig instance used to initialize the SDK.


getInitializationStatus 

1@NonNull
2open fun getInitializationStatus(): InitializationStatus

Returns: The current initialization status of the SDK.


getRegistrationManager 

1@NonNull
2open fun getRegistrationManager(): RegistrationManager

Returns: The registration manager for device registration operations.


getInboxMessageManager 

1@NonNull
2open fun getInboxMessageManager(): InboxMessageManager

Returns: The inbox message manager for handling inbox messages.


getRegionMessageManager 

1@NonNull
2open fun getRegionMessageManager(): RegionMessageManager

Returns: The region message manager for location-based messaging.


getSdkState 

1@NonNull
2open fun getSdkState(): JSONObject

Returns: A JSON object containing the current state of the SDK.


getSdkVersionName 

1@NonNull
2open fun getSdkVersionName(): String

Returns: The version name of the SDK as a string.


getSdkVersionCode 

1open fun getSdkVersionCode(): Int

Returns: The version code of the SDK as an integer.


setLogLevel 

1open fun setLogLevel(level: Int)

Sets the logging level for the SDK.

Parameters:

  • level - The desired log level

getLogLevel 

1open fun getLogLevel(): Int

Returns: The current log level.


setLogListener 

1open fun setLogListener(@Nullable logListener: MCLogListener)

Sets a custom log listener for SDK logging events.

Parameters:

  • logListener - Optional custom log listener implementation

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!