Skip to content

Commit f44082e

Browse files
authored
Reviewed, edited, raised Acrolinx score from 81 to 100
1 parent cb56854 commit f44082e

File tree

1 file changed

+58
-37
lines changed

1 file changed

+58
-37
lines changed

articles/communication-services/tutorials/includes/twilio-to-acs-chat-ios-tutorial.md

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Migrating from Twilio Conversations Chat to ACS Chat iOS
2+
title: Migrating from Twilio Conversations Chat to Azure Communication Services Chat iOS
33
description: Guide describes how to migrate iOS apps from Twilio Conversations Chat to Azure Communication Services Chat SDK.
44
services: azure-communication-services
55
ms.date: 07/22/2024
@@ -28,9 +28,9 @@ For more information, see [Use Azure CLI to Create and Manage Access Tokens](../
2828

2929
### Install the libraries
3030

31-
To start the migration from Twilio Conversations Chat, the first step is to install the Azure Communication Services Chat SDK for iOS to your project. You can configure these parameters using`Cocoapods`.
31+
To start the migration from Twilio Conversations Chat, the first step is to install the Azure Communication Services Chat SDK for iOS to your project. You can configure these parameters using `Cocoapods`.
3232

33-
1. To create a Podfile for your application, open the terminal and navigate to the project folder and run:
33+
1. Create a Podfile for your application. Open the terminal, navigate to the project folder, and run:
3434

3535
`pod init`
3636

@@ -40,17 +40,17 @@ To start the migration from Twilio Conversations Chat, the first step is to inst
4040
pod 'AzureCommunicationChat', '~> 1.3.5'
4141
```
4242

43-
3. Set up the `.xcworkspace` project
43+
3. Set up the `.xcworkspace` project:
4444

4545
```shell
4646
pod install
4747
```
4848

49-
4. Open the `.xcworkspace` that was created by the pod install with Xcode.
49+
4. Open the `.xcworkspace` created by the pod install with Xcode.
5050

5151
### Authenticating to the SDK
5252

53-
To be able to use the Azure Communication Services Chat SDK, you need to authenticate using an access token.
53+
To use the Azure Communication Services Chat SDK, you need to authenticate using an access token.
5454

5555
#### Twilio
5656

@@ -96,7 +96,8 @@ callClient.createCallAgent(userCredential: userCredential) { callAgent, error in
9696

9797
#### Twilio
9898

99-
The following code snippet helps to initialize chat client in Twilio.
99+
The following code snippet initializes the chat client in Twilio.
100+
100101
```swift
101102
func fetchAccessTokenAndInitializeClient() {
102103
let identity = "user_identity" // Replace with actual user identity
@@ -127,7 +128,8 @@ func fetchAccessTokenAndInitializeClient() {
127128

128129
#### Azure Communication Services
129130

130-
To create a chat client, you'll use your Communication Services endpoint and the access token that was generated as part of the prerequisite steps.
131+
To create a chat client, use your Communication Services endpoint and the access token generated as part of the prerequisite steps.
132+
131133
Replace `<ACS_RESOURCE_ENDPOINT>` with the endpoint of your Azure Communication Services resource. Replace `<ACCESS_TOKEN>` with a valid Communication Services access token.
132134

133135
```swift
@@ -151,14 +153,16 @@ The following classes and interfaces handle some of the major features of the Az
151153

152154
| Name | Description |
153155
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
154-
| `ChatClient` | This class is needed for the chat functionality. You instantiate it with your subscription information, and use it to create, get, delete threads, and subscribe to chat events. |
155-
| `ChatThreadClient` | This class is needed for the chat thread functionality. You obtain an instance via `ChatClient`, and use it to send, receive, update, and delete messages. You can also use it to add, remove, and get users, send typing notifications and read receipts. |
156+
| `ChatClient` | This class is needed for the chat function. You instantiate it with your subscription information, and use it to create, get, delete threads, and subscribe to chat events. |
157+
| `ChatThreadClient` | This class is needed for the chat thread function. You get an instance via `ChatClient`, and use it to send, receive, update, and delete messages. You can also use it to add, remove, get users, and send typing notifications and read receipts. |
156158

157159

158160
### Start a chat thread
159161

160162
#### Twilio
161-
The following code snippet allow to create a new chat thread
163+
164+
The following code snippet enables you to create a new chat thread.
165+
162166
```swift
163167
// the unique name of the conversation you create
164168
private let uniqueConversationName = "general"
@@ -191,10 +195,11 @@ The following code snippet allow to create a new chat thread
191195
```
192196

193197
#### Azure Communication Services
194-
`CreateChatThreadResult` is the response returned from creating a chat thread.
195-
It contains a `chatThread` property which is the `ChatThreadProperties` object. This object contains the threadId which can be used to get a `ChatThreadClient` for performing operations on the created thread: add participants, send message, etc.
196198

197-
Replace the comment `<CREATE A CHAT THREAD>` with the code snippet below:
199+
The response returned from creating a chat thread is `CreateChatThreadResult`.
200+
It contains a `chatThread` property, which is the `ChatThreadProperties` object. This object contains the `threadId`, which you can use to get a `ChatThreadClient` for performing operations on the created thread: add participants, send message, and so on.
201+
202+
Replace the comment `<CREATE A CHAT THREAD>` with the following code snippet:
198203

199204
```swift
200205
let request = CreateChatThreadRequest(
@@ -223,14 +228,15 @@ semaphore.wait()
223228

224229
Replace `<USER_ID>` with a valid Communication Services user ID.
225230

226-
You're using a semaphore here to wait for the completion handler before continuing. In later steps, you'll use the `threadId` from the response returned to the completion handler.
231+
You're using a semaphore here to wait for the completion handler before continuing. In later steps, use the `threadId` from the response returned to the completion handler.
227232

228233

229234
### Get a chat thread client
230235

231236
#### Twilio
232237

233-
The following code snippet showes how to get chat thread client in Twilio.
238+
The following code snippet shows how to get a chat thread client in Twilio.
239+
234240
```swift
235241
func conversationsClient(_ client: TwilioConversationsClient, synchronizationStatusUpdated status: TCHClientSynchronizationStatus) {
236242
guard status == .completed else {
@@ -252,7 +258,10 @@ func conversationsClient(_ client: TwilioConversationsClient, synchronizationSta
252258
```
253259

254260
#### Azure Communication Services
255-
The `createClient` method returns a `ChatThreadClient` for a thread that already exists. It can be used for performing operations on the created thread: add participants, send message, etc. threadId is the unique ID of the existing chat thread.
261+
262+
The `createClient` method returns a `ChatThreadClient` for a thread that already exists. You can use it to perform operations on the created thread: add participants, send message, and so on.
263+
264+
The `threadId` is the unique ID of the existing chat thread.
256265

257266
Replace the comment `<GET A CHAT THREAD CLIENT>` with the following code:
258267

@@ -261,10 +270,13 @@ let chatThreadClient = try chatClient.createClient(forThread: threadId!)
261270
```
262271

263272
### Send a message to a chat thread
264-
Unlike Twilio ACS does not have separate function to send text message or media.
273+
274+
Unlike Twilio, Azure Communication Services doesn't have separate function to send text message or media.
265275

266276
#### Twilio
267-
Sending a regular text message in Twilio.
277+
278+
Send a regular text message in Twilio.
279+
268280
```swift
269281
func sendMessage(_ messageText: String,
270282
completion: @escaping (TCHResult, TCHMessage?) -> Void) {
@@ -277,7 +289,8 @@ Sending a regular text message in Twilio.
277289
}
278290
```
279291

280-
Sending media.
292+
Send media in Twilio:
293+
281294
```swift
282295
/ The data for the image you would like to send
283296
let data = Data()
@@ -309,18 +322,19 @@ self.conversation.prepareMessage
309322
```
310323

311324
#### Azure Communication Services
312-
Use the `send` method to send a message to a thread identified by threadId.
313325

314-
`SendChatMessageRequest` is used to describe the message request:
326+
Use the `send` method to send a message to a thread identified by `threadId`.
327+
328+
Use `SendChatMessageRequest` to describe the message request:
315329

316-
- Use `content` to provide the chat message content
317-
- Use `senderDisplayName` to specify the display name of the sender
318-
- Use `type` to specify the message type, such as 'text' or 'html'
319-
- Use `metadata` optionally to include any additional data you want to send along with the message. This field provides a mechanism for developers to extend chat message functionality and add custom information for your use case. For example, when sharing a file link in the message, you might want to add 'hasAttachment:true' in metadata so that recipient's application can parse that and display accordingly.
330+
- Use `content` to provide the chat message content.
331+
- Use `senderDisplayName` to specify the display name of the sender.
332+
- Use `type` to specify the message type, such as `text` or `html`.
333+
- Use `metadata` optionally to include any information you want to send along with the message. This field provides a mechanism for developers to extend chat message functionality and add custom information for your use case. For example, when sharing a file link in the message, you might want to add `hasAttachment:true` in metadata so that recipient's application can parse that and display accordingly.
320334

321-
`SendChatMessageResult` is the response returned from sending a message, it contains an ID, which is the unique ID of the message.
335+
The response returned from sending a message is`SendChatMessageResult`. It contains an ID, which is the unique ID of the message.
322336

323-
Replace the comment `<SEND A MESSAGE>` with the code snippet below:
337+
Replace the comment `<SEND A MESSAGE>` with the following code snippet:
324338

325339
```swift
326340
let message = SendChatMessageRequest(
@@ -349,10 +363,13 @@ semaphore.wait()
349363
```
350364

351365
### Receive chat messages from a chat thread
352-
Unlike Twilio ACS does not have separate function to receive text message or media.
366+
367+
Unlike Twilio, Azure Communication Services doesn't have a separate function to receive text message or media.
353368

354369
#### Twilio
355-
Code snippet below shows how to receive text message in Twilio.
370+
371+
The following code snippet shows how to receive a text message in Twilio.
372+
356373
```swift
357374
// Called whenever a conversation we've joined receives a new message
358375
func conversationsClient(_ client: TwilioConversationsClient, conversation: TCHConversation,
@@ -369,7 +386,8 @@ Code snippet below shows how to receive text message in Twilio.
369386
}
370387
```
371388

372-
Receive media
389+
Receive media in Twilio:
390+
373391
```swift
374392
conversationsClient.getTemporaryContentUrlsForMedia(message.attachedMedia) { result, mediaSidToUrlMap in
375393
guard result.isSuccessful else {
@@ -384,9 +402,10 @@ conversationsClient.getTemporaryContentUrlsForMedia(message.attachedMedia) { res
384402
```
385403

386404
#### Azure Communication Services
387-
With real-time signaling, you can subscribe to listen for new incoming messages and update the current messages in memory accordingly. Azure Communication Services supports a [list of events that you can subscribe to](../../../concepts/chat/concepts.md#real-time-notifications).
388405

389-
Replace the comment `<RECEIVE MESSAGES>` with the code below. After enabling notifications, try sending new messages to see the ChatMessageReceivedEvents.
406+
With real-time signaling, you can subscribe to listen for new incoming messages and update the current messages in memory accordingly. Azure Communication Services supports a [list of events that you can subscribe to](../../concepts/chat/concepts.md#real-time-notifications).
407+
408+
Replace the comment `<RECEIVE MESSAGES>` with the following code. After enabling notifications, try sending new messages to see the `ChatMessageReceivedEvents`.
390409

391410
```swift
392411
chatClient.startRealTimeNotifications { result in
@@ -410,7 +429,7 @@ chatClient.register(event: .chatMessageReceived, handler: { response in
410429
})
411430
```
412431

413-
Alternatively you can retrieve chat messages by polling the `listMessages` method at specified intervals. See the following code snippet for `listMessages`
432+
Alternatively you can retrieve chat messages by polling the `listMessages` method at specified intervals. See the following code snippet for `listMessages`.
414433

415434
```swift
416435
chatThreadClient.listMessages { result, _ in
@@ -435,7 +454,9 @@ semaphore.wait()
435454

436455
### Push notifications
437456

438-
Similar to Twilio Azure Communication Services support push notifications. Push notifications notify clients of incoming messages in a chat thread in situations where the mobile app is not running in the foreground.
439-
Currently sending chat push notifications with Notification Hub is supported for IOS SDK in version 1.3.0.
440-
Please refer to the article [Enable Push Notification in your chat app](../../../tutorials/add-chat-push-notifications.md) for details.
457+
Similar to Twilio, Azure Communication Services support push notifications. Push notifications notify clients of incoming messages in a chat thread if the mobile app isn't running in the foreground.
458+
459+
Currently sending chat push notifications with Notification Hub is supported for iOS SDK in version 1.3.0.
460+
461+
For more information, see [Enable Push Notification in your chat app](../../tutorials/add-chat-push-notifications.md).
441462

0 commit comments

Comments
 (0)