Skip to content

Commit f487dbe

Browse files
Update demo app path, cocoapods and demo code
1 parent 1e97646 commit f487dbe

File tree

2 files changed

+43
-26
lines changed
  • articles/communication-services/quickstarts/ui-library/includes

2 files changed

+43
-26
lines changed

articles/communication-services/quickstarts/ui-library/includes/get-started-call/ios.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: azure-communication-services
88

99
> [!VIDEO https://www.youtube.com/embed/Aq5VTLfXU_4]
1010
11-
Get the sample iOS application for this [quickstart](https://github.com/Azure-Samples/communication-services-ios-quickstarts/tree/main/ui-library-quick-start) in the open source Azure Communication Services [UI Library for iOS](https://github.com/Azure/communication-ui-library-ios).
11+
Get the sample iOS application for this [quickstart](https://github.com/Azure-Samples/communication-services-ios-quickstarts/tree/main/ui-calling) in the open source Azure Communication Services [UI Library for iOS](https://github.com/Azure/communication-ui-library-ios).
1212

1313
## Prerequisites
1414

articles/communication-services/quickstarts/ui-library/includes/get-started-chat/ios.md

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: azure-communication-services
88

99
[!INCLUDE [Public Preview Notice](../../../../includes/public-preview-include.md)]
1010

11-
Get the sample iOS application for this [quickstart](https://github.com/Azure-Samples/communication-services-ios-quickstarts/tree/main/ui-library-quick-start/Chat) in the open source Azure Communication Services [UI Library for iOS](https://github.com/Azure/communication-ui-library-ios).
11+
Get the sample iOS application for this [quickstart](https://github.com/Azure-Samples/communication-services-ios-quickstarts/tree/main/ui-chat) in the open source Azure Communication Services [UI Library for iOS](https://github.com/Azure/communication-ui-library-ios).
1212

1313
## Prerequisites
1414

@@ -32,7 +32,7 @@ In Xcode, create a new project:
3232

3333
:::image type="content" source="../../media/xcode-new-project-template-select.png" alt-text="Screenshot that shows the Xcode new project dialog, with iOS and the App template selected.":::
3434

35-
1. In **Choose options for your new project**, for the product name, enter **Chat**. For the interface, select **Storyboard**. The quickstart doesn't create tests, so you can clear the **Include Tests** checkbox.
35+
1. In **Choose options for your new project**, for the product name, enter **UILibraryQuickStart**. For the interface, select **Storyboard**. The quickstart doesn't create tests, so you can clear the **Include Tests** checkbox.
3636

3737
:::image type="content" source="../../media/xcode-new-project-details.png" alt-text="Screenshot that shows setting new project options in Xcode.":::
3838

@@ -42,14 +42,14 @@ In Xcode, create a new project:
4242

4343
1. In your project root directory, run `pod init` to create a Podfile. If you encounter an error, update [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) to the current version.
4444

45-
1. Add the following code to your Podfile. Replace `Chat` with your project name.
45+
1. Add the following code to your Podfile. Replace `UILibraryQuickStart` with your project name.
4646

4747
```ruby
4848
platform :ios, '14.0'
4949

50-
target 'Chat' do
50+
target 'UILibraryQuickStart' do
5151
use_frameworks!
52-
pod 'AzureCommunicationUIChat', '0.1.0-beta.1'
52+
pod 'AzureCommunicationUIChat', '1.0.0-beta1'
5353
end
5454
```
5555

@@ -69,19 +69,20 @@ To initialize the composite:
6969

7070
1. Go to `ViewController`.
7171

72-
1. Add the following code to initialize your composite components for a chat. Replace `<USER_ID>` with user identifier. Replace `<USER_ACCESS_TOKEN>` with your access token. Replace `<ENDPOINT_URL>` with your endpoint URL. Replace `<DISPLAY_NAME>` with your name. (The string length limit for `<DISPLAY_NAME>` is 256 characters). Replace `<THREAD_ID>` with your chat thread ID.
72+
1. Add the following code to initialize your composite components for a chat. Replace `<USER_ID>` with user identifier. Replace `<USER_ACCESS_TOKEN>` with your access token. Replace `<ENDPOINT_URL>` with your endpoint URL. Replace `<THREAD_ID>` with your chat thread ID. Replace `<DISPLAY_NAME>` with your name. (The string length limit for `<DISPLAY_NAME>` is 256 characters).
7373

7474
```swift
7575
import UIKit
7676
import AzureCommunicationCommon
7777
import AzureCommunicationUIChat
7878
7979
class ViewController: UIViewController {
80+
var chatAdapter: ChatAdapter?
8081
8182
override func viewDidLoad() {
8283
super.viewDidLoad()
8384
84-
let button = UIButton(frame: CGRect(x: 100, y: 100, width: 200, height: 50))
85+
let button = UIButton()
8586
button.contentEdgeInsets = UIEdgeInsets(top: 10.0, left: 20.0, bottom: 10.0, right: 20.0)
8687
button.layer.cornerRadius = 10
8788
button.backgroundColor = .systemBlue
@@ -90,6 +91,8 @@ To initialize the composite:
9091
9192
button.translatesAutoresizingMaskIntoConstraints = false
9293
self.view.addSubview(button)
94+
button.widthAnchor.constraint(equalToConstant: 200).isActive = true
95+
button.heightAnchor.constraint(equalToConstant: 50).isActive = true
9396
button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
9497
button.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
9598
}
@@ -101,35 +104,49 @@ To initialize the composite:
101104
return
102105
}
103106
104-
let chatAdapter = ChatAdapter(
105-
identifier: communicationIdentifier,
107+
self.chatAdapter = ChatAdapter(
108+
endpoint: "<ENDPOINT_URL>", identifier: communicationIdentifier,
106109
credential: communicationTokenCredential,
107-
endpoint: "<ENDPOINT_URL>",
110+
threadId: "<THREAD_ID>",
108111
displayName: "<DISPLAY_NAME>")
109112
110-
chatAdapter.connect(threadId: "<THREAD_ID>") { [weak self] _ in
111-
print("Chat connect completionHandler called")
112-
DispatchQueue.main.async {
113-
let chatCompositeViewController = ChatCompositeViewController(
114-
with: chatAdapter)
115-
chatCompositeViewController.title = "Chat"
116-
let closeItem = UIBarButtonItem(
117-
barButtonSystemItem: .close,
118-
target: nil,
119-
action: #selector(self?.onBackBtnPressed))
120-
chatCompositeViewController.navigationItem.leftBarButtonItem = closeItem
121-
122-
let navController = UINavigationController(rootViewController: chatCompositeViewController)
123-
navController.modalPresentationStyle = .fullScreen
124-
self?.present(navController, animated: true, completion: nil)
113+
Task { @MainActor in
114+
guard let chatAdapter = self.chatAdapter else {
115+
return
125116
}
117+
try await chatAdapter.connect()
118+
let chatCompositeViewController = ChatCompositeViewController(
119+
with: chatAdapter)
120+
121+
let closeItem = UIBarButtonItem(
122+
barButtonSystemItem: .close,
123+
target: nil,
124+
action: #selector(self.onBackBtnPressed))
125+
chatCompositeViewController.title = "Chat"
126+
chatCompositeViewController.navigationItem.leftBarButtonItem = closeItem
127+
128+
let navController = UINavigationController(rootViewController: chatCompositeViewController)
129+
navController.modalPresentationStyle = .fullScreen
130+
131+
self.present(navController, animated: true, completion: nil)
126132
}
127133
}
128134
129135
@objc func onBackBtnPressed() {
130136
self.dismiss(animated: true, completion: nil)
137+
Task { @MainActor in
138+
self.chatAdapter?.disconnect(completionHandler: { [weak self] result in
139+
switch result {
140+
case .success:
141+
self?.chatAdapter = nil
142+
case .failure(let error):
143+
print("disconnect error \(error)")
144+
}
145+
})
146+
}
131147
}
132148
}
149+
133150
```
134151

135152
## Run the code

0 commit comments

Comments
 (0)