Identity
@objc(SFIdentity)
public final class Identity : NSObject
Main class for managing identity information in the Salesforce Marketing Cloud SDK.
The Identity class provides a singleton interface for managing user identity data,
including profile information, custom attributes, and party identification details.
All operations are performed thread-safely using an internal worker queue.
-
Converts the current identity information to a JSON string representation.
Declaration
Swift
@objc public func toJson() -> String -
Updates the identity information using a modifier closure.
This method provides thread-safe access to modify identity data. The updater closure receives an
IdentityModifierobject that allows you to modify profile ID, attributes, and party identification information. All modifications are persisted to the database and trigger identity change events.Thread Safety:
This method is thread-safe and uses an internal worker queue to ensure that identity modifications don’t interfere with other operations.
Persistence:
All changes made through this method are automatically persisted to the database and will trigger identity change events that other SDK modules can observe.
Declaration
Swift
public func edit(identity updater: @escaping (IdentityModifier) -> IdentityModifier)Parameters
updaterA closure that receives an
IdentityModifierand returns the modifiedIdentityModifierwith the desired changes. The closure is executed synchronously on a background worker queue. -
Retrieves the current identity information.
This method returns the current identity data including profile ID, attributes, and party identification information. The data is retrieved from the in-memory cache for optimal performance.
Thread Safety:
This method is thread-safe and uses an internal worker queue to ensure consistent data access.
Performance:
This method retrieves data from the in-memory cache, making it very fast. If no identity has been set, it returns
nil.Declaration
Swift
public func get() -> IdentityInfo?Return Value
An
IdentityInfoobject containing the current identity data, ornilif no identity record is found or if the identity manager is not properly initialized.
Identity Class Reference