DriverAttributes

@objc
public class DriverAttributes : NSObject, NSCopying

Additional attributes of a Zendrive driver.

The application can specify both predefined and custom attributes for a driver. These attributes are associated with a SDK driverId at SDK initialization time. In addition to predefined special attributes, up to 4 custom key value attributes can be associated with a driver using the Zendrive SDK.

Warning

All attribute keys can be atmost 64 characters in length.

Warning

All attribute values can be atmost 1024 characters in length.
  • A unique id that associates the current user to a group. This groupId will be made available as a query parameter to filter users in the reports and API that Zendrive provides.

    For example, ‘EastCoast’ and ‘WestCoast’ can be groupIds to distinguish users from these regions. Another example would be using city names as groupIds. Check Zendrive.isValidInputParameter(_:) method to validate group id. Setting an invalid groupId is a no-op and would log an error.

    Declaration

    Swift

    @objc
    public func setGroup(_ groupId: String) -> Bool

    Parameters

    groupId

    A string representing the group of a user.

    Return Value

    true, if the value was set, false otherwise.

  • The service level of a driver. This is useful for applications where Zendrive supports different service levels for different drivers. See ServiceLevel for more information about this attribute.

    Declaration

    Swift

    @objc
    public func setServiceLevel(_ serviceLevel: ServiceLevel) -> Bool

    Parameters

    serviceLevel

    service tier of the user.

  • Set the custom attribute of the user.

    Up to 4 custom attributes can be set for a user. A new value for an existing key would be overwritten only if the value length is within 1024 characters, otherwise the original value would be retained.

    Declaration

    Swift

    @objc
    public func setCustomAttribute(_ value: String, forKey key: String) -> Bool

    Parameters

    key

    A key for the custom attribute. The maximum key length is 64 characters.

    value

    Value of the custom attribute. The maximum value length is 1024 characters.

    Return Value

    true, if the value was set, false otherwise.

  • Alias is a string placeholder offered as a convenience for developers to create a reference for a driver

    Declaration

    Swift

    @objc
    public func setAlias(_ alias: String) -> Bool

    Parameters

    alias

    service tier of the user.

    Return Value

    true, if the value was set, false otherwise.

  • Returns driver attributes as a json string. Empty string if json serialization fails.

    Declaration

    Swift

    @objc
    public func asJson() -> String
  • Returns the driver attributes as a dictionary.

    Declaration

    Swift

    @objc
    public func asDictionary() -> [AnyHashable : Any]
  • NSCopying protocol confirmance

    Declaration

    Swift

    @objc
    public func copy(with zone: NSZone? = nil) -> Any
  • Creates a DriverAttributes object.

    Declaration

    Swift

    @objc
    public override convenience init()