Quickstart: Add Chat to your App
For full instructions on how to build this code sample from scratch, look at Quickstart: Add Chat to your App
Prerequisites
To complete this tutorial, you’ll need the following prerequisites:
- An Azure account with an active subscription. Create an account for free.
- Install Xcode and CocoaPods. You use Xcode to create an iOS application for the quickstart, and CocoaPods to install dependencies.
- A deployed Communication Services resource. Create a Communication Services resource.
- Create two users in Azure Communication Services, and issue them a user access token. Be sure to set the scope to chat, and note the token string as well as the userId string. In this quickstart, you create a thread with an initial participant, and then add a second participant to the thread.
Before running sample code
Open an instance of PowerShell, Windows Terminal, Command Prompt or equivalent and navigate to the directory that you'd like to clone the sample to.
git clone https://github.com/Azure-Samples/Communication-Services-ios-quickstarts.git
With the
Access Token
procured in pre-requisites, add it to the ChatQuickstart/ViewController.swift file. Assign your access token in line 25:let credential =try CommunicationTokenCredential(token: "<ACCESS_TOKEN>")
With the
End point
procured in pre-requisites, add it to the ChatQuickstart/ViewController.swift file. Assign end point in line 22:let endpoint = "<ACS_RESOURCE_ENDPOINT>"
With the
Communication Services user ID
procured in pre-requisites, add it to the ChatQuickstart/ViewController.swift file. Assign first user ID in line 40.With the
Communication Services user ID
procured in pre-requisites, add it to the ChatQuickstart/ViewController.swift file. Assign second user ID in line 131.
Run the sample
- In Xcode hit the Run button to build and run the project. In the console you can view the output from the code and the logger output from the ChatClient.