SecurePrefs

@objc(SFMCSdkSecurePrefs)
public class SecurePrefs : NSObject

This class provides helper methods for storage.

  • Tag: SecurePrefs

Set/Update Methods

  • Stores a String value with the provided key. Key and value are both encrypted.

    Declaration

    Swift

    @objc
    public func setString(_ value: String, for key: String)

    Parameters

    value

    The String value to be encrypted and stored

    key

    The key used to extract the value from storage

  • Stores a Int value with the provided key. Key and value are both encrypted.

    Declaration

    Swift

    @objc
    public func setInt(_ value: Int, for key: String)

    Parameters

    value

    The Int value to be encrypted and stored

    key

    The key used to extract the value from storage

  • Stores a Bool value with the provided key. Key and value are both encrypted.

    Declaration

    Swift

    @objc
    public func setBool(_ value: Bool, for key: String)

    Parameters

    value

    The Bool value to be encrypted and stored

    key

    The key used to extract the value from storage

  • Sets a Float value in the keychain with the provided key. Key and value are both encrypted.

    Declaration

    Swift

    @objc
    public func setFloat(_ value: Float, for key: String)

    Parameters

    value

    The Float value to be encrypted and stored

    key

    The key used to extract the value from storage

  • Sets a Double value in the keychain with the provided key. Key and value are both encrypted.

    Declaration

    Swift

    @objc
    public func setDouble(_ value: Double, for key: String)

    Parameters

    value

    The Double value to be encrypted and stored

    key

    The key used to extract the value from storage

Read Methods

  • Extracts the String value for the provided key in storage

    Declaration

    Swift

    @objc
    public func stringFor(key: String) -> String?

    Parameters

    key

    The key associated with the value being stored

    Return Value

    The string value stored or nil if not present

  • Extracts the Int value for the provided key in storage

    Declaration

    Swift

    public func intFor(key: String) -> Int?

    Parameters

    key

    The key associated with the Int being stored

    Return Value

    The Int value stored or nil if not present

  • Extracts the Bool value for the provided key in storage

    Declaration

    Swift

    public func boolFor(key: String) -> Bool?

    Parameters

    key

    The key associated with the Bool being stored

    Return Value

    The Bool value stored or nil if not present

  • Extracts the Float value for the provided key in storage

    Declaration

    Swift

    public func floatFor(key: String) -> Float?

    Parameters

    key

    The key associated with the Float being stored

    Return Value

    The Float value stored or nil if not present

  • Extracts the Double value for the provided key in storage

    Declaration

    Swift

    public func doubleFor(key: String) -> Double?

    Parameters

    key

    The key associated with the Double being stored

    Return Value

    The Double value stored or nil if not present

Delete Methods

  • Removes the value associated with the provided key

    Declaration

    Swift

    @objc
    public func remove(key: String)

    Parameters

    key

    The key for the value to be removed

  • Clears all data stored in the SecurePrefs Object and makes it a dead object unable to save or extract data. SecurePrefs will have to be re-initialized again.

    Declaration

    Swift

    @objc
    public func clearAll()