SFMCSdk

Class

Declaration 

1@objc(SFMCSdk)
2public final class SFMCSdk : NSObject
3
4@objc
5public static var cdp: CDP
6
7@objc
8public static var personalization: PERSONALIZATION
9
10@objc
11public static let identity: Identity
12
13@objc
14public static func initializeSdk(_ configuration: Config, completion: ((_ status: [ModuleInitStatus]) -> Void)? = nil)
15
16@objc
17public static func state() -> String
18
19@objc
20public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter())
21
22public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter(), filters: [LoggerCategory] = [LoggerCategory]())
23
24@objc
25public static func getLogLevel() -> LogLevel
26
27@objc
28public static func clearLoggerFilters()
29
30@objc
31public static func setFileProtectionType(fileProtectionType: FileProtectionType?)
32
33@objc
34public static func fileProtectionType() -> FileProtectionType?
35
36@objc
37public static func requestPersonalizationSdk(_ callback: @escaping () -> Void)
38
39@objc
40public static func requestCdpSdk(_ callback: @escaping (_ cdp: CdpInterface) -> Void)
41
42@objc
43public static func getStatus(module: ModuleName) -> ModuleStatus
44
45@objc
46public static func track(event: Event)
47
48@objc
49public static func sendImmediate(event: Event)
50
51@objc
52public static func flush()

SFMCSDK Modules 

cdp 

1@objc
2public static var cdp: CDP

personalization 

1@objc
2public static var personalization: PERSONALIZATION

identity 

1@objc
2public static let identity: Identity

SFMCSDK Methods 

initializeSdk(_:completion:) 

1@objc
2public static func initializeSdk(_ configuration: Config, completion: ((_ status: [ModuleInitStatus]) -> Void)? = nil)

state() 

1@objc
2public static func state() -> String

Logger Methods 

setLogger(logLevel:logOutputter:) 

1@objc
2public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter())

setLogger(logLevel:logOutputter:filters:) 

1public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter(), filters: [LoggerCategory] = [LoggerCategory]())

getLogLevel() 

1@objc
2public static func getLogLevel() -> LogLevel

clearLoggerFilters() 

1@objc
2public static func clearLoggerFilters()

File Protection Helpers 

setFileProtectionType(fileProtectionType:) 

Provides a way to set/override the Protection level for File system

1@objc
2public static func setFileProtectionType(fileProtectionType: FileProtectionType?)

fileProtectionType() 

Returns File protection type set by the SDK or overridden value by the consuming application

1@objc
2public static func fileProtectionType() -> FileProtectionType?

SDK Getters 

requestPersonalizationSdk(_:) 

Requests the Personalization Module/SDK when it’s operational and safe to use. The provided callback will be invoked when Personalization is ready. The host app shouldn’t normally need to use this, as the Personalization module itself already does this for async operations, like fetching decisions/personalization. As Personalization intentionally doesn’t expose much functionality to the base SFMCSdk, one could use PersonalizationModule.shared within the callback code to use module-specific functionality.

1@objc
2public static func requestPersonalizationSdk(_ callback: @escaping () -> Void)

requestCdpSdk(_:) 

Requests the CDP Module/SDK when it’s operational and safe to use. The provided callback will be invoked when CDP Is ready.

1@objc
2public static func requestCdpSdk(_ callback: @escaping (_ cdp: CdpInterface) -> Void)

getStatus(module:) 

Returns the current operational status of the specified module. This method can be called at any time, even before the module is operational.

1@objc
2public static func getStatus(module: ModuleName) -> ModuleStatus

User Triggered Events 

track(event:) 

Tracks a custom event which are dispatched to all registered SDK modules. Events are processed asynchronously and may be batched before being sent to the network. Use [sendImmediate] for time-sensitive events that should bypass normal queuing.

1@objc
2public static func track(event: Event)

sendImmediate(event:) 

Tracks a custom event at high priority and schedules it to be sent to the server along with any other pending events in the queue. Unlike [track], this attempts to deliver queued events promptly rather than waiting for the next scheduled interval. This API is subject to SDK guardrails — there is a 60-second throttling period between consecutive calls. Use it only when timely delivery is important.

1@objc
2public static func sendImmediate(event: Event)

flush() 

Schedules a flush of any queued events. The flush is subject to SDK guardrails — notably, a 60-second throttling period between consecutive flush calls. If a flush was recently performed, the request will be deferred until the throttle window has elapsed. Use this only when prompt delivery is critical. Calling it frequently will not accelerate delivery and may be throttled by the SDK.

1@objc
2public static func flush()