MessageClient
public class MessageClient
MessageClient represents a client to the Webex platform. It can send and receive messages.
Use Webex.messages to get an instance of MessageClient.
Since
1.4.0-
The callback handler for incoming message events.
Since
1.4.0Declaration
Swift
public var onEvent: ((MessageEvent) -> Void)? -
The callback handler for incoming message events.
Since
2.3.0Declaration
Swift
public var onEventWithPayload: ((MessageEvent, WebexEventPayload) -> Void)? -
Lists all messages in a space by space Id. The list sorts the messages in descending order by creation date.
Note that the file attachment of the message are not downloaded. Use the
downloadFile(...)ordownloadThumbnail(...)to download the actual content or the thumbnail of the attachment.Since
1.4.0Declaration
Swift
public func list(spaceId: String, before: Before? = nil, max: Int = 50, mentionedPeople: Mention? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<[Message]>) -> Void)Parameters
spaceIdThe identifier of the space.
beforeIf not nil, only list messages sent before this condition.
maxLimit the maximum number of messages in the response, default is 50.
mentionedPeopleList messages where a person (using
Mention.person) or all (usingMention.all) is mentioned.queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the request has finished with a list of messages based on the above criteria.
Return Value
Void
-
Posts a message with optional file attachments to a user by email address.
The content of the message can be plain text, html, or markdown.
Since
2.3.0Declaration
Swift
public func post(_ text: Message.Text? = nil, toPersonEmail: EmailAddress, withFiles: [LocalFile]? = nil, parent: Message? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
toPersonEmailThe email address of the user to whom the message is to be posted.
withFilesLocal files to be uploaded with the message.
parentIf not nil, the sent message will belong to the thread of the parent message.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is posted.
Return Value
Void
-
Posts a message with optional file attachments to a user by id.
The content of the message can be plain text, html, or markdown.
Since
2.3.0Declaration
Swift
public func post(_ text: Message.Text? = nil, toPerson: String, withFiles: [LocalFile]? = nil, parent: Message? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
toPersonThe id of the user to whom the message is to be posted.
withFilesLocal files to be attached to the message.
parentIf not nil, the sent message will belong to the thread of the parent message.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is posted.
Return Value
Void
-
Posts a message with optional file attachments to a space by spaceId.
The content of the message can be plain text, html, or markdown.
To notify specific person or everyone in a space, mentions should be used. Having
@johndoein the content of the message does not generate notification.Since
2.3.0Declaration
Parameters
toSpaceThe identifier of the space where the message is to be posted.
mentionsNotify these mentions.
withFilesLocal files to be uploaded to the space.
parentIf not nil, the sent message will belong to the thread of the parent message.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is posted.
Return Value
Void
-
Edit a message without attachment.
Note
Only be able to edit messages without attachments.Since
2.8.0Declaration
Swift
public func edit(_ text: Message.Text, parent: Message, mentions: [Mention]? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
textThe message text is used to replace old one.
parentThe message you are editing.
mentionsnew message Mention objects.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is edited, will callback an edited message object.
Return Value
Void
-
Retrieves the details of a message by id.
Note that the file attachment of the message are not downloaded. Use the
downloadFile(...)ordownloadThumbnail(...)to download the actual content or the thumbnail of the attachment.Since
1.2.0Declaration
Swift
public func get(messageId: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
messageIdThe identifier of the message.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is retrieved.
Return Value
Void
-
Deletes a message by id.
Since
1.2.0Declaration
Swift
public func delete(messageId: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Any>) -> Void)Parameters
messageIdThe identifier of the message to be deleted.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is deleted.
Return Value
Void
-
Mark all messages in the space read.
Since
2.3.0Declaration
Swift
public func markAsRead(spaceId: String, messageId: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Any>) -> Void)Parameters
spaceIdThe identifier of the space where the message is.
messageIdThe identifier of the message which user read.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the request has finished.
Return Value
Void
-
Mark all messages in the space read.
Since
2.3.0Declaration
Swift
public func markAsRead(spaceId: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Any>) -> Void)Parameters
spaceIdThe identifier of the space where the message is.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the request has finished.
Return Value
Void
-
Download a file attachement to the specified local directory.
Since
1.4.0Declaration
Swift
public func downloadFile(_ file: RemoteFile, to: URL? = nil, progressHandler: ((Double) -> Void)? = nil, completionHandler: @escaping (Result<URL>) -> Void)Parameters
fileThe RemoteFile object need to be downloaded. Use
Message.remoteFilesto get the references.toThe local file directory for saving dwonloaded file attahement.
progressHandlerThe download progress indicator.
completionHandlerA closure to be executed once the download is completed. The URL contains the path to the downloded file.
Return Value
Void
-
Download the thumbnail for a file attachment to the specified local directory. Note Cisco Webex doesn’t generate thumbnail for all files.
Since
1.4.0Declaration
Swift
public func downloadThumbnail(for file: RemoteFile, to: URL? = nil, progressHandler: ((Double) -> Void)? = nil, completionHandler: @escaping (Result<URL>) -> Void)Parameters
fileThe RemoteFile object whose thumbnail needs to be downloaded.
toThe local file directory for saving downloaded thumbnail.
progressHandlerThe download progress indicator.
completionHandlerA closure to be executed once the download is completed. The URL contains the path to the downloded thumbnail.
Return Value
Void
-
Posts a message with optional file attachments to a user by email address.
The content of the message can be plain text, html, or markdown.
Since
1.4.0Declaration
Swift
@available(*, deprecated) public func post(personEmail: EmailAddress, text: String? = nil, files: [LocalFile]? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personEmailThe email address of the user to whom the message is to be posted.
contentThe content of message to be posted to the user. The content can be plain text, html, or markdown.
filesLocal files to be uploaded with the message.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is posted.
Return Value
Void
-
Posts a message with optional file attachments to a user by id.
The content of the message can be plain text, html, or markdown.
Since
1.4.0Declaration
Swift
@available(*, deprecated) public func post(personId: String, text: String? = nil, files: [LocalFile]? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personIdThe id of the user to whom the message is to be posted.
textThe content message to be posted to the user. The content can be plain text, html, or markdown.
filesLocal files to be attached to the message.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is posted.
Return Value
Void
-
Posts a message with optional file attachments to a space by spaceId.
The content of the message can be plain text, html, or markdown.
To notify specific person or everyone in a space, mentions should be used. Having
@johndoein the content of the message does not generate notification.Since
1.4.0Declaration
Swift
@available(*, deprecated) public func post(spaceId: String, text: String? = nil, mentions: [Mention]? = nil, files: [LocalFile]? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
spaceIdThe identifier of the space where the message is to be posted.
textThe content message to be posted to the space. The content can be plain text, html, or markdown.
mentionsNotify these mentions.
filesLocal files to be uploaded to the space.
queueIf not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.
completionHandlerA closure to be executed once the message is posted.
Return Value
Void
View on GitHub
MessageClient Class Reference