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.0

    Declaration

    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.0

    Declaration

    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

    roomId

    The identifier of the room.

    before

    If not nil, only list messages sent only before this date and time, in ISO8601 format.

    beforeMessage

    If not nil, only list messages sent only before this message by id.

    max

    Limit the maximum number of messages in the response, default is 50.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    Swift

    public func list(roomId: String,
                     before: Before? = nil,
                     max: Int = 50,
                     mentionedPeople: Mention? = nil,
                     queue: DispatchQueue? = nil,
                     completionHandler: @escaping (ServiceResponse<[Message]>) -> Void)

    Parameters

    roomId

    The identifier of the room.

    before

    If not nil, only list messages sent only before this condition.

    max

    Limit the maximum number of messages in the response, default is 50.

    mentionedPeople

    List messages where the caller is mentioned by using Mention.person(me).

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    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

    roomId

    The identifier of the room where the message is to be posted.

    text

    The plain text message to be posted to the room.

    files

    A 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.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    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

    roomId

    The identifier of the room.

    files

    A 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.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    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

    personId

    The identifier of the recipient of this private 1:1 message.

    text

    The plain text message to post to the recipient.

    files

    A 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.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    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

    personId

    The identifier of the recipient of this media content.

    files

    A 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.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    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

    personEmail

    The email address of the recipient when sending a private 1:1 message.

    text

    The plain text message to post to the room.

    files

    A 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.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    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

    personEmail

    The email address of the recipient of this media content.

    files

    A 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.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    Swift

    public func post(personEmail: EmailAddress,
                     text: String? = nil,
                     files: [LocalFile]? = nil,
                     queue: DispatchQueue? = nil,
                     completionHandler: @escaping (ServiceResponse<Message>) -> Void)

    Parameters

    personEmail

    The EmailAddress of the user to whom the message is to be posted.

    content

    The plain text message to be posted to the room.

    files

    Local file objects to be uploaded to the room.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    Swift

    public func post(personId: String,
                     text: String? = nil,
                     files: [LocalFile]? = nil,
                     queue: DispatchQueue? = nil,
                     completionHandler: @escaping (ServiceResponse<Message>) -> Void)

    Parameters

    personId

    The personId of the user to whom the message is to be posted.

    text

    The plain text message to be posted to the room.

    files

    Local file objects to be uploaded to the room.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    Swift

    public func post(roomId: String,
                     text: String? = nil,
                     mentions: [Mention]? = nil,
                     files: [LocalFile]? = nil,
                     queue: DispatchQueue? = nil,
                     completionHandler: @escaping (ServiceResponse<Message>) -> Void)

    Parameters

    roomId

    The identifier of the room where the message is to be posted.

    text

    The plain text message to be posted to the room.

    mentions

    The mention items to be posted to the room.

    files

    Local file objects to be uploaded to the room.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    Swift

    public func get(messageId: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Message>) -> Void)

    Parameters

    messageID

    The identifier of the message.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    Swift

    public func delete(messageId: String, queue: DispatchQueue? = nil, completionHandler: @escaping (ServiceResponse<Any>) -> Void)

    Parameters

    messageId

    The messageId to be deleted in the room.

    queue

    If not nil, the queue on which the completion handler is dispatched. Otherwise, the handler is dispatched on the application’s main thread.

    completionHandler

    A 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.0

    Declaration

    Swift

    public func downloadFile(_ file: RemoteFile, to: URL? = nil, progressHandler: ((Double)->Void)? = nil, completionHandler: @escaping (Result<URL>) -> Void)

    Parameters

    file

    The RemoteFile object need to be downloaded.

    to

    The local file directory for saving dwonloaded file.

    progressHandler

    The download progress indicator.

    completionHandler

    Downloaded 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.0

    Declaration

    Swift

    public func downloadThumbnail(for file: RemoteFile, to: URL? = nil, progressHandler: ((Double)->Void)? = nil, completionHandler: @escaping (Result<URL>) -> Void)

    Parameters

    file

    The RemoteFile object need to be downloaded.

    to

    The local file directory for saving file after download.

    progressHandler

    The download progress indicator.

    completionHandler

    Downloaded file local address wiil be stored in file.localFileUrl

    Return Value

    Void