Migrate your Chat iOS SDK to Conversations (classic)
(information)
Info
If you are not using >=4.0.0 of our Chat SDK (or later), please follow the appropriate migration guides to get to v4+ before following this guide.
This guide walks you through migrating your Programmable Chat iOS SDK to Conversations (classic). The bulk of the work is renaming entities and refactoring method calls, which this guide covers. You should also review the companion migration guide that covers the high-level changes and new APIs in Conversations (classic).
CocoaPodsCarthage
1# Replace23pod "TwilioChatClient"45# with67pod "TwilioConversationsClient"8
SwiftObjective-C
1import TwilioChatClient23// becomes45import TwilioConversationsClient6
TCHTwilioChatClientbecomesTCHTwilioConversationsClientTCHChannelbecomesTCHConversationTCHMemberbecomesTCHParticipantTCHClientSynchronizationStatusChannelsListCompletedbecomesTCHClientSynchronizationStatusConversationsListCompleted
Intermediate accessor objects were removed so your code will look cleaner.
SwiftObjective-C
1TwilioChatClient.chatClient(withToken:properties:delegate:completion:)23// becomes45TwilioConversationsClient.conversationsClient(withToken:properties:delegate:completion:)67
SwiftObjective-C
1TwilioChatClient.users.subscribedUser(withIdentity:completion:)23// becomes45TwilioConversationsClient.subscribedUser(withIdentity:completion:)6
SwiftObjective-C
1Channel.member(withIdentity:)23// becomes45Conversation.participant(withIdentity:)6
SwiftObjective-C
1TwilioChatClient.channels.subscribedChannels()2// becomes3TwilioConversationsClient.myConversations()45//-------------------------------------------------------------67TwilioChatClient.channels.createChannel(options:completion:)8// becomes9TwilioConversationsClient.createConversation(options:completion:)1011//-------------------------------------------------------------1213TwilioChatClient.channels.channel(withSidOrUniqueName:completion:)14// becomes15TwilioConversationsClient.conversation(withSidOrUniqueName:completion:)16
SwiftObjective-C
1Channel.members.members(completion:)2// becomes3Conversation.participants()45//-------------------------------------------------------------67Channel.members.add(byIdentity:completion:)8// becomes9Conversation.addParticipant(byIdentity:attributes:completion:)1011//-------------------------------------------------------------1213Channel.members.remove(_:completion:)14// becomes15Conversation.removeParticipant(_:completion:)16
SwiftObjective-C
1Channel.messages. sendMessage(with:completion:)2// becomes3Conversation.sendMessage(with:completion:)45//-------------------------------------------------------------67Channel.messages.removeMessage(_:completion:)8// becomes9Conversation.removeMessage(_:completion:)1011//-------------------------------------------------------------1213Channel.messages.getLastMessages(withCount:completion:)14// becomes15Conversation.getLastMessages(withCount:completion:)1617//-------------------------------------------------------------1819Channel.messages.getMessagesBefore(_:withCount:completion:)20// becomes21Conversation.getMessagesBefore(_:withCount:completion:)2223//-------------------------------------------------------------2425Channel.messages.getMessagesAfter(_:withCount:completion:)26// becomes27Conversation.getMessagesAfter(_:withCount:completion:)2829//-------------------------------------------------------------3031Channel.messages.message(withIndex:completion:)32// becomes33Conversation.message(withIndex:completion:)3435//-------------------------------------------------------------3637Channel.messages.message(forConsumptionIndex:completion:)38// becomes39Conversation.message(forReadIndex:completion:)4041//-------------------------------------------------------------4243Channel.messages.lastConsumedMessageIndex44// becomes45Channel.lastReadMessageIndex4647//-------------------------------------------------------------4849Channel.messages.setLastConsumedMessageIndex(_:completion:)50// becomes51Conversation.setLastReadMessageIndex(_:completion:)5253//-------------------------------------------------------------5455Channel.messages.advanceLastConsumedMessageIndex(_:completion:)56// becomes57Conversation.advanceLastReadMessageIndex(_:completion:)5859//-------------------------------------------------------------6061Channel.messages.setAllMessagesConsumedWithCompletion(_:)62// becomes63Conversation.setAllMessagesReadWithCompletion(_:)6465//-------------------------------------------------------------6667Channel.messages.setNoMessagesConsumedWithCompletion(_:)68// becomes69Conversation.setAllMessagesUnreadWithCompletion(_:)
Channels subscribedChannelsSortedByChannels userChannelDescriptorsWithCompletionChannels publicChannelDescriptorsWithCompletionMembers inviteByIdentity:completion:
SwiftObjective-C
1// added2Conversation.addParticipant(byAddress:proxyAddress:attributes:completion:)34// added5Conversation.removeParticipant(byIdentity:completion:)6
- You can get delivery receipts for each SMS or WhatsApp message to understand the current status of delivery.
Conversations (classic) have state.
- Added update reason
TCHConversationUpdateState. - Get the current state of a conversation by calling
Conversation.state()
- Update reasons
TCHChannelUpdateLastConsumedMessageIndexbecomesTCHConversationUpdateLastReadMessageIndexTCHParticipantUpdateLastConsumedMessageIndexbecomesTCHParticipantUpdateLastReadMessageIndexTCHParticipantUpdateLastConsumedTimestampbecomesTCHParticipantUpdateLastReadTimestamp
Channel.getUnconsumedMessagesCountWithCompletionbecomesConversation.getUnreadMessagesCountWithCompletionMember.lastConsumedMessageIndexbecomesParticipant.lastReadMessageIndexMember.lastConsumptionTimestampbecomesParticipant.lastReadTimestampMember.lastConsumptionTimestampAsDatebecomesParticipant.lastReadTimestampAsDate
There are no more streams used to download media. Instead, you'll retrieve a temporary data URL to download it.
SwiftObjective-C
1getMediaContentTemporaryUrl(completion:)2
- Public conversations are unavailable for Conversations (classic) SDK,
conversationWithSidOrUniqueNamereturns an error if the conversation is public. TCHChannelTypeis removed.- Instead of removed
subscribedChannelsSortedBymethod, sort the list returned frommyConversations. TCHChannelDescriptor,TCHUserDescriptorwere removed. UseTCHConversationandTCHUserobjects instead.- Paginators were removed
- Invites are not supported by Conversations (classic) SDK. Use
addParticipantByIdentityandaddParticipantByAddressinstead. TCHConversationStatuscould be now eitherjoinedornotParticipating.