ObjcLDUser

@objc(LDUser)
public final class ObjcLDUser : NSObject

LDUser allows clients to collect information about users in order to refine the feature flag values sent to the SDK. For example, the client app may launch with the SDK defined anonymous user. As the user works with the client app, information may be collected as needed and sent to LaunchDarkly. The client app controls the information collected, which LaunchDarkly does not use except as the client directs to refine feature flags. Client apps should follow Apple’s Privacy Policy when collecting user information.

The SDK caches last known feature flags for use on app startup to provide continuity with the last app run. Provided the LDClient is online and can establish a connection with LaunchDarkly servers, cached information will only be used a very short time. Once the latest feature flags arrive at the SDK, the SDK no longer uses cached feature flags. The SDK retains feature flags on the last 5 client defined users. The SDK will retain feature flags until they are overwritten by a different user’s feature flags, or until the user removes the app from the device.

The SDK does not cache user information collected, except for the user key. The user key is used to identify the cached feature flags for that user. Client app developers should use caution not to use sensitive user information as the user-key.

  • LDUser attributes that can be marked private.

    The SDK will not include private attribute values in analytics events, but private attribute names will be sent.

    See Also: ObjcLDConfig.allUserAttributesPrivate, ObjcLDConfig.privateUserAttributes, and privateAttributes.

    Declaration

    Swift

    @objc
    public class var privatizableAttributes: [String] { get }
  • LDUser secondary attribute used to make secondary private

    Declaration

    Swift

    @objc
    public class var attributeSecondary: String { get }
  • LDUser name attribute used to make name private

    Declaration

    Swift

    @objc
    public class var attributeName: String { get }
  • LDUser firstName attribute used to make firstName private

    Declaration

    Swift

    @objc
    public class var attributeFirstName: String { get }
  • LDUser lastName attribute used to make lastName private

    Declaration

    Swift

    @objc
    public class var attributeLastName: String { get }
  • LDUser country attribute used to make country private

    Declaration

    Swift

    @objc
    public class var attributeCountry: String { get }
  • LDUser ipAddress attribute used to make ipAddress private

    Declaration

    Swift

    @objc
    public class var attributeIPAddress: String { get }
  • LDUser email attribute used to make email private

    Declaration

    Swift

    @objc
    public class var attributeEmail: String { get }
  • LDUser avatar attribute used to make avatar private

    Declaration

    Swift

    @objc
    public class var attributeAvatar: String { get }
  • LDUser custom attribute used to make custom private

    Declaration

    Swift

    @objc
    public class var attributeCustom: String { get }
  • key

    Client app defined string that uniquely identifies the user. If the client app does not define a key, the SDK will assign an identifier associated with the anonymous user. The key cannot be made private.

    Declaration

    Swift

    @objc
    public var key: String { get }
  • The secondary key for the user. See the documentation for more information on it’s use for percentage rollout bucketing.

    Declaration

    Swift

    @objc
    public var secondary: String? { get set }
  • Client app defined name for the user. (Default: nil)

    Declaration

    Swift

    @objc
    public var name: String? { get set }
  • Client app defined first name for the user. (Default: nil)

    Declaration

    Swift

    @objc
    public var firstName: String? { get set }
  • Client app defined last name for the user. (Default: nil)

    Declaration

    Swift

    @objc
    public var lastName: String? { get set }
  • Client app defined country for the user. (Default: nil)

    Declaration

    Swift

    @objc
    public var country: String? { get set }
  • Client app defined ipAddress for the user. (Default: nil)

    Declaration

    Swift

    @objc
    public var ipAddress: String? { get set }
  • Client app defined email address for the user. (Default: nil)

    Declaration

    Swift

    @objc
    public var email: String? { get set }
  • Client app defined avatar for the user. (Default: nil)

    Declaration

    Swift

    @objc
    public var avatar: String? { get set }
  • Client app defined dictionary for the user. The client app may declare top level dictionary items as private. If the client app defines custom as private, the SDK considers the dictionary private except for device & operatingSystem (which cannot be made private). See privateAttributes for details. (Default: nil)

    Declaration

    Swift

    @objc
    public var custom: [String : Any]? { get set }
  • Client app defined isAnonymous for the user. If the client app does not define isAnonymous, the SDK will use the key to set this attribute. isAnonymous cannot be made private. (Default: YES)

    Declaration

    Swift

    @objc
    public var isAnonymous: Bool { get set }
  • Client app defined device for the user. The SDK will determine the device automatically, however the client app can override the value. The SDK will insert the device into the custom dictionary. The device cannot be made private. (Default: the system identified device)

    Declaration

    Swift

    @objc
    public var device: String? { get set }
  • Client app defined operatingSystem for the user. The SDK will determine the operatingSystem automatically, however the client app can override the value. The SDK will insert the operatingSystem into the custom dictionary. The operatingSystem cannot be made private. (Default: the system identified operating system)

    Declaration

    Swift

    @objc
    public var operatingSystem: String? { get set }
  • Client app defined privateAttributes for the user.

    The SDK will not include private attribute values in analytics events, but private attribute names will be sent.

    This attribute is ignored if ObjcLDConfig.allUserAttributesPrivate is YES. Combined with ObjcLDConfig.privateUserAttributes. The SDK considers attributes appearing in either list as private. Client apps may define attributes found in privatizableAttributes and top level custom dictionary keys here. (Default: nil)

    See Also: ObjcLDConfig.allUserAttributesPrivate and ObjcLDConfig.privateUserAttributes.

    Declaration

    Swift

    @objc
    public var privateAttributes: [String]? { get set }
  • Initializer to create a LDUser. Client configurable attributes are set to their default value. The SDK will automatically set key, device, operatingSystem, and isAnonymous attributes. The SDK embeds device and operatingSystem into the custom dictionary for transmission to LaunchDarkly.

    Declaration

    Swift

    @objc
    override public init()
  • Initializer to create a LDUser with a specific key. Other client configurable attributes are set to their default value. The SDK will automatically set key, device, operatingSystem, and isAnonymous attributes. The SDK embeds device and operatingSystem into the custom dictionary for transmission to LaunchDarkly.

    Declaration

    Swift

    @objc
    public init(key: String)

    Parameters

    key

    String that uniquely identifies the user. If the client app does not define a key, the SDK will assign an identifier associated with the anonymous user.

  • Initializer that takes a NSDictionary and creates a LDUser from the contents. Uses any keys present to define corresponding attribute values. Initializes attributes not present in the dictionary to their default value. The initializer attempts to set device and operatingSystem from corresponding values embedded in custom. The initializer attempts to set feature flags from values set in config.

    Declaration

    Swift

    @objc
    public init(userDictionary: [String : Any])

    Parameters

    userDictionary

    NSDictionary with LDUser attribute keys and values.

  • Compares users by comparing their user keys only, to allow the client app to collect user information over time

    Declaration

    Swift

    @objc
    public func isEqual(object: Any) -> Bool