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.
-
Identifier for the message conforming to
IdentifiableDeclaration
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.173Declaration
Swift
@objc open internal(set) var sendingStatus: MessageSendingStatus { get } -
The scheduled info of the message if this is a scheduled message.
Since
4.0.0Declaration
Swift
@objc open internal(set) var scheduledInfo: ScheduledInfo? { 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.90Declaration
Swift
@objc open var mentionedUsers: [User] { get } -
Since
3.0.103Declaration
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
mentionedUserIdsSince
3.0.147Note
seementionedUserIdswhen 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 is0.Since
3.0.181Declaration
Swift
@objc open internal(set) var parentMessageId: Int64 { get } -
The thread info that belongs to this message object.
Since
3.0.181Declaration
Swift
@objc open internal(set) var threadInfo: ThreadInfo { get } -
Gets an array of meta arrays sorted by chronological order.
Since
3.0.148Declaration
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 sidelSince
3.0.184Declaration
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 sidelSince
3.0.184Declaration
Swift
@objc open var isSilent: Bool { get } -
The error code of file. This value generated only when message send fails.
Since
3.0.161Declaration
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.193Declaration
Swift
@objc public let ogMetaData: OGMetaData? -
List of plugin that are corresponding to this message
Since
3.0.207Declaration
Swift
@objc public let plugins: [Plugin]? -
Current message’s parent message object.
When
parentMessageisUserMessageit only has 3 properties:message,senderandcreatedAtWhenparentMessageisAdminMessageit only has 3 properties:message,senderandcreatedAtWhenparentMessageisFileMessageit only has 6 properties:message,sender,createdAt,name,url,typeSince
3.0.236Declaration
Swift
@objc open var parentMessage: BaseMessage? -
Determines whether current message is also shown on channel.
Since
3.0.236Declaration
Swift
@objc public let isReplyToChannel: Bool -
Represents whether this message was created by an operator.
Since
3.0.198Declaration
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.0Declaration
Swift
@objc open internal(set) var notifiationData: NotificationData? { get } -
Since
4.13.0Declaration
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.pendingorMessageSendingStatus.failed. When this message is trying to be resent, this property will be used as well. If the message object isUserMessageclass, then themessageParamshas to be casted toUserMessageCreateParamsclass. If the message object isFileMessageclass, then themessageParamshas to be casted toFileMessageCreateParamsclass.Since
3.1.0Declaration
Swift
@objc open internal(set) var messageParams: BaseMessageCreateParams? { get } -
The template for the message.
Since
4.2.3Declaration
Swift
public let extendedMessage: [String : Any] -
The datas for the message.
Since
4.12.2Declaration
Swift
public let extendedMessagePayload: [String : Any] -
Default constructor.
Declaration
Swift
public required init(from decoder: Decoder) throwsParameters
decoderDecoderinstance -
Encodes this object.
Declaration
Swift
public func encode(to encoder: Encoder) throwsParameters
encoderEncoderinstance -
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?) -> BoolParameters
objectAnyinstanceReturn Value
trueif same otherwisefalse -
Checks the channel type is open channel or not.
Declaration
Swift
open func isOpenChannel() -> BoolReturn Value
truewhen this message is in open channel. -
Checks the channel type is group channel or not.
Declaration
Swift
open func isGroupChannel() -> BoolReturn Value
true, when this message is in group channel. -
Checks the channel type is feed channel or not.
Since
4.6.0Declaration
Swift
open func isFeedChannel() -> BoolReturn 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.161Declaration
Swift
open func isResendable() -> BoolReturn Value
trueif this message can resend. -
Returns an array of meta arrays for keys.
Since
3.0.148Declaration
Swift
open func metaArrays(keys: [String]) -> [MessageMetaArray]Parameters
keysKeys 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) -> BoolParameters
reactionEventReactionEventinstanceReturn Value
trueif the given event was applied successfully -
Applies the update of the thread information to the message object.
Since
3.0.181Declaration
Swift
@discardableResult @objc(applyThreadInfoUpdateEvent:) open func apply(_ threadInfoUpdateEvent: ThreadInfoUpdateEvent) -> BoolParameters
threadInfoUpdateEventThe event object that is applied to.
Return Value
trueifthreadInfoUpdateEventwas applied successfully otherwisefalse -
Retrieves a message with a specified message ID.
Since
3.0.181Declaration
Swift
@objc(getMessageWithParams:completionHandler:) open class func getMessage( params: MessageRetrievalParams, completionHandler: BaseMessageHandler? )Parameters
paramsContains a set of parameters you can set regarding the messages in the results.
completionHandlerThe handler block to be executed. The
messageretrieves the message with the matching message ID. A value ofnilindicates that there is no message with the specified message ID. TheerrorIndicates whether there is an error. If there is no error, the value isnil. -
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.181Declaration
Swift
@objc(getThreadedMessagesWithTimestamp:params:completionHandler:) open func getThreadedMessages( timestamp: Int64, params: ThreadedMessageListParams, completionHandler: ThreadedMessageListHandler? )Parameters
timestampSpecifies the timestamp to be the reference point of the retrieval, in Unix milliseconds format.
paramsContains a set of parameters you can set regarding the messages in the results.
completionHandlerThe handler block to be executed. The
parentMessageretrieves the parent message of the thread. ThethreadedRepliesretrieves the threaded replies in the thread. Theerrorindicates whether there is an error. If there is no error, the value isnil. -
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.0Declaration
Swift
@objc(getScheduledMessageWithParams:completionHandler:) open class func getScheduledMessage( params: ScheduledMessageRetrievalParams, completionHandler: BaseMessageHandler? )Parameters
paramsThe instance of
ScheduledMessageRetrievalParamsthat can has parameters related with scheduled message.completionHandlerThe 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
formsfields in the message’sextendedMessage. You can createformKeyandanswersparameters usingform_keyandfield_keyin theformsdata.Since
4.12.0
Declaration
Swift
@objc(submitFormWithFormKey:answers:completionHandler:) open func submitForm( formKey: String, answers: [String: String], completionHandler: SBErrorHandler? )Parameters
formKeySpecifies the
form_keyinformdata.answersThe data type is
[String: String]. The key should be thekeyof thefield, and the value should be thestringvalue to store.completionHandlerThe handler block to be executed after the answer is submitted.
-
Copies this object
Declaration
Swift
open func copy(with zone: NSZone? = nil) -> AnyParameters
zoneoptional
NSZoneReturn Value
BaseMessageinstance -
Copies this message with fail state
Declaration
Swift
@objc open func copyWithFailedState() -> SelfReturn Value
copied object with error code
-
Copies this message with fail state
Declaration
Swift
@objc open func copyWithFailedState(errorCode: Int) -> SelfParameters
errorCodeerror code
Return Value
copied object with error code
-
Copies this message with fail state
Declaration
Swift
public func copyWithFailedState(errorCode: Int?) -> SelfParameters
errorCodeerror code
Return Value
copied object with error code
-
Serializes this object into data
Declaration
Swift
open func serialize() -> Data?Return Value
optioanal
Datainstance -
Deserializes and reconstructs the object
Declaration
Swift
open class func build(fromSerializedData data: Data?) -> `Self`?Parameters
dataDatainstanceReturn Value
BaseMessageif parameter is valid, otherwisenil -
Deserializes and reconstructs the object
Since
3.0.203Declaration
Swift
@objc open class func build(fromSerializedData data: Data?, desiredState: MessageSendingStatus) -> `Self`?Parameters
dataDatainstanceReturn Value
BaseMessageif parameter is valid, otherwisenil
View on GitHub
Install in Dash
BaseMessage Class Reference