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
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.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
mentionedUserIds
Since
3.0.147Note
seementionedUserIds
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 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
parentMessage
isUserMessage
it only has 3 properties:message
,sender
andcreatedAt
WhenparentMessage
isAdminMessage
it only has 3 properties:message
,sender
andcreatedAt
WhenparentMessage
isFileMessage
it only has 6 properties:message
,sender
,createdAt
,name
,url
,type
Since
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 }
-
An object that was used to resend this message. This property is valid when the sendingStatus is
MessageSendingStatus.pending
orMessageSendingStatus.failed
. When this message is trying to be resent, this property will be used as well. If the message object isUserMessage
class, then themessageParams
has to be casted toUserMessageCreateParams
class. If the message object isFileMessage
class, then themessageParams
has to be casted toFileMessageCreateParams
class.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]
-
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
instanceReturn Value
true
if same otherwisefalse
-
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.0Declaration
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.161Declaration
Swift
open func isResendable() -> Bool
Return Value
true
if this message can resend. -
Returns an array of meta arrays for keys.
Since
3.0.148Declaration
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
instanceReturn Value
true
if 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) -> Bool
Parameters
threadInfoUpdateEvent
The event object that is applied to.
Return Value
true
ifthreadInfoUpdateEvent
was 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
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 ofnil
indicates that there is no message with the specified message ID. Theerror
Indicates 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
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. ThethreadedReplies
retrieves the threaded replies in the thread. Theerror
indicates 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
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.
-
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
instanceReturn Value
BaseMessage
if 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
data
Data
instanceReturn Value
BaseMessage
if parameter is valid, otherwisenil