Identity

Class

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.

Declaration 

1@objc(SFIdentity)
2public final class Identity : NSObject
3
4@objc
5public func toJson() -> String
6
7public func edit(identity updater: @escaping (IdentityModifier) -> IdentityModifier)
8
9public func get() -> IdentityInfo?

Cases 

toJson() 

Converts the current identity information to a JSON string representation.

1@objc
2public func toJson() -> String

edit(identity:) 

Updates the identity information using a modifier closure. This method provides thread-safe access to modify identity data. The updater closure receives an IdentityModifier object 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.

1public func edit(identity updater: @escaping (IdentityModifier) -> IdentityModifier)

get() 

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 .

1public func get() -> IdentityInfo?

Returns: An IdentityInfo object containing the current identity data, or nil if no identity record is found or if the identity manager is not properly initialized.