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
IdentifiableDeclaration
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
mentionedUserIdsSince
3.0.147Note
seementionedUserIdswhen 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.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
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) 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
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
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
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
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
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 feedback data.
Since
4.14.0Declaration
Swift
open func submitFeedback( rating: Feedback.Rating, comment: String? = nil, completionHandler: FeedbackHandler? = nil )Parameters
ratingRatingenum value.commentFeedback string comment (optional).
completionHandlerThe 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
ratingRatingenum value.commentFeedback string comment (optional).
completionHandlerThe handler block to be executed after the feedback is updated.
-
Delete feedback data.
Since
4.14.0Declaration
Swift
open func deleteFeedback(completionHandler: SBErrorHandler?)Parameters
completionHandlerThe 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
formsfields in the message’sextendedMessagePayload. Theformsproperty is the instance that contains the form information. Using the givenFormmodel, You can createformKeyandanswersviaformKeyandfields.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
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.
-
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
formsfields in the message’sextendedMessagePayload. Theformsproperty is the instance that contains the form information. Using the givenFormmodel, You can do that just by updating thetemporaryAnswerproperty 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
formA form instance with the answer to submit updated in
temporaryAnswer.completionHandlerThe handler block to be executed after the answer is submitted.
-
Submit data for a form type message. A form type message contains
formfields in the message’sextendedMessagePayload. TheBaseMessage/formproperty is the instance that contains the form information. Using the givenMessageFormmodel, You can do that just by updating theFormItem/temporaryAnswerproperty of each of thefields.Since
4.21.0
Declaration
Swift
open func submitMessageForm( completionHandler: SBErrorHandler? )Parameters
formA message form instance with the answer to submit updated in
temporaryAnswer.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
open func copyWithFailedState() -> SelfReturn Value
copied object with error code
-
Copies this message with fail state
Declaration
Swift
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
open class func build(fromSerializedData data: Data?, desiredState: MessageSendingStatus) -> Self?Parameters
dataDatainstancedesiredStateThe sending status that a message object will have.
Return Value
BaseMessageif parameter is valid, otherwisenil
View on GitHub
Install in Dash