User

open class User: NSObject, Codable, Identifiable, Injectable
extension User: Mappable
extension User: NSCopying
extension User: Serializable

The User class represents a user. The user is identified by the userId, so the userId has to be unique. The userId, nickname and profileURL are valid in every User instance, however the connectionStatus and lastSeenAt is valid in User instance from UserListQuery.

  • id

    Identifier for the user conforming to Identifiable

    Declaration

    Swift

    open var id: String
  • User ID. This has to be unique.

    Declaration

    Swift

    public let userId: String
  • User nickname.

    Declaration

    Swift

    open internal(set) var nickname: String
  • Profile image url.

    Declaration

    Swift

    open var profileURL: String?
  • Original profile image url.

    Declaration

    Swift

    open var originalProfileURL: String?
  • The profile image URL without the ekey.

    Since

    3.0.194

    Declaration

    Swift

    open internal(set) var plainProfileImageURL: String?
  • User connection status. This is defined in UserConnectionStatus.

    Declaration

    Swift

    open internal(set) var connectionStatus: UserConnectionStatus
  • The lastest time when the user became offline.

    Declaration

    Swift

    open internal(set) var lastSeenAt: Int64
  • Represents the user is activated. This property is changed by the Platform API

    Declaration

    Swift

    public let isActive: Bool
  • Discovery key for friend

    Declaration

    Swift

    public let friendDiscoveryKey: String?
  • User name for friend

    Declaration

    Swift

    public let friendName: String?
  • Shows if the user is a bot or not.

    Since

    4.9.4

    Declaration

    Swift

    public let isBot: Bool
  • User’s preferred language. Used for translating messages.

    Since

    3.0.159

    Declaration

    Swift

    open internal(set) var preferredLanguages: [String]?
  • Meta data.

    Declaration

    Swift

    open var metaData: [String: String]
  • Default constructor.

    Declaration

    Swift

    required public init(from decoder: Decoder) throws

    Parameters

    decoder

    Decoder instance

  • Encodes this object.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    Encoder instance

  • Initialize with json dictionary

    Declaration

    Swift

    public func initWithDictionary(_ json: [String: Any]) -> Self?
  • Converts the object into dictionary

    Declaration

    Swift

    public func _toDictionary() -> [String: Any]
  • Creates the meta data for the current user.

    Declaration

    Swift

    func createMetaData(
        _ metaData: [String: String],
        completionHandler: MetaDataHandler?
    )

    Parameters

    metaData

    The meta data to be set.

    completionHandler

    The handler block to execute. metaData is the meta data which are set on Sendbird server.

  • Updates the meta data for the current user.

    Declaration

    Swift

    func updateMetaData(
        _ metaData: [String: String],
        completionHandler: MetaDataHandler?
    )

    Parameters

    metaData

    The meta data to be updated.

    completionHandler

    The handler block to execute. metaData is the meta counters which are updated on Sendbird server.

  • Deletes meta data with key for the current user.

    Declaration

    Swift

    func deleteMetaData(key: String, completionHandler: SBErrorHandler?)

    Parameters

    key

    The key to be deleted.

    completionHandler

    The handler block to execute.

  • Deletes all meta data for the current user.

    Declaration

    Swift

    func deleteAllMetaData(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to execute.

  • Compares this object with given other object.

    Declaration

    Swift

    public override func isEqual(_ object: Any?) -> Bool

    Parameters

    object

    Any instance

    Return Value

    true if same otherwise false

  • Copies this object

    Declaration

    Swift

    public func copy(with zone: NSZone? = nil) -> Any

    Parameters

    zone

    optional NSZone

    Return Value

    User instance

  • Serializes this object into data

    Declaration

    Swift

    public func serialize() -> Data?

    Return Value

    optioanal Data instance

  • Deserializes and reconstructs the object

    Declaration

    Swift

    public class func build(fromSerializedData data: Data?) -> Self?

    Parameters

    data

    Data instance

    Return Value

    User if parameter is valid, otherwise nil