# AVAConversation

Objective-C

    @interface AVAConversation : NSObject <NSSecureCoding>

Swift

    class AVAConversation : NSObject, NSSecureCoding

@discussion The AVAConversation class provides an interface to interact with the current user’s conversation.

To obtain an instance, use `[AvMessagingSdk conversation]`. +initWithSettings:completionHandler: must have been called prior to retrieving the shared conversation object.

To send a message, use -sendMessage: with an AVAMessage object

Example:

`[[AvMessagingSdk conversation] sendMessage:[[AVAMessage alloc] initWithText:@"Hello World!"]];`

A notification will be fired indicating the success or failure of the message. To subscribe to these notifications, use NSNotificationCenter.

Example:

`[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(messageUploaded:) name:AVAMessageUploadCompletedNotification object:nil];`

`[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(messageFailed:) name:AVAMessageUploadFailedNotification object:nil];`

See

AVAMessage

See

AvMessagingSdk

- `conversationId`

  @abstract The unique identifier of the conversation. May be nil if a conversation doesn’t exist for the current user

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSString *conversationId;

  Swift

      var conversationId: String? { get }

- `messages`

  @abstract The array of AVAMessage objects representing the conversation.

  See

  AVAMessage

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSArray *messages;

  Swift

      var messages: [Any]? { get }

- `messageCount`

  @abstract The total number of messages in the conversation, including user-generated messages.

  #### Declaration

  Objective-C

      @property (readonly) NSUInteger messageCount;

  Swift

      var messageCount: UInt { get }

- `unreadCount`

  @abstract Count of unread messages in the conversation.

  @discussion The primary use of this property is to be able to display an indicator / badge when the conversation has unread messages.

  #### Declaration

  Objective-C

      @property (readonly) NSUInteger unreadCount;

  Swift

      var unreadCount: UInt { get }

- `businessLastRead`

  @abstract Date when the business last read the user messages

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSDate *businessLastRead;

  Swift

      var businessLastRead: Date? { get }

- `metadata`

  @abstract Metadata associated with the conversation.

  @discussion A flat dictionary of metadata set through the REST API. May be nil.

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSDictionary *metadata;

  Swift

      var metadata: [AnyHashable : Any]? { get }

- `delegate`

  @abstract A delegate object for receiving notifications related to the conversation.

  See

  AVAConversationDelegate

  #### Declaration

  Objective-C

      @property (weak, readonly, nullable) id<AVAConversationDelegate> delegate;

  Swift

      weak var delegate: AVAConversationDelegate? { get }

- `hasPreviousMessages`

  @abstract Boolean representing whether there are previous messages in the conversation that can be fetched or not

  @discussion Returns YES if there are previous messages in the conversation, NO otherwise. For fetching previous messages, use [AVAConversation loadPreviousMessages]

  #### Declaration

  Objective-C

      @property (readonly) BOOL hasPreviousMessages;

  Swift

      var hasPreviousMessages: Bool { get }

- `lastUpdatedAt`

  @abstract NSDate representation of when the conversation was last updated.

  @discussion NSDate object set through the REST API and Web Socket. May be nil.

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSDate *lastUpdatedAt;

  Swift

      var lastUpdatedAt: Date? { get }

- `displayName`

  @abstract A display name for the conversation.

  @discussion This is set when a conversation is created. Can be nil.

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSString *displayName;

  Swift

      var displayName: String? { get }

- `conversationDescription`

  @abstract A conversation description for the conversation.

  @discussion This is set when a conversation is created. Can be nil.

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSString *conversationDescription;

  Swift

      var conversationDescription: String? { get }

- `iconUrl`

  @abstract A iconUrl for the conversation.

  @discussion This is set when a conversation is created. Can be nil.

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSString *iconUrl;

  Swift

      var iconUrl: String? { get }

- `participants`

  @abstract An array of AVAParticipant objects currently in the conversation.

  See

  AVAParticipant

  #### Declaration

  Objective-C

      @property (readonly, nullable) NSArray *participants;

  Swift

      var participants: [Any]? { get }

- `-markAllAsRead`

  @abstract Marks all unread messages as read.

  @discussion Marks all unread messages as read, and notifies that the unread count changed.

  See

  AVAMessage

  #### Declaration

  Objective-C

      - (void)markAllAsRead;

  Swift

      func markAllAsRead()

- `-loadPreviousMessages`

  @abstract Loads previous messages for this conversation, if any

  @discussion Will get previous messages for this conversation based on the timestamp of the current oldest message and will notify the delegate of new incoming messages through [AVAConversationDelegate conversation:didReceivePreviousMessages:]

  #### Declaration

  Objective-C

      - (void)loadPreviousMessages;

  Swift

      func loadPreviousMessages()

- `-sendMessage:`

  @abstract Adds a new message to the conversation.

  @discussion For each message added using `sendMessage`, a notification will be fired indicating the success or failure status of the upload.

  See

  AVAMessageUploadFailedNotification

  See

  AVAMessageUploadCompletedNotification

  #### Declaration

  Objective-C

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

  Swift

      func sendMessage(_ message: AVAMessage)

- `-sendImage:withProgress:completion:`

  @abstract Adds an image message to the conversation.

  @discussion Use the progress block to track the progress of the upload. Progress is reported as a number between 0 and 1.

  The completion block is called when the operation completes, either in success or failure. Both blocks are guaranteed to be called on the main thread.

  In case of success, the error parameter will be nil, and the message parameter will contain the newly created message. The message will already be part of the messages array when this block is called.

  In case of failure, the message parameter will be nil, and the error parameter will contain the error that occurred.

  #### Declaration

  Objective-C

      - (void)sendImage:(id)image
           withProgress:(nullable AVAImageUploadProgressBlock)progressBlock
             completion:(nullable AVAImageUploadCompletionBlock)completionBlock;

  Swift

      func sendImage(_ image: Any!, withProgress progressBlock: AVAImageUploadProgressBlock?) async throws -> AVAMessage

  #### Parameters

  `image` | The image to upload. Must not be nil.
  `progressBlock` | Called to report progress updates. May be nil.
  `completionBlock` | Called when the upload completes or fails. May be nil.

- `-sendFile:withProgress:completion:`

  Undocumented

  #### Declaration

  Objective-C

      - (void)sendFile:(NSURL *)fileLocation
          withProgress:(nullable AVAFileUploadProgressBlock)progressBlock
            completion:(nullable AVAFileUploadCompletionBlock)completionBlock;

  Swift

      func sendFile(_ fileLocation: URL, withProgress progressBlock: AVAFileUploadProgressBlock?) async throws -> AVAMessage

- `-postback:completion:`

  @abstract Sends a postback to the server.

  @discussion The completion block is called when the operation completes, either in success or failure.

  In case of success, the error parameter will be nil.

  In case of failure, the error parameter will contain the error that occurred.

  #### Declaration

  Objective-C

      - (void)postback:(nonnull AVAMessageAction *)messageAction
            completion:(nullable void (^)(NSError *_Nullable))completionBlock;

  Swift

      func postback(_ messageAction: AVAMessageAction) async throws

  #### Parameters

  `messageAction` | The messageAction for which to send the postback. Must not be nil.
  `completionBlock` | Called when the postback completes or fails. May be nil.

- `-retryMessage:`

  @abstract Retries a message that failed to send.

  @discussion The failed message will be removed from the messages array, and a new message will be constructed with the same text as the failed message. A notification will be fired indicating the success or failure status of the upload.

  See

  AVAMessageUploadFailedNotification

  See

  AVAMessageUploadCompletedNotification

  #### Declaration

  Objective-C

      - (void)retryMessage:(nonnull AVAMessage *)failedMessage;

  Swift

      func retryMessage(_ failedMessage: AVAMessage)

- `-startTyping`

  @abstract Notify the server that the user is typing.

  @discussion This method is called automatically when using the default conversation view controller. Only call this method if your application implements its own conversation view.

  Typing updates are automatically throttled, so you may call this method as often as necessary. The typing stop event will automatically fire 10 seconds after the most recent call to this method.

  #### Declaration

  Objective-C

      - (void)startTyping;

  Swift

      func startTyping()

- `-stopTyping`

  @abstract Notify the server that the user has finished typing.

  @discussion This method is called automatically when using the default conversation view controller. Only call this method if your application implements its own conversation view.

  If the user was not flagged as typing recently, this method will result in a no-op.

  #### Declaration

  Objective-C

      - (void)stopTyping;

  Swift

      func stopTyping()

© 2022 . All rights reserved. (Last updated: 2022-06-30)

Generated by jazzy ♪♫ v0.14.2, a Realm project.