SMIConversationClient

Objective-C

@protocol SMIConversationClient

Swift

protocol ConversationClient

Class that allows you to perform actions related to a conversation and to listen for events using the associated delegate.

  • The identifier for the conversation managed by this client.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSUUID *_Nonnull identifier;

    Swift

    var identifier: UUID { get }
  • Reference to the core object which manages this client.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly) id<SMICoreClient> _Nullable core;

    Swift

    weak var core: SMICoreClient? { get }
  • Sends a message with the contents of the message parameter.

    Declaration

    Objective-C

    - (void)sendMessage:(nonnull NSString *)message;

    Swift

    func send(message: String)

    Parameters

    message

    The message to send.

  • Deprecated

    Will be removed in a future version. Use sendImage:fileName:

    Sends an image with the contents of the image parameter.

    Declaration

    Objective-C

    - (void)sendImage:(nonnull UIImage *)image;

    Swift

    func send(image: UIImage)

    Parameters

    image

    The image to send.

  • Sends an image with the contents of the data parameter.

    Declaration

    Objective-C

    - (void)sendImage:(nonnull NSData *)data fileName:(NSString *_Nullable)fileName;

    Swift

    func send(image data: Data, fileName: String?)

    Parameters

    data

    The data representation of an image.

    fileName

    The file name, if one exists, for the image that is being sent.

  • Sends an PDF attachment.

    Declaration

    Objective-C

    - (void)sendPDF:(nonnull PDFDocument *)pdf;

    Swift

    func send(pdf: PDFDocument)

    Parameters

    pdf

    The PDF document to send.

  • Sends a reply to a structured content message.

    Declaration

    Objective-C

    - (void)sendReply:(nonnull id<SMIChoice>)reply;

    Swift

    func send(reply: SMIChoice)

    Parameters

    reply

    The selected option for the structured content.

  • Attempts to send a typing indicator.

    Note

    There’s a predefined threshold for how often typing indicators are sent. It’s safe to call this method as often as needed. Attempts to send an indicator too frequently are ignored.

    Declaration

    Objective-C

    - (void)sendTypingEvent;

    Swift

    func sendTypingEvent()
  • Sends a filled out Form.

    See

    SMIEntryTypeFormMessage

    Declaration

    Objective-C

    - (void)sendForm:(nonnull id<SMIEntryTypeFormMessage>)form;

    Swift

    func send(form: EntryTypeFormMessage)

    Parameters

    form

    The Form to send.

  • Retrieves the conversation represented by the client.

    Declaration

    Objective-C

    - (void)conversationWithCompletion:
        (nonnull SMISingleConversationQueryCompletion)completion;

    Swift

    func conversation() async throws -> SMIConversation

    Parameters

    completion

    The completion that contains the stored conversation record.

  • Deprecated

    Will be removed in a future version. Use submitRemoteConfiguration:

    Submits collected pre-chat fields and creates a conversation if required.

    Declaration

    Objective-C

    - (void)submitPreChatFields:
        (nonnull NSArray<id<SMIPreChatField>> *)preChatFields;

    Swift

    func submit(preChatFields: [PreChatField])

    Parameters

    preChatFields

    An array of SMIPreChatField objects representing collected pre-chat data.

  • Deprecated

    Will be removed in a future version. Use submitRemoteConfiguration:

    Submits collected pre-chat fields and creates a conversation if required.

    Declaration

    Objective-C

    - (void)submitPreChatFields:
                (nonnull NSArray<id<SMIPreChatField>> *)preChatFields
            hiddenPreChatFields:
                (nonnull NSArray<id<SMIHiddenPreChatField>> *)hiddenPreChatFields;

    Swift

    func submit(preChatFields: [PreChatField], hiddenPreChatFields: [HiddenPreChatField])

    Parameters

    preChatFields

    An array of SMIPreChatField objects representing collected pre-chat data.

    hiddenPreChatFields

    An array of SMIHiddenPreChatField objects representing hidden prechat data.

  • Deprecated

    Will be removed in a future version. Use submitRemoteConfiguration:createConversationOnSubmit:

    Submits collected pre-chat fields and starts the conversation if createConversationOnSubmit is true. Otherwise, the SDK stores the pre-chat data until the conversation is created.

    Declaration

    Objective-C

    - (void)submitPreChatFields:
                (nonnull NSArray<id<SMIPreChatField>> *)preChatFields
               hiddenPreChatFields:
                   (nonnull NSArray<id<SMIHiddenPreChatField>> *)hiddenPreChatFields
        createConversationOnSubmit:(BOOL)createConversationOnSubmit;

    Swift

    func submit(preChatFields: [PreChatField], hiddenPreChatFields: [HiddenPreChatField], createConversationOnSubmit: Bool)

    Parameters

    preChatFields

    An array of SMIPreChatField objects representing collected pre-chat data.

    hiddenPreChatFields

    An array of SMIHiddenPreChatField objects representing any hidden pre-chat data.

    createConversationOnSubmit

    Determines if the conversation starts when the pre-chat data is submitted.

  • Submits the remote configuration values.

    Declaration

    Objective-C

    - (void)submitRemoteConfiguration:
        (nonnull id<SMIRemoteConfiguration>)remoteConfig;

    Swift

    func submit(remoteConfig: RemoteConfiguration)

    Parameters

    remoteConfig

    The remote configuration fields.

  • Submits the remote configuration values and starts the conversation if createConversationOnSubmit is true. Otherwise, the SDK stores the pre-chat data until the conversation is created.

    Declaration

    Objective-C

    - (void)submitRemoteConfiguration:
                (nonnull id<SMIRemoteConfiguration>)remoteConfig
           createConversationOnSubmit:(BOOL)createConversationOnSubmit;

    Swift

    func submit(remoteConfig: RemoteConfiguration, createConversationOnSubmit: Bool)

    Parameters

    remoteConfig

    The remote configuration fields.

    createConversationOnSubmit

    Determines if the conversation starts when the pre-chat data is submitted.

  • Deprecated

    Will be removed in a future version. Use entriesWithLimit:fromTimestamp:direction:completion:

    Retrieves messages for this conversation. Only returns the first subset of messages. This is a convenience method to make direct database calls for entries associated with this conversation.

    Declaration

    Objective-C

    - (void)entriesWithCompletion:(nonnull SMIFullQueryCompletion)completion;

    Swift

    func entries() async throws -> ([SMIConversationEntry], SMIConversation)

    Parameters

    completion

    The completion that contains the result of the search query.

  • Deprecated

    Will be removed in a future version. Use entriesWithLimit:fromTimestamp:direction:completion:

    Retrieves entries for this conversation. This is a convenience method to make direct database calls for entries associated with this conversation.

    Declaration

    Objective-C

    - (void)entriesWithLimit:(NSUInteger)limit
                      offset:(NSUInteger)offset
                  completion:(nonnull SMIFullQueryCompletion)completion;

    Swift

    func entries(withLimit limit: UInt, offset: UInt) async throws -> ([SMIConversationEntry], SMIConversation)

    Parameters

    limit

    The maximum number of results to expect.

    offset

    The offset to begin searching for results.

    completion

    The completion that contains the result of the search query.

  • Deprecated

    Will be removed in a future version. Use entriesWithLimit:fromTimestamp:direction:completion:

    Retrieves entries for this conversation. This is a convenience method to make direct database calls for entries associated with this conversation.

    Declaration

    Objective-C

    - (void)entriesWithLimit:(NSUInteger)limit
              olderThanEntry:(nullable id<SMIConversationEntry>)olderThanEntry
                  completion:(nonnull SMIFullQueryCompletion)completion;

    Swift

    func entries(withLimit limit: UInt, olderThanEntry: SMIConversationEntry?) async throws -> ([SMIConversationEntry], SMIConversation)

    Parameters

    limit

    The maximum number of results to expect.

    olderThanEntry

    The comparison entry which serves as a base for returning older entries in the conversation. If nil, the query starts from the newest known entry.

    completion

    The completion that contains the result of the search query.

  • Retrieves entries for this conversation. This is a convenience method to make direct database calls for entries associated with this conversation.

    Declaration

    Objective-C

    - (void)entriesWithLimit:(NSUInteger)limit
               fromTimestamp:(nullable NSDate *)fromTimestamp
                   direction:(nonnull SMIListAPIDirections)direction
                   behaviour:(SMIQueryBehaviour)behaviour
                  completion:
                      (nonnull void (^)(
                          NSArray<id<SMIConversationEntry>> *_Nullable __strong,
                          id<SMIConversation> _Nullable __strong,
                          NSError *_Nullable __strong))completion;

    Swift

    func entries(withLimit limit: UInt, fromTimestamp: Date?, direction: ListAPIDirections, behaviour: QueryBehaviour) async throws -> ([SMIConversationEntry], SMIConversation)

    Parameters

    limit

    The maximum number of results to expect.

    fromTimestamp

    A timestamp to use as a point of comparison for conversation entry queries.

    direction

    The direction of the query.

    behaviour

    Defines how the query will behave. Default: SMIQueryBehaviourLocalWithNetwork

    completion

    The completion that contains the result of the search query.

  • Retrieves entries for this conversation. This is a convenience method to make direct database calls for entries associated with this conversation.

    Declaration

    Objective-C

    - (void)entriesWithLimit:(NSUInteger)limit
               fromTimestamp:(nullable NSDate *)fromTimestamp
                   direction:(nonnull SMIListAPIDirections)direction
                  completion:(nonnull SMIFullQueryCompletion)completion;

    Swift

    func entries(withLimit limit: UInt, fromTimestamp: Date?, direction: ListAPIDirections) async throws -> ([SMIConversationEntry], SMIConversation)

    Parameters

    limit

    The maximum number of results to expect.

    fromTimestamp

    A timestamp to use as a point of comparison for conversation entry queries.

    direction

    The direction of the query.

    completion

    The completion that contains the result of the search query.

  • Deprecated

    Will be removed in a future version. Use fetchLatestVerifiedEntryWithCompletion:

    Returns the most recent verified entry. An entry is considered verified if the entry in the local DB cache has been verified against the conversation transcript in the network service.

    Declaration

    Objective-C

    - (void)latestVerifiedEntryWithCompletion:
        (nonnull SMIFullQueryCompletion)completion;

    Swift

    func latestVerifiedEntry() async throws -> ([SMIConversationEntry], SMIConversation)

    Parameters

    completion

    The completion that contains the result of the search query.

  • Returns the most recent verified entry. An entry is considered verified if the entry in the local DB cache has been verified against the conversation transcript in the network service.

    Declaration

    Objective-C

    - (void)fetchLatestVerifiedEntryWithCompletion:
        (nonnull SMISingleEntryQueryCompletion)completion;

    Swift

    func fetchLatestVerifiedEntry() async throws -> (SMIConversationEntry, SMIConversation)

    Parameters

    completion

    The completion that contains the result of the search query.

  • Adds a delegate to listen to SMIConversationClientDelegate events.

    Declaration

    Objective-C

    - (void)addDelegate:(nonnull id<SMIConversationClientDelegate>)delegate;

    Swift

    func addDelegate(delegate: ConversationClientDelegate)

    Parameters

    delegate

    The delegate to add.

  • Adds a delegate to listen to SMIConversationClientDelegate events. It is recommended that the main queue is passed to this method if you plan to handle events directly with changes to the UI.

    Declaration

    Objective-C

    - (void)addDelegate:(nonnull id<SMIConversationClientDelegate>)delegate
                  queue:(nonnull dispatch_queue_t)queue;

    Swift

    func addDelegate(delegate: ConversationClientDelegate, queue: dispatch_queue_t)

    Parameters

    delegate

    The delegate to add.

    queue

    The dispatch queue to listen for events.

  • Removes the delegate to stop receiving events.

    Declaration

    Objective-C

    - (void)removeDelegate:(nonnull id<SMIConversationClientDelegate>)delegate;

    Swift

    func removeDelegate(delegate: ConversationClientDelegate)

    Parameters

    delegate

    The delegate to remove.