CPChatConversation

@objc
public class CPChatConversation : CPConversation

This class is used to manage an exchange of chat messages between two parties. Create a ChatConversation using the ChatService createConversation(withParticipant:) method

  • url

    The url of the conversation

    Declaration

    Swift

    @objc
    override public var url: String { get }
  • The url of the conversation messages

    Declaration

    Swift

    @objc
    public var messagesUrl: String { get }
  • Public method to send a file attachment.

    Declaration

    Swift

    @objc
    public func send(withFile: URL, progress: @escaping UploadProgressBlock, completion: @escaping SendCompletionBlock) -> CPActivityHandle

    Parameters

    withFile

    URL of file attachment.

    completion

    Code block to execute upon send completion.

    Return Value

    Opaque activity handle with a cancel method that can be used to cancel the upload operation.

  • Public method to send a text with a file attachment.

    Declaration

    Swift

    @objc
    public func send(text: String, withFile: URL, progress: @escaping UploadProgressBlock, completion: @escaping SendCompletionBlock) -> CPActivityHandle

    Parameters

    text

    Text message to send.

    withFile

    URL of file attachment.

    completion

    Code block to execute upon send completion.

    Return Value

    Opaque activity handle with a cancel method that can be used to cancel the upload operation.

  • Indicate to a participant that a message is being composed.

    Declaration

    Swift

    @objc
    public func composing(active: Bool, refresh: UInt, lastActive: UInt64, _ completion: @escaping ComposingCompletionBlock)

    Parameters

    active

    Composition state. Use true for active and false for idle.

    refresh

    Number of seconds since last activity before which the remote should expect a refresh of composing state.

    lastActive

    Epoch timestamp of last activity.

    completion

    Code block to execute upon completion.

  • Indicate to a participant a message has been displayed to the user.

    Declaration

    Swift

    @objc
    public func displayed(message: CPMessage, _ completion: @escaping ErrorCompletionBlock)

    Parameters

    message

    The message object that has been displayed to the user.

    completion

    Code block to execute upon send completion. This block returns an error if one occurred or nil.

  • Interface to fetch messages from the server. Overrides base class Conversation abstract method.

    Declaration

    Swift

    @objc
    override public func fetchMessages(completion: @escaping FetchBlock)

    Parameters

    completion

    Code block to execute once the fetch has completed.

  • Interface to fetch messages from the server. Overrides base class Conversation abstract method.

    Declaration

    Swift

    @objc
    override public func fetchMessages(fetchOptions: FetchOptions, completion: @escaping FetchBlock)

    Parameters

    fetchOptions

    Options to pull messages in the conversation.

    completion

    Code block to execute once the fetch has completed.

  • Public interface to delete a single message from the server.

    Declaration

    Swift

    @objc
    override public func deleteMessage(withResourceUrl: String, completion: @escaping DeleteCompletionBlock)

    Parameters

    withId

    Unique identifier of the message to delete.

    completion

    Code block to execute once the delete has completed.

  • Public method used to create a chat group using this chat conversation. New chat group will have the complete chat history and particpants of this conversation.

    Declaration

    Swift

    @objc
    public func extend(name: String, type: String, subject: String? = nil, image: URL? = nil, participants: [CPChatGroupParticipant], completion: @escaping CreateChatGroupBlock)

    Parameters

    name

    User-friendly name of the chat group

    type

    “open” or “closed” - only “closed” supported in v1

    subject

    Topic of discussion for the chat group

    image

    URL of an image file to be used for the chat group

    particpants

    An array of participant members of the chat group

    completion

    Code block to execute upon completion of chat group creation