Migrate your Chat iOS SDK to Conversations
We are happy you decided to migrate your Programmable Chat iOS SDK to Conversations. It is a great decision and this guide will simplify the process a lot. You will need to perform several rather mechanical changes to convert your existing application code utilizing Twilio Chat to Conversations. One thing is important here, you will need to use Programmable Chat iOS SDK 4.0.0 as a minimal version to be able to migrate without any breaking changes.
# Replace pod "TwilioChatClient" # with pod "TwilioConversationsClient"
# Replace github "twilio/twilio-chat-ios" # with github "twilio/conversations-ios"
import TwilioChatClient // becomes import TwilioConversationsClient
#import "TwilioChatClient" // becomes #import "TwilioConversationsClient"
Rename entities
TCHTwilioChatClient
becomesTCHTwilioConversationsClient
TCHChannel
becomesTCHConversation
TCHMember
becomesTCHParticipant
TCHClientSynchronizationStatusChannelsListCompleted
becomesTCHClientSynchronizationStatusConversationsListCompleted
Refactor method calls
Intermediate accessor objects were removed so your code would look cleaner.
TwilioChatClient.chatClient(withToken:properties:delegate:completion:) // becomes TwilioConversationsClient.conversationsClient(withToken:properties:delegate:completion:)
[TwilioChatClient chatClientWithToken:properties:delegate:completion] // becomes [TwilioConversationsClient conversationsClientWithToken:properties:delegate:completion]
TwilioChatClient.users.subscribedUser(withIdentity:completion:) // becomes TwilioConversationsClient.subscribedUser(withIdentity:completion:)
[TwilioChatClient.users subscribedUserWithIdentity:completion:] // becomes [TwilioConversationsClient.subscribedUserWithIdentity:completion:]
Channel.member(withIdentity:) // becomes Conversation.participant(withIdentity:)
[Channel memberWithIdentity:] // becomes [Channel participantWithIdentity:]
TwilioChatClient.channels.subscribedChannels() // becomes TwilioConversationsClient.myConversations() //------------------------------------------------------------- TwilioChatClient.channels.createChannel(options:completion:) // becomes TwilioConversationsClient.createConversation(options:completion:) //------------------------------------------------------------- TwilioChatClient.channels.channel(withSidOrUniqueName:completion:) // becomes TwilioConversationsClient.conversation(withSidOrUniqueName:completion:)
[TwilioChatClient.channels subscribedChannels] // becomes [TwilioConversationsClient myConversations] //------------------------------------------------------------- [TwilioChatClient.channels createChannelWithOptions:completion] // becomes [TwilioConversationsClient createConversationWithOptions:completion:] //------------------------------------------------------------- [TwilioChatClient.channels channelWithSidOrUniqueName:completion] // becomes [TwilioConversationsClient conversationsWithSidOrUniqueName:completion:]
Channel.members.members(completion:) // becomes Conversation.participants() //------------------------------------------------------------- Channel.members.add(byIdentity:completion:) // becomes Conversation.addParticipant(byIdentity:attributes:completion:) //------------------------------------------------------------- Channel.members.remove(_:completion:) // becomes Conversation.removeParticipant(_:completion:)
[Channel.members membersList] // becomes [Conversation participants] //------------------------------------------------------------- [Channel.members addByIdentity:completion:] // becomes [Conversation addParticipantByIdentity:attributes:completion:] //------------------------------------------------------------- [Channel.members removeMember:completion:] // becomes [Conversation removeParticipant:completion:]
Channel.messages. sendMessage(with:completion:) // becomes Conversation.sendMessage(with:completion:) //------------------------------------------------------------- Channel.messages.removeMessage(_:completion:) // becomes Conversation.removeMessage(_:completion:) //------------------------------------------------------------- Channel.messages.getLastMessages(withCount:completion:) // becomes Conversation.getLastMessages(withCount:completion:) //------------------------------------------------------------- Channel.messages.getMessagesBefore(_:withCount:completion:) // becomes Conversation.getMessagesBefore(_:withCount:completion:) //------------------------------------------------------------- Channel.messages.getMessagesAfter(_:withCount:completion:) // becomes Conversation.getMessagesAfter(_:withCount:completion:) //------------------------------------------------------------- Channel.messages.message(withIndex:completion:) // becomes Conversation.message(withIndex:completion:) //------------------------------------------------------------- Channel.messages.message(forConsumptionIndex:completion:) // becomes Conversation.message(forReadIndex:completion:) //------------------------------------------------------------- Channel.messages.lastConsumedMessageIndex // becomes Channel.lastReadMessageIndex //------------------------------------------------------------- Channel.messages.setLastConsumedMessageIndex(_:completion:) // becomes Conversation.setLastReadMessageIndex(_:completion:) //------------------------------------------------------------- Channel.messages.advanceLastConsumedMessageIndex(_:completion:) // becomes Conversation.advanceLastReadMessageIndex(_:completion:) //------------------------------------------------------------- Channel.messages.setAllMessagesConsumedWithCompletion(_:) // becomes Conversation.setAllMessagesReadWithCompletion(_:) //------------------------------------------------------------- Channel.messages.setNoMessagesConsumedWithCompletion(_:) // becomes Conversation.setAllMessagesUnreadWithCompletion(_:)
[Channel.messages sendMessageWithOptoins:completion:] // becomes [Conversation sendMessageWithOptions:completion:] //------------------------------------------------------------- [Channel.messages removeMessage:completion:] // becomes [Conversation removeMessage:completion:] //------------------------------------------------------------- [Channel.messages getLastMessagesWithCount:completion:] // becomes [Conversation getLastMessagesWithCount:completion:] //------------------------------------------------------------- [Channel.messages getMessagesBefore:withCount:completion:] // becomes [Conversation getMessagesBefore:withCount:completion:] //------------------------------------------------------------- [Channel.messages getMessagesAfter:withCount:completion:] // becomes [Conversation getMessagesAfter:withCount:completion:] //------------------------------------------------------------- [Channel.messages messageWithIndex:completion:] // becomes [Conversation messageWithIndex:completion:] //------------------------------------------------------------- [Channel.messages messageForConsumptionIndex:completion] // becomes [Conversation messageForReadIndex:completion:] //------------------------------------------------------------- Channel.messages.lastConsumedMessageIndex // becomes Conversation.lastReadMessageIndex //------------------------------------------------------------- [Channel.messages setLastConsumedMessageIndex:completion:] // becomes [Conversation setLastReadMessageIndex:completion:] //------------------------------------------------------------- [Channel.messages advanceLastConsumedMessageIndex:completion:] // becomes [Conversation advanceLastReadMessageIndex:completion:] //------------------------------------------------------------- [Channel.messages setAllMessagesConsumedWithCompletion:] // becomes [Conversation setAllMessagesReadWithCompletion:] //------------------------------------------------------------- [Channel.messages setNoMessagesConsumedWithCompletion:] // becomes [Conversation setAllMessagesUnreadWithCompletion:]
Remove or replace not supported methods
Channels subscribedChannelsSortedBy
Channels userChannelDescriptorsWithCompletion
Channels publicChannelDescriptorsWithCompletion
Members inviteByIdentity:completion:
// added Conversation.addParticipant(byAddress:proxyAddress:attributes:completion:) // added Conversation.removeParticipant(byIdentity:completion:)
// added [Conversation addParticipantByAddress:proxyAddress:attributes:completion:] // added [Conversation removeParticipantByIdentity:completion:]
Added Aggregated Delivery Receipts
- You can get delivery receipts for each SMS or WhatsApp message to understand current status of delivery.
Added conversation state
Conversations now have state.
- Added update reason
TCHConversationUpdateState
. - Current state of conversation you can get by calling
Conversation.state()
Rename consumptionHorizon to readHorizon
- Update reasons
TCHChannelUpdateLastConsumedMessageIndex
becomesTCHConversationUpdateLastReadMessageIndex
TCHParticipantUpdateLastConsumedMessageIndex
becomesTCHParticipantUpdateLastReadMessageIndex
TCHParticipantUpdateLastConsumedTimestamp
becomesTCHParticipantUpdateLastReadTimestamp
Channel.getUnconsumedMessagesCountWithCompletion
becomesConversation.getUnreadMessagesCountWithCompletion
Member.lastConsumedMessageIndex
becomesParticipant.lastReadMessageIndex
Member.lastConsumptionTimestamp
becomesParticipant.lastReadTimestamp
Member.lastConsumptionTimestampAsDate
becomesParticipant.lastReadTimestampAsDate
Media changes
There are no more streams used to download media. Instead you should get a temporary data URL to download it.
getMediaContentTemporaryUrl(completion:)
getMediaContentTemporaryUrlWithCompletion:
Other changes
- Public conversations are unavailable for Conversations SDK,
conversationWithSidOrUniqueName
returns error if conversation is public. TCHChannelType
is removed.- Instead of removed
subscribedChannelsSortedBy
method simply sort the list returned frommyConversations
. TCHChannelDescriptor
,TCHUserDescriptor
were removed. UseTCHConversation
andTCHUser
objects instead.- Paginators were removed
- Invites are not supported by Conversations SDK. Use
addParticipantByIdentity
andaddParticipantByAddress
instead. TCHConversationStatus
could be now eitherjoined
ornotParticipating
.
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。