BaseMessage

@objc(SBDBaseMessage)
open class BaseMessage : NSObject, Codable, NSCopying, Injectable, SBCommand, SortableElement, Identifiable
extension BaseMessage: Mappable
extension BaseMessage: Serializable

The BaseMessage class represents the base message which is generated by a user or an admin. The UserMessage, the FileMessage and the AdminMessage are derived from this class.

  • id

    Identifier for the message conforming to Identifiable

    Declaration

    Swift

    @objc
    open var id: AnyHashable { get }
  • Undocumented

    Declaration

    Swift

    @objc
    open internal(set) var requestId: String { get }
  • Unique message ID.

    Declaration

    Swift

    @objc
    public let messageId: Int64
  • Message text.

    Declaration

    Swift

    @objc
    public let message: String
  • Represents the dispatch state of the message. If message is not dispatched completely to the Sendbird server, the value is .pending. If failed to send the message, the value is .failed. And if success to send the message, the value is .succeeded.

    Since

    3.0.173

    Declaration

    Swift

    @objc
    open internal(set) var sendingStatus: MessageSendingStatus { get }
  • The scheduled info of the message if this is a scheduled message.

    Since

    4.0.0

    Declaration

    Swift

    @objc
    open internal(set) var scheduledInfo: ScheduledInfo? { get }
  • Sender of the message. This is represented by Sender class.

    Declaration

    Swift

    @objc
    open var sender: Sender? { get }
  • Channel URL which has this message.

    Declaration

    Swift

    @objc
    public let channelURL: String
  • Channel type of this message.

    Declaration

    Swift

    @objc
    open internal(set) var channelType: ChannelType { get }
  • The list of users who was mentioned together with the message.

    Since

    3.0.90

    Declaration

    Swift

    @objc
    open var mentionedUsers: [User] { get }
  • Since

    3.0.103

    Declaration

    Swift

    @objc
    open internal(set) var mentionType: MentionType { get }
  • Represents target user IDs to mention when success to send the message. This value is valid only when the message is a pending message or failed message. If the message is a succeeded message, see mentionedUserIds

    Since

    3.0.147

    Note

    see mentionedUserIds when the message is a succeeded message.

    Declaration

    Swift

    @objc
    open internal(set) var requestedMentionUserIds: [String]? { get }
  • Message created time in millisecond(UTC).

    Declaration

    Swift

    @objc
    open internal(set) var createdAt: Int64 { get }
  • Message updated time in millisecond(UTC).

    Declaration

    Swift

    @objc
    public let updatedAt: Int64
  • The unique ID of the parent message. If the message object is a parent message or a single message without any reply, the value of this property is 0. If the object is a reply, the value is the unique ID of its parent message.

    Note

    The default value is 0.

    Since

    3.0.181

    Declaration

    Swift

    @objc
    open internal(set) var parentMessageId: Int64 { get }
  • The thread info that belongs to this message object.

    Since

    3.0.181

    Declaration

    Swift

    @objc
    open internal(set) var threadInfo: ThreadInfo { get }
  • Gets an array of meta arrays sorted by chronological order.

    Since

    3.0.148

    Declaration

    Swift

    @objc
    open internal(set) var metaArrays: [MessageMetaArray]? { get }
  • The custom data for message.

    Declaration

    Swift

    @objc
    open internal(set) var data: String { get }
  • Custom message type.

    Declaration

    Swift

    @objc
    public let customType: String?
  • Reaction list on this message

    Declaration

    Swift

    @objc
    open var reactions: [Reaction] { get }
  • Message survival seconds, default is -1

    Declaration

    Swift

    @objc
    open internal(set) var messageSurvivalSeconds: Int { get }
  • Whether the message is silent or not

    If the message is silent, last message won’t be changed and channelWasChanged(_:) will not get called on receiver’s sidel

    Since

    3.0.184

    Declaration

    Swift

    @objc
    open internal(set) var silent: Bool { get }
  • Whether the message is silent or not

    If the message is silent, last message won’t be changed and channelWasChanged(_:) will not get called on receiver’s sidel

    Since

    3.0.184

    Declaration

    Swift

    @objc
    open var isSilent: Bool { get }
  • The error code of file. This value generated only when message send fails.

    Since

    3.0.161

    Declaration

    Swift

    @objc
    open internal(set) var errorCode: UInt { get }
  • Optional open graph information if the message contains links. We only support first open graph tag appearance on the first link

    Since

    3.0.193

    Declaration

    Swift

    @objc
    public let ogMetaData: OGMetaData?
  • List of plugin that are corresponding to this message

    Since

    3.0.207

    Declaration

    Swift

    @objc
    public let plugins: [Plugin]?
  • Current message’s parent message object.

    When parentMessage is UserMessage it only has 3 properties: message, sender and createdAt When parentMessage is AdminMessage it only has 3 properties: message, sender and createdAt When parentMessage is FileMessage it only has 6 properties: message, sender, createdAt, name, url, type

    Since

    3.0.236

    Declaration

    Swift

    @objc
    open var parentMessage: BaseMessage?
  • Determines whether current message is also shown on channel.

    Since

    3.0.236

    Declaration

    Swift

    @objc
    public let isReplyToChannel: Bool
  • Represents whether this message was created by an operator.

    Since

    3.0.198

    Declaration

    Swift

    @objc
    open internal(set) var isOperatorMessage: Bool { get }
  • The template for the message that has the mentioned users.

    Declaration

    Swift

    @objc
    open internal(set) var mentionedMessageTemplate: String? { get }
  • Since

    4.11.0

    Declaration

    Swift

    @objc
    open internal(set) var notifiationData: NotificationData? { get }
  • Since

    4.13.0

    Declaration

    Swift

    @objc
    open internal(set) var notificationMessageStatus: NotificationMessageStatus { get }
  • An object that was used to resend this message. This property is valid when the sendingStatus is MessageSendingStatus.pending or MessageSendingStatus.failed. When this message is trying to be resent, this property will be used as well. If the message object is UserMessage class, then the messageParams has to be casted to UserMessageCreateParams class. If the message object is FileMessage class, then the messageParams has to be casted to FileMessageCreateParams class.

    Since

    3.1.0

    Declaration

    Swift

    @objc
    open internal(set) var messageParams: BaseMessageCreateParams? { get }
  • The template for the message.

    Since

    4.2.3

    Declaration

    Swift

    public let extendedMessage: [String : Any]
  • The datas for the message.

    Since

    4.12.2

    Declaration

    Swift

    public let extendedMessagePayload: [String : Any]
  • Default constructor.

    Declaration

    Swift

    public required 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]
  • 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

  • Checks the channel type is open channel or not.

    Declaration

    Swift

    open func isOpenChannel() -> Bool

    Return Value

    true when this message is in open channel.

  • Checks the channel type is group channel or not.

    Declaration

    Swift

    open func isGroupChannel() -> Bool

    Return Value

    true, when this message is in group channel.

  • Checks the channel type is feed channel or not.

    Since

    4.6.0

    Declaration

    Swift

    open func isFeedChannel() -> Bool

    Return Value

    true, when this message is in feed channel.

  • Checks message can resend.

    The message can only resend if the problem is due to network related error.

    Since

    3.0.161

    Declaration

    Swift

    open func isResendable() -> Bool

    Return Value

    true if this message can resend.

  • Returns an array of meta arrays for keys.

    Since

    3.0.148

    Declaration

    Swift

    open func metaArrays(keys: [String]) -> [MessageMetaArray]

    Parameters

    keys

    Keys of the meta array.

    Return Value

    An Array of meta array with keys.

  • Applies reaction event to this message

    Declaration

    Swift

    @discardableResult
    @objc(applyReactionEvent:)
    open func apply(_ reactionEvent: ReactionEvent) -> Bool

    Parameters

    reactionEvent

    ReactionEvent instance

    Return Value

    true if the given event was applied successfully

  • Applies the update of the thread information to the message object.

    Since

    3.0.181

    Declaration

    Swift

    @discardableResult
    @objc(applyThreadInfoUpdateEvent:)
    open func apply(_ threadInfoUpdateEvent: ThreadInfoUpdateEvent) -> Bool

    Parameters

    threadInfoUpdateEvent

    The event object that is applied to.

    Return Value

    true if threadInfoUpdateEventwas applied successfully otherwise false

  • Retrieves a message with a specified message ID.

    Since

    3.0.181

    Declaration

    Swift

    @objc(getMessageWithParams:completionHandler:)
    open class func getMessage(
        params: MessageRetrievalParams,
        completionHandler: BaseMessageHandler?
    )

    Parameters

    params

    Contains a set of parameters you can set regarding the messages in the results.

    completionHandler

    The handler block to be executed. The message retrieves the message with the matching message ID. A value of nil indicates that there is no message with the specified message ID. The error Indicates whether there is an error. If there is no error, the value is nil.

  • Retrieves the threaded replies of the current message depending on the timestamp. If the current message doesn’t have replies, the result is nil.

    Since

    3.0.181

    Declaration

    Swift

    @objc(getThreadedMessagesWithTimestamp:params:completionHandler:)
    open func getThreadedMessages(
        timestamp: Int64,
        params: ThreadedMessageListParams,
        completionHandler: ThreadedMessageListHandler?
    )

    Parameters

    timestamp

    Specifies the timestamp to be the reference point of the retrieval, in Unix milliseconds format.

    params

    Contains a set of parameters you can set regarding the messages in the results.

    completionHandler

    The handler block to be executed. The parentMessage retrieves the parent message of the thread. The threadedReplies retrieves the threaded replies in the thread. The error indicates whether there is an error. If there is no error, the value is nil.

  • Get a message to be sent at the specified time.

    Note

    If a user leaves before sending scheduled messages, the scheduled messages will be removed.

    Since

    4.0.0

    Declaration

    Swift

    @objc(getScheduledMessageWithParams:completionHandler:)
    open class func getScheduledMessage(
        params: ScheduledMessageRetrievalParams,
        completionHandler: BaseMessageHandler?
    )

    Parameters

    params

    The instance of ScheduledMessageRetrievalParams that can has parameters related with scheduled message.

    completionHandler

    The handler block to be executed after the message is registered in the schedule. This block has no return value and takes two argument, one is a user message is registered in the schedule and other is an error made when there is something wrong to message.

  • Submit data for a form type message. A form type message contains forms fields in the message’s extendedMessage. You can create formKey and answers parameters using form_key and field_key in the forms data.

    Since

    4.12.0

    Declaration

    Swift

    @objc(submitFormWithFormKey:answers:completionHandler:)
    open func submitForm(
        formKey: String,
        answers: [String: String],
        completionHandler: SBErrorHandler?
    )

    Parameters

    formKey

    Specifies the form_key in form data.

    answers

    The data type is [String: String]. The key should be the key of the field, and the value should be the string value to store.

    completionHandler

    The handler block to be executed after the answer is submitted.

  • Copies this object

    Declaration

    Swift

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

    Parameters

    zone

    optional NSZone

    Return Value

    BaseMessage instance

  • Copies this message with fail state

    Declaration

    Swift

    @objc
    open func copyWithFailedState() -> Self

    Return Value

    copied object with error code

  • Copies this message with fail state

    Declaration

    Swift

    @objc
    open func copyWithFailedState(errorCode: Int) -> Self

    Parameters

    errorCode

    error code

    Return Value

    copied object with error code

  • Copies this message with fail state

    Declaration

    Swift

    public func copyWithFailedState(errorCode: Int?) -> Self

    Parameters

    errorCode

    error code

    Return Value

    copied object with error code

  • Serializes this object into data

    Declaration

    Swift

    open func serialize() -> Data?

    Return Value

    optioanal Data instance

  • Deserializes and reconstructs the object

    Declaration

    Swift

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

    Parameters

    data

    Data instance

    Return Value

    BaseMessage if parameter is valid, otherwise nil

  • Deserializes and reconstructs the object

    Since

    3.0.203

    Declaration

    Swift

    @objc
    open class func build(fromSerializedData data: Data?, desiredState: MessageSendingStatus) -> `Self`?

    Parameters

    data

    Data instance

    Return Value

    BaseMessage if parameter is valid, otherwise nil