BaseMessage
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
open var id: AnyHashable
-
Undocumented
Declaration
Swift
open internal(set) var requestId: String
-
Unique message ID.
Declaration
Swift
public let messageId: Int64
-
Message text.
Declaration
Swift
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
open internal(set) var sendingStatus: MessageSendingStatus
-
The scheduled info of the message if this is a scheduled message.
Since
4.0.0Declaration
Swift
open internal(set) var scheduledInfo: ScheduledInfo?
-
Channel URL which has this message.
Declaration
Swift
public let channelURL: String
-
Channel type of this message.
Declaration
Swift
open internal(set) var channelType: ChannelType
-
The list of users who was mentioned together with the message.
Since
3.0.90Declaration
Swift
open var mentionedUsers: [User]
-
Since
3.0.103Declaration
Swift
open internal(set) var mentionType: MentionType
-
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
open internal(set) var requestedMentionUserIds: [String]?
-
Message created time in millisecond(UTC).
Declaration
Swift
open internal(set) var createdAt: Int64
-
Message updated time in millisecond(UTC).
Declaration
Swift
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
open internal(set) var parentMessageId: Int64
-
The thread info that belongs to this message object.
Since
3.0.181Declaration
Swift
open internal(set) var threadInfo: ThreadInfo
-
Gets an array of meta arrays sorted by chronological order.
Since
3.0.148Declaration
Swift
open internal(set) var metaArrays: [MessageMetaArray]?
-
The custom data for message.
Declaration
Swift
open internal(set) var data: String
-
Custom message type.
Declaration
Swift
public let customType: String?
-
Reaction list on this message
Declaration
Swift
open var reactions: [Reaction]
-
Undocumented
Declaration
Swift
open internal(set) var messageSurvivalSeconds: Int
-
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
open internal(set) var silent: Bool
-
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
open var isSilent: Bool
-
The error code of file. This value generated only when message send fails.
Since
3.0.161Declaration
Swift
open internal(set) var errorCode: UInt
-
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
public let ogMetaData: OGMetaData?
-
List of plugin that are corresponding to this message
Since
3.0.207Declaration
Swift
public let plugins: [Plugin]?
-
Current message’s parent message object.
Note
- It does not contain all properties of the parent message.
- Only contains:
- common:
customType
,message
,timestamp
,sender
,data
- FileMessage:
url
,plainURL
,name
,size
,type
,thumbnails
- common:
Since
3.0.236
Declaration
Swift
open var parentMessage: BaseMessage?
-
Determines whether current message is also shown on channel.
Since
3.0.236Declaration
Swift
public let isReplyToChannel: Bool
-
Represents whether this message was created by an operator.
Since
3.0.198Declaration
Swift
open internal(set) var isOperatorMessage: Bool
-
The template for the message that has the mentioned users.
Declaration
Swift
open internal(set) var mentionedMessageTemplate: String?
-
Since
4.11.0Declaration
Swift
open internal(set) var notifiationData: NotificationData?
-
Since
4.13.0Declaration
Swift
open internal(set) var notificationMessageStatus: NotificationMessageStatus = .none
-
Since
4.22.0Declaration
Swift
open private(set) var templateMessageData: TemplateMessageData?
-
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
open internal(set) var messageParams: BaseMessageCreateParams?
-
Since
4.14.0Declaration
Swift
public var myFeedback: Feedback?
-
Since
4.14.0Declaration
Swift
public var myFeedbackStatus: Feedback.Status
-
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]
-
list of string options.
Since
4.14.1Declaration
Swift
public let suggestedReplies: [String]?
-
List of form data.
Since
4.14.1Declaration
Swift
@available(*, deprecated, message: "This property is deprecated in 4.21.0. Please use `messageForm` single value property") public var forms: [Form]?
-
Message form data.
Since
4.21.0Declaration
Swift
public let messageForm: MessageForm?
-
This field is intended to store temporary in-memory data, such as UI interaction configurations.
Note
This field is not locally cached and data is not restored, so it is not suitable for storing data for long periods of time.Warning
Even if the message ID is the same, the value of this property will be different if the reference of the message object is different.Since
4.15.0Declaration
Swift
public var inMemoryUserInfo: [String: Any]?
-
Priority for notification. This is valid in the notification message. The default value is
normal
.Since
4.16.0Declaration
Swift
open internal(set) var notificationPriority: NotificationPriority
-
Additional information to support the notification
Since
4.18.0Declaration
Swift
public let notificationEventDeadline: Int64
-
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
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
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
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
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
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 feedback data.
Since
4.14.0Declaration
Swift
open func submitFeedback( rating: Feedback.Rating, comment: String? = nil, completionHandler: FeedbackHandler? = nil )
Parameters
rating
Rating
enum value.comment
Feedback string comment (optional).
completionHandler
The handler block to be executed after the feedback is submitted.
-
Update feedback data.
Since
4.14.0Declaration
Swift
open func updateFeedback( rating: Feedback.Rating, comment: String? = nil, completionHandler: FeedbackHandler? = nil )
Parameters
rating
Rating
enum value.comment
Feedback string comment (optional).
completionHandler
The handler block to be executed after the feedback is updated.
-
Delete feedback data.
Since
4.14.0Declaration
Swift
open func deleteFeedback(completionHandler: SBErrorHandler?)
Parameters
completionHandler
The handler block to be executed after the feedback is deleted.
-
Warning
This method will always fail because it is an interface that is no longer supported Submit data for a form type message. A form type message contains
forms
fields in the message’sextendedMessagePayload
. Theforms
property is the instance that contains the form information. Using the givenForm
model, You can createformKey
andanswers
viaformKey
andfields
.Since
4.12.0
Declaration
Swift
@available(*, deprecated, renamed: "submitMessageForm(form:completionHandler:﹚", message: "This method is deprecated in 4.14.1.") open func submitForm( formKey: String, answers: [String: String], completionHandler: SBErrorHandler? )
Parameters
formKey
Specifies the
form_key
inform
data.answers
The data type is
[String: String]
. The key should be thekey
of thefield
, and the value should be thestring
value to store.completionHandler
The handler block to be executed after the answer is submitted.
-
Warning
This method will always fail because it is an interface that is no longer supported Submit data for a form type message. A form type message contains
forms
fields in the message’sextendedMessagePayload
. Theforms
property is the instance that contains the form information. Using the givenForm
model, You can do that just by updating thetemporaryAnswer
property of each of thefields
.Since
4.14.1
Declaration
Swift
@available(*, deprecated, renamed: "submitMessageForm(form:completionHandler:﹚", message: "This method is deprecated in 4.21.0.") open func submitForm( form: Form, completionHandler: SBErrorHandler? )
Parameters
form
A form instance with the answer to submit updated in
temporaryAnswer
.completionHandler
The handler block to be executed after the answer is submitted.
-
Submit data for a form type message. A form type message contains
form
fields in the message’sextendedMessagePayload
. TheBaseMessage/form
property is the instance that contains the form information. Using the givenMessageForm
model, You can do that just by updating theFormItem/temporaryAnswer
property of each of thefields
.Since
4.21.0
Declaration
Swift
open func submitMessageForm( completionHandler: SBErrorHandler? )
Parameters
form
A message form instance with the answer to submit updated in
temporaryAnswer
.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
open func copyWithFailedState() -> Self
Return Value
copied object with error code
-
Copies this message with fail state
Declaration
Swift
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
open class func build(fromSerializedData data: Data?, desiredState: MessageSendingStatus) -> Self?
Parameters
data
Data
instancedesiredState
The sending status that a message object will have.
Return Value
BaseMessage
if parameter is valid, otherwisenil