Class
Declaration
@objc(SFMCSdk)
public final class SFMCSdk : NSObject
@objc
public static var cdp: CDP
@objc
public static var personalization: PERSONALIZATION
@objc
public static let identity: Identity
@objc
public static func initializeSdk(_ configuration: Config, completion: ((_ status: [ModuleInitStatus]) -> Void)? = nil)
@objc
public static func state() -> String
@objc
public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter())
public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter(), filters: [LoggerCategory] = [LoggerCategory]())
@objc
public static func getLogLevel() -> LogLevel
@objc
public static func clearLoggerFilters()
@objc
public static func setFileProtectionType(fileProtectionType: FileProtectionType?)
@objc
public static func fileProtectionType() -> FileProtectionType?
@objc
public static func requestPersonalizationSdk(_ callback: @escaping () -> Void)
@objc
public static func requestCdpSdk(_ callback: @escaping (_ cdp: CdpInterface) -> Void)
@objc
public static func getStatus(module: ModuleName) -> ModuleStatus
@objc
public static func track(event: Event)
@objc
public static func sendImmediate(event: Event)
@objc
public static func flush()
SFMCSDK Modules
cdp
@objc
public static var cdp: CDP
personalization
@objc
public static var personalization: PERSONALIZATION
identity
@objc
public static let identity: Identity
SFMCSDK Methods
initializeSdk(_:completion:)
@objc
public static func initializeSdk(_ configuration: Config, completion: ((_ status: [ModuleInitStatus]) -> Void)? = nil)
state()
@objc
public static func state() -> String
Logger Methods
setLogger(logLevel:logOutputter:)
@objc
public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter())
setLogger(logLevel:logOutputter:filters:)
public static func setLogger(logLevel: LogLevel, logOutputter: LogOutputter? = LogOutputter(), filters: [LoggerCategory] = [LoggerCategory]())
getLogLevel()
@objc
public static func getLogLevel() -> LogLevel
clearLoggerFilters()
@objc
public static func clearLoggerFilters()
File Protection Helpers
setFileProtectionType(fileProtectionType:)
Provides a way to set/override the Protection level for File system
@objc
public static func setFileProtectionType(fileProtectionType: FileProtectionType?)
fileProtectionType()
Returns File protection type set by the SDK or overridden value by the consuming application
@objc
public 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.
@objc
public 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.
@objc
public 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.
@objc
public 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.
@objc
public 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.
@objc
public 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.
@objc
public static func flush()