MessageClient
public class MessageClient
An iOS client wrapper of the Cisco Spark Message APIs.
Since
1.4.0-
Callback when receive Message.
Since
1.4.0Declaration
Swift
public var onEvent: ((MessageEvent) -> Void)? { get set } -
Lists all messages in a room by room Id. If present, it includes the associated media content attachment for each message. The list sorts the messages in descending order by creation date.
Since
1.2.0Declaration
Swift
@available(*, deprecated: 1.4.0, renamed: "list(roomId:before:max:mentionedPeople:queue:completionHandler:﹚") public func list(roomId: String, before: String? = nil, beforeMessage: String? = nil, max: Int? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<[Message]>) -> Void)Parameters
roomIdThe identifier of the room.
beforeIf not nil, only list messages sent only before this date and time, in ISO8601 format.
beforeMessageIf not nil, only list messages sent only before this message by id.
maxLimit the maximum number of messages in the response, default is 50.
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
-
Lists all messages in a room by room Id. If present, it includes the associated media content attachment for each message. The list sorts the messages in descending order by creation date. This Api will automatically register phone to websocket, if phone was not been registered before.
Since
1.4.0Declaration
Swift
public func list(roomId: String, before: Before? = nil, max: Int = 50, mentionedPeople: Mention? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<[Message]>) -> Void)Parameters
roomIdThe identifier of the room.
beforeIf not nil, only list messages sent only before this condition.
maxLimit the maximum number of messages in the response, default is 50.
mentionedPeopleList messages where the caller is mentioned by using Mention.person(
me
).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
-
Posts a plain text message, and optionally, a media content attachment, to a room by room Id.
Since
1.2.0Declaration
Swift
@available(*, deprecated: 1.4.0, renamed: "post(roomId:text:mentions:files:queue:completionHandler:﹚") public func post(roomId: String, text: String, files: String? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
roomIdThe identifier of the room where the message is to be posted.
textThe plain text message to be posted to the room.
filesA public URL that Cisco Spark can use to fetch attachments. Currently supports only a single URL. Cisco Spark downloads the content from the URL one time shortly after the message is created and automatically converts it to a format that all Cisco Spark clients can render.
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
-
Posts a media content attachment to a room by room Id without text.
Since
1.2.0Declaration
Swift
@available(*, deprecated: 1.4.0, renamed: "post(roomId:text:mentions:files:queue:completionHandler:﹚") public func post(roomId: String, files: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
roomIdThe identifier of the room.
filesA public URL that Cisco Spark can use to fetch attachments. Currently supports only a single URL. Cisco Spark downloads the content from the URL one time shortly after the message is created and automatically converts it to a format that all Cisco Spark clients can render.
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
-
Posts a private 1:1 message in plain text, and optionally, a media content attachment, to a person by person Id.
Since
1.2.0Declaration
Swift
@available(*, deprecated: 1.4.0, renamed: "post(personId:text:mentions:files:queue:completionHandler:﹚") public func post(personId: String, text: String, files: String? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personIdThe identifier of the recipient of this private 1:1 message.
textThe plain text message to post to the recipient.
filesA public URL that Cisco Spark can use to fetch attachments. Currently supports only a single URL. Cisco Spark downloads the content from the URL one time shortly after the message is created and automatically converts it to a format that all Cisco Spark clients can render.
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
-
Posts a media content attachment to a person by person Id without text.
Since
1.2.0Declaration
Swift
@available(*, deprecated: 1.4.0, renamed: "post(personId:text:mentions:files:queue:completionHandler:﹚") public func post(personId: String, files: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personIdThe identifier of the recipient of this media content.
filesA public URL that Cisco Spark can use to fetch attachments. Currently supports only a single URL. Cisco Spark downloads the content from the URL one time shortly after the message is created and automatically converts it to a format that all Cisco Spark clients can render.
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
-
Posts a private 1:1 message in plain text, and optionally, a media content attachment, to a person by person Id.
Since
1.2.0Declaration
Swift
@available(*, deprecated: 1.4.0, renamed: "post(email:text:mentions:files:queue:completionHandler:﹚") public func post(personEmail: EmailAddress, text: String, files: String? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personEmailThe email address of the recipient when sending a private 1:1 message.
textThe plain text message to post to the room.
filesA public URL that Spark can use to fetch attachments. Currently supports only a single URL. The Spark Cloud downloads the content one time shortly after the message is created and automatically converts it to a format that all Spark clients can render.
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
-
Posts a media content attachment to a person by email address without text.
Since
1.2.0Declaration
Swift
@available(*, deprecated: 1.4.0, renamed: "post(email:text:mentions:files:queue:completionHandler:﹚") public func post(personEmail: EmailAddress, files: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personEmailThe email address of the recipient of this media content.
filesA public URL that Spark can use to fetch attachments. Currently supports only a single URL. The Spark Cloud downloads the content one time shortly after the message is created and automatically converts it to a format that all Spark clients can render.
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
-
Posts a plain text message, optionally a media content attachment, to a room by user email. This Api will automatically register phone to websocket, if phone was not been registered before.
Since
1.4.0Declaration
Swift
public func post(personEmail: EmailAddress, text: String? = nil, files: [LocalFile]? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personEmailThe EmailAddress of the user to whom the message is to be posted.
contentThe plain text message to be posted to the room.
filesLocal file objects to be uploaded to the room.
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
-
Posts a plain text message, optionally a media content attachment, to a room by person id. This Api will automatically register phone to websocket, if phone was not been registered before.
Since
1.4.0Declaration
Swift
public func post(personId: String, text: String? = nil, files: [LocalFile]? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
personIdThe personId of the user to whom the message is to be posted.
textThe plain text message to be posted to the room.
filesLocal file objects to be uploaded to the room.
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
-
Posts a plain text message, optionally a media content attachment, to a room by roomId. This Api will automatically register phone to websocket, if phone was not been registered before.
Since
1.4.0Declaration
Swift
public func post(roomId: String, text: String? = nil, mentions: [Mention]? = nil, files: [LocalFile]? = nil, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)Parameters
roomIdThe identifier of the room where the message is to be posted.
textThe plain text message to be posted to the room.
mentionsThe mention items to be posted to the room.
filesLocal file objects to be uploaded to the room.
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
-
Detail of one message. This Api will automatically register phone to websocket, if phone was not been registered before.
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 request has finished.
Return Value
Void
-
Deletes a message, to a room by messageId. This Api will automatically register phone to websocket, if phone was not been registered before.
Since
1.2.0Declaration
Swift
public func delete(messageId: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Any>) -> Void)Parameters
messageIdThe messageId to be deleted in the room.
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 object, save the file to pointed destination. This Api will automatically register phone to websocket, if phone was not been registered before.
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.
toThe local file directory for saving dwonloaded file.
progressHandlerThe download progress indicator.
completionHandlerDownloaded file local address wiil be stored in
file.localFileUrl
Return Value
Void
-
Download a file object, save the file thumbnail. This Api will automatically register phone to websocket, if phone was not been registered before.
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 need to be downloaded.
toThe local file directory for saving file after download.
progressHandlerThe download progress indicator.
completionHandlerDownloaded file local address wiil be stored in
file.localFileUrl
Return Value
Void
View on GitHub
MessageClient Class Reference