User

@objc(SBDUser)
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

    @objc
    open var id: String { get }
  • User ID. This has to be unique.

    Declaration

    Swift

    @objc
    public let userId: String
  • User nickname.

    Declaration

    Swift

    @objc
    open internal(set) var nickname: String { get }
  • Profile image url.

    Declaration

    Swift

    @objc
    open var profileURL: String? { get }
  • Original profile image url.

    Declaration

    Swift

    @objc
    open var originalProfileURL: String? { get }
  • The profile image URL without the ekey.

    Since

    3.0.194

    Declaration

    Swift

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

    Declaration

    Swift

    @objc
    open internal(set) var connectionStatus: UserConnectionStatus { get }
  • The lastest time when the user became offline.

    Declaration

    Swift

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

    Declaration

    Swift

    @objc
    public let isActive: Bool
  • Discovery key for friend

    Declaration

    Swift

    @objc
    public let friendDiscoveryKey: String?
  • User name for friend

    Declaration

    Swift

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

    Since

    4.9.4

    Declaration

    Swift

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

    Since

    3.0.159

    Declaration

    Swift

    @objc
    open internal(set) var preferredLanguages: [String]? { get }
  • Meta data.

    Declaration

    Swift

    @objc
    open var metaData: [String : String] { get }
  • 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