TCHConversation Class Reference
| Inherits from | NSObject | 
|---|---|
| Declared in | TCHConversation.h | 
  delegate
	Optional conversation delegate. Upon setting the delegate, you will receive the current conversation synchronization status by delegate method.
@property (nonatomic, weak, nullable) id<TCHConversationDelegate> delegateDiscussion
Optional conversation delegate. Upon setting the delegate, you will receive the current conversation synchronization status by delegate method.
Declared In
TCHConversation.h
  sid
	The unique identifier for this conversation.
@property (nonatomic, copy, readonly, nullable) NSString *sidDiscussion
The unique identifier for this conversation.
Declared In
TCHConversation.h
  friendlyName
	The friendly name for this conversation.
@property (nonatomic, copy, readonly, nullable) NSString *friendlyNameDiscussion
The friendly name for this conversation.
Declared In
TCHConversation.h
  uniqueName
	The unique name for this conversation.
@property (nonatomic, copy, readonly, nullable) NSString *uniqueNameDiscussion
The unique name for this conversation.
Declared In
TCHConversation.h
  notificationLevel
	The current user’s notification level on this conversation. This property reflects whether the user will receive push notifications for activity on this conversation.
@property (nonatomic, assign, readonly) TCHConversationNotificationLevel notificationLevelDiscussion
The current user’s notification level on this conversation. This property reflects whether the user will receive push notifications for activity on this conversation.
Declared In
TCHConversation.h
  status
	The current user’s status on this conversation.
@property (nonatomic, assign, readonly) TCHConversationStatus statusDiscussion
The current user’s status on this conversation.
Declared In
TCHConversation.h
  state
	The current state for this conversation.
@property (readonly) TCHConversationState stateDiscussion
The current state for this conversation.
Declared In
TCHConversation.h
  stateDateUpdatedAsDate
	The date when TCHConversationState was last updated.
@property (readonly, nullable) NSDate *stateDateUpdatedAsDateDiscussion
The date when TCHConversationState was last updated.
Declared In
TCHConversation.h
  createdBy
	The identity of the conversation’s creator.
@property (nonatomic, copy, readonly, nullable) NSString *createdByDiscussion
The identity of the conversation’s creator.
Declared In
TCHConversation.h
  dateCreated
	The conversation creation date.
@property (nonatomic, strong, readonly, nullable) NSString *dateCreatedDiscussion
The conversation creation date.
Declared In
TCHConversation.h
  dateCreatedAsDate
	The conversation creation date as an NSDate.
@property (nonatomic, strong, readonly, nullable) NSDate *dateCreatedAsDateDiscussion
The conversation creation date as an NSDate.
Declared In
TCHConversation.h
  dateUpdated
	The timestamp the conversation was last updated.
@property (nonatomic, strong, readonly, nullable) NSString *dateUpdatedDiscussion
The timestamp the conversation was last updated.
Declared In
TCHConversation.h
  dateUpdatedAsDate
	The timestamp the conversation was last updated as an NSDate.
@property (nonatomic, strong, readonly, nullable) NSDate *dateUpdatedAsDateDiscussion
The timestamp the conversation was last updated as an NSDate.
Declared In
TCHConversation.h
  lastMessageDate
	The timestamp of the conversation’s most recent message.
@property (nonatomic, strong, readonly, nullable) NSDate *lastMessageDateDiscussion
The timestamp of the conversation’s most recent message.
Declared In
TCHConversation.h
  lastMessageIndex
	The index of the conversation’s most recent message.
@property (nonatomic, strong, readonly, nullable) NSNumber *lastMessageIndexDiscussion
The index of the conversation’s most recent message.
Declared In
TCHConversation.h
  lastReadMessageIndex
	Index of the last Message the User has marked as read in this Conversation.
@property (nonatomic, copy, readonly, nullable) NSNumber *lastReadMessageIndexDiscussion
Index of the last Message the User has marked as read in this Conversation.
Declared In
TCHConversation.h
  limits
	Limits for attachments per each message in the conversation.
@property (nonatomic, readonly, nonnull) TCHConversationLimits *limitsDiscussion
Limits for attachments per each message in the conversation.
Declared In
TCHConversation.h
– attributes
	Return this conversation’s attributes.
- (nullable TCHJsonAttributes *)attributesReturn Value
The developer-defined extensible attributes for this conversation.
Discussion
Return this conversation’s attributes.
Declared In
TCHConversation.h
– setAttributes:completion:
	Set this conversation’s attributes.
- (void)setAttributes:(nullable TCHJsonAttributes *)attributes completion:(nullable TCHCompletion)completionParameters
| attributes | The new developer-defined extensible attributes for this conversation. (Supported types are NSString, NSNumber, NSArray, NSDictionary and NSNull) | 
|---|---|
| completion | Completion block that will specify the result of the operation. | 
Discussion
Set this conversation’s attributes.
Declared In
TCHConversation.h
– setFriendlyName:completion:
	Set this conversation’s friendly name.
- (void)setFriendlyName:(nullable NSString *)friendlyName completion:(nullable TCHCompletion)completionParameters
| friendlyName | The new friendly name for this conversation. | 
|---|---|
| completion | Completion block that will specify the result of the operation. | 
Discussion
Set this conversation’s friendly name.
Declared In
TCHConversation.h
– setUniqueName:completion:
	Set this conversation’s unique name.
- (void)setUniqueName:(nullable NSString *)uniqueName completion:(nullable TCHCompletion)completionParameters
| uniqueName | The new unique name for this conversation. | 
|---|---|
| completion | Completion block that will specify the result of the operation. | 
Discussion
Set this conversation’s unique name.
Declared In
TCHConversation.h
– setNotificationLevel:completion:
	Set the user’s notification level for the conversation. This property determines whether the user will receive push notifications for activity on this conversation.
- (void)setNotificationLevel:(TCHConversationNotificationLevel)notificationLevel completion:(nullable TCHCompletion)completionParameters
| notificationLevel | The new notification level for the current user on this conversation. | 
|---|---|
| completion | Completion block that will specify the result of the operation. | 
Discussion
Set the user’s notification level for the conversation. This property determines whether the user will receive push notifications for activity on this conversation.
Declared In
TCHConversation.h
– joinWithCompletion:
	Join the current user to this conversation.
- (void)joinWithCompletion:(nullable TCHCompletion)completionParameters
| completion | Completion block that will specify the result of the operation. | 
|---|
Discussion
Join the current user to this conversation.
Declared In
TCHConversation.h
– leaveWithCompletion:
	Leave the current conversation.
- (void)leaveWithCompletion:(nullable TCHCompletion)completionParameters
| completion | Completion block that will specify the result of the operation. | 
|---|
Discussion
Leave the current conversation.
Declared In
TCHConversation.h
– destroyWithCompletion:
	Destroy the current conversation, removing all of its participants.
- (void)destroyWithCompletion:(nullable TCHCompletion)completionParameters
| completion | Completion block that will specify the result of the operation. | 
|---|
Discussion
Destroy the current conversation, removing all of its participants.
Declared In
TCHConversation.h
– typing
	Indicates to other users and the backend that the user is typing a message to this conversation.
- (void)typingDiscussion
Indicates to other users and the backend that the user is typing a message to this conversation.
Declared In
TCHConversation.h
– prepareMessage
	Prepares a new message to send into the conversation.
- (nonnull TCHMessageBuilder *)prepareMessageReturn Value
The message builder for building a new message and sending it into the conversation.
Example of usage: @code conversation.prepareMessage() .setBody(“message body”) .addMedia(mediaData, “image/jpeg”, “filename.jpg”, .init(onStarted: { print(“Media upload started”) } onProgress: { bytesSent in print(“Current progress (bytesSent)”) } onCompleted: { mediaSid in print(“Media uploaded with sid (mediaSid)”) } onFailed: { error in print(“Media upload failed with error (error)”) })) .buildAndSend { result, message in print(“Message sent with result (result)”) } @endcode
Discussion
Prepares a new message to send into the conversation.
Declared In
TCHConversation.h
– removeMessage:completion:
	Removes the specified message from the conversation.
- (void)removeMessage:(nonnull TCHMessage *)message completion:(nullable TCHCompletion)completionParameters
| message | The message to remove. | 
|---|---|
| completion | Completion block that will specify the result of the operation. | 
Discussion
Removes the specified message from the conversation.
Declared In
TCHConversation.h
– getLastMessagesWithCount:completion:
	Fetches the most recent count messages.  This will return locally cached messages if they are all available or may require a load from the server.
- (void)getLastMessagesWithCount:(NSUInteger)count completion:(nonnull TCHMessagesCompletion)completionParameters
| count | The number of most recent messages to return. | 
|---|---|
| completion | Completion block that will specify the result of the operation as well as the requested messages if successful. If no completion block is specified, no operation will be executed. | 
Discussion
Fetches the most recent count messages.  This will return locally cached messages if they are all available or may require a load from the server.
Declared In
TCHConversation.h
– getMessagesBefore:withCount:completion:
	Fetches at most count messages including and prior to the specified index.  This will return locally cached messages if they are all available or may require a load from the server.
- (void)getMessagesBefore:(NSUInteger)index withCount:(NSUInteger)count completion:(nonnull TCHMessagesCompletion)completionParameters
| index | The starting point for the request. | 
|---|---|
| count | The number of preceding messages to return. | 
| completion | Completion block that will specify the result of the operation as well as the requested messages if successful. If no completion block is specified, no operation will be executed. | 
Discussion
Fetches at most count messages including and prior to the specified index.  This will return locally cached messages if they are all available or may require a load from the server.
Declared In
TCHConversation.h
– getMessagesAfter:withCount:completion:
	Fetches at most count messages including and subsequent to the specified index.  This will return locally cached messages if they are all available or may require a load from the server.
- (void)getMessagesAfter:(NSUInteger)index withCount:(NSUInteger)count completion:(nonnull TCHMessagesCompletion)completionParameters
| index | The starting point for the request. | 
|---|---|
| count | The number of succeeding messages to return. | 
| completion | Completion block that will specify the result of the operation as well as the requested messages if successful. If no completion block is specified, no operation will be executed. | 
Discussion
Fetches at most count messages including and subsequent to the specified index.  This will return locally cached messages if they are all available or may require a load from the server.
Declared In
TCHConversation.h
– messageWithIndex:completion:
	Returns the message with the specified index.
- (void)messageWithIndex:(nonnull NSNumber *)index completion:(nonnull TCHMessageCompletion)completionParameters
| index | The index of the message. | 
|---|---|
| completion | Completion block that will specify the result of the operation as well as the requested message if successful. If no completion block is specified, no operation will be executed. | 
Discussion
Returns the message with the specified index.
Declared In
TCHConversation.h
– messageForReadIndex:completion:
	Returns the oldest message starting at index. If the message at index does not exist, the next message will be returned.
- (void)messageForReadIndex:(nonnull NSNumber *)index completion:(nonnull TCHMessageCompletion)completionParameters
| index | The index of the last message reported as read (may refer to a deleted message). | 
|---|---|
| completion | Completion block that will specify the result of the operation as well as the requested message if successful. If no completion block is specified, no operation will be executed. | 
Discussion
Returns the oldest message starting at index. If the message at index does not exist, the next message will be returned.
Declared In
TCHConversation.h
– setLastReadMessageIndex:completion:
	Set the last read index for this Participant and Conversation. Allows you to set any value, including smaller than the current index.
- (void)setLastReadMessageIndex:(nonnull NSNumber *)index completion:(nullable TCHCountCompletion)completionParameters
| index | The new index. | 
|---|---|
| completion | Optional completion block that will specify the result of the operation and an updated unread message count for the user on this conversation. | 
Discussion
Set the last read index for this Participant and Conversation. Allows you to set any value, including smaller than the current index.
Declared In
TCHConversation.h
– advanceLastReadMessageIndex:completion:
	Update the last read index for this Participant and Conversation. Only update the index if the value specified is larger than the previous value.
- (void)advanceLastReadMessageIndex:(nonnull NSNumber *)index completion:(nullable TCHCountCompletion)completionParameters
| index | The new index. | 
|---|---|
| completion | Optional completion block that will specify the result of the operation and an updated unread message count for the user on this conversation. | 
Discussion
Update the last read index for this Participant and Conversation. Only update the index if the value specified is larger than the previous value.
Declared In
TCHConversation.h
– setAllMessagesReadWithCompletion:
	Update the last read index for this Participant and Conversation to the max message currently on this device.
- (void)setAllMessagesReadWithCompletion:(nullable TCHCountCompletion)completionParameters
| completion | Optional completion block that will specify the result of the operation and an updated unread message count for the user on this conversation. | 
|---|
Discussion
Update the last read index for this Participant and Conversation to the max message currently on this device.
Declared In
TCHConversation.h
– setAllMessagesUnreadWithCompletion:
	Reset the last read index for this Participant and Conversation to no messages read.
- (void)setAllMessagesUnreadWithCompletion:(nullable TCHNullableCountCompletion)completionParameters
| completion | Optional completion block that will specify the result of the operation and an updated unread message count for the user on this conversation. | 
|---|
Discussion
Reset the last read index for this Participant and Conversation to no messages read.
Declared In
TCHConversation.h
– getUnreadMessagesCountWithCompletion:
	Fetch the number of unread messages on this conversation for the current user.
- (void)getUnreadMessagesCountWithCompletion:(nonnull TCHNullableCountCompletion)completionParameters
| completion | Completion block that will specify the requested count. If no completion block is specified, no operation will be executed. | 
|---|
Discussion
Fetch the number of unread messages on this conversation for the current user.
Use this method to obtain number of unread messages together with [TCHConversation setLastReadMessageIndex:completion:] instead of relying on TCHMessage indices which may have gaps. See [TCHMessage index] for details.
Available even if the conversation is not yet synchronized.
Note: if the last read index has not been yet set for current user as the participant of this conversation then unread messages count is considered uninitialized. In this case nil is returned. See [TCHConversation setLastReadMessageIndex:completion:].
This method is semi-realtime. This means that this data will be eventually correct, but will also possibly be incorrect for a few seconds. The Conversations system does not provide real time events for counter values changes.
So this is quite useful for any “unread messages count” badges, but is not recommended to build any core application logic based on these counters being accurate in real time. This function performs an async call to service to obtain up-to-date message count.
The retrieved value is then cached for 5 seconds so there is no reason to call this function more often than once in 5 seconds.
Declared In
TCHConversation.h
– getMessagesCountWithCompletion:
	Fetch the number of messages on this conversation.
- (void)getMessagesCountWithCompletion:(nonnull TCHCountCompletion)completionParameters
| completion | Completion block that will specify the requested count. If no completion block is specified, no operation will be executed. | 
|---|
Discussion
Fetch the number of messages on this conversation.
Available even if the conversation is not yet synchronized.
This method is semi-realtime. This means that this data will be eventually correct, but will also possibly be incorrect for a few seconds. The Conversations system does not provide real time events for counter values changes.
So this is quite useful for any UI badges, but is not recommended to build any core application logic based on these counters being accurate in real time. This function performs an async call to service to obtain up-to-date message count.
The retrieved value is then cached for 5 seconds so there is no reason to call this function more often than once in 5 seconds.
Declared In
TCHConversation.h
– getParticipantsCountWithCompletion:
	Fetch the number of participants on this conversation.
- (void)getParticipantsCountWithCompletion:(nonnull TCHCountCompletion)completionParameters
| completion | Completion block that will specify the requested count. If no completion block is specified, no operation will be executed. | 
|---|
Discussion
Fetch the number of participants on this conversation.
Available even if the conversation is not yet synchronized.
This method is semi-realtime. This means that this data will be eventually correct, but will also possibly be incorrect for a few seconds. The Conversations system does not provide real time events for counter values changes.
So this is quite useful for any UI badges, but is not recommended to build any core application logic based on these counters being accurate in real time. This function performs an async call to service to obtain up-to-date message count.
The retrieved value is then cached for 5 seconds so there is no reason to call this function more often than once in 5 seconds.
Declared In
TCHConversation.h
– participants
	Obtain the participants of this conversation.
- (nonnull NSArray<TCHParticipant*> *)participantsDiscussion
Obtain the participants of this conversation.
Declared In
TCHConversation.h
– addParticipantByIdentity:attributes:completion:
	Add specified username to this conversation.
- (void)addParticipantByIdentity:(nonnull NSString *)identity attributes:(nullable TCHJsonAttributes *)attributes completion:(nullable TCHCompletion)completionParameters
| identity | The username to add to this conversation. | 
|---|---|
| attributes | The developer-defined extensible attributes for participant or nil to use default empty attributes. (Supported types are NSString, NSNumber, NSArray, NSDictionary and NSNull) | 
| completion | Completion block that will specify the result of the operation. | 
Discussion
Add specified username to this conversation.
Declared In
TCHConversation.h
– addParticipantByAddress:proxyAddress:attributes:completion:
	Add specified non chat participant to this conversation, i.e. sms, whatsapp participants etc.
- (void)addParticipantByAddress:(nonnull NSString *)address proxyAddress:(nonnull NSString *)proxyAddress attributes:(nullable TCHJsonAttributes *)attributes completion:(nullable TCHCompletion)completionParameters
| address | The participant address to add to this conversation (phone number for sms and whatsapp participants) | 
|---|---|
| proxyAddress | Proxy address (Twilio phone number for sms and whatsapp participants). See conversations quickstart for more info: https://www.twilio.com/docs/conversations/quickstart | 
| attributes | The developer-defined extensible attributes for participant or nil to use default empty attributes. (Supported types are NSString, NSNumber, NSArray, NSDictionary and NSNull) | 
| completion | Completion block that will specify the result of the operation. | 
Discussion
Add specified non chat participant to this conversation, i.e. sms, whatsapp participants etc.
Declared In
TCHConversation.h
– removeParticipant:completion:
	Remove specified participant from this conversation.
- (void)removeParticipant:(nonnull TCHParticipant *)participant completion:(nullable TCHCompletion)completionParameters
| participant | The participant to remove from this conversation. | 
|---|---|
| completion | Completion block that will specify the result of the operation. | 
Discussion
Remove specified participant from this conversation.
Declared In
TCHConversation.h
– removeParticipantByIdentity:completion:
	Remove specified username from this conversation.
- (void)removeParticipantByIdentity:(nonnull NSString *)identity completion:(nullable TCHCompletion)completionParameters
| identity | The username to remove from this conversation. | 
|---|---|
| completion | Completion block that will specify the result of the operation. | 
Discussion
Remove specified username from this conversation.
Declared In
TCHConversation.h
– participantWithIdentity:
	Fetch the participant object for the given identity if it exists.
- (nullable TCHParticipant *)participantWithIdentity:(nonnull NSString *)identityParameters
| identity | The username to fetch. | 
|---|
Return Value
The TCHParticipant object, if one exists for the username for this conversation.
Discussion
Fetch the participant object for the given identity if it exists.
Declared In
TCHConversation.h
– participantWithSid:
	Fetch the participant object for the given SID if it exists.
- (nullable TCHParticipant *)participantWithSid:(nonnull NSString *)sidParameters
| sid | The participant’s SID. | 
|---|
Return Value
The TCHParticipant object, if one exists for the SID for this conversation.
Discussion
Fetch the participant object for the given SID if it exists.
Declared In
TCHConversation.h