@cometchat/skills 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -17
- package/bin/install.js +389 -43
- package/package.json +19 -9
- package/skills/cometchat/SKILL.md +1066 -265
- package/skills/cometchat-android-v5/SKILL.md +120 -0
- package/skills/cometchat-android-v5-components/SKILL.md +430 -0
- package/skills/cometchat-android-v5-core/SKILL.md +468 -0
- package/skills/cometchat-android-v5-customization/SKILL.md +305 -0
- package/skills/cometchat-android-v5-extensions/SKILL.md +124 -0
- package/skills/cometchat-android-v5-features/SKILL.md +130 -0
- package/skills/cometchat-android-v5-placement/SKILL.md +276 -0
- package/skills/cometchat-android-v5-production/SKILL.md +94 -0
- package/skills/cometchat-android-v5-push/SKILL.md +620 -0
- package/skills/cometchat-android-v5-testing/SKILL.md +187 -0
- package/skills/cometchat-android-v5-theming/SKILL.md +166 -0
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +73 -0
- package/skills/cometchat-android-v6/SKILL.md +107 -0
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +145 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +202 -0
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +280 -0
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +213 -0
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +224 -0
- package/skills/cometchat-android-v6-core/SKILL.md +354 -0
- package/skills/cometchat-android-v6-events/SKILL.md +212 -0
- package/skills/cometchat-android-v6-extensions/SKILL.md +191 -0
- package/skills/cometchat-android-v6-features/SKILL.md +130 -0
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +197 -0
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +268 -0
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +248 -0
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +202 -0
- package/skills/cometchat-android-v6-production/SKILL.md +187 -0
- package/skills/cometchat-android-v6-push/SKILL.md +274 -0
- package/skills/cometchat-android-v6-testing/SKILL.md +279 -0
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +249 -0
- package/skills/cometchat-angular-components/SKILL.md +706 -0
- package/skills/cometchat-angular-core/SKILL.md +444 -0
- package/skills/cometchat-angular-customization/SKILL.md +424 -0
- package/skills/cometchat-angular-features/SKILL.md +447 -0
- package/skills/cometchat-angular-patterns/SKILL.md +447 -0
- package/skills/cometchat-angular-placement/SKILL.md +685 -0
- package/skills/cometchat-angular-production/SKILL.md +415 -0
- package/skills/cometchat-angular-theming/SKILL.md +365 -0
- package/skills/cometchat-angular-troubleshooting/SKILL.md +329 -0
- package/skills/cometchat-astro-patterns/SKILL.md +3 -3
- package/skills/cometchat-components/SKILL.md +11 -0
- package/skills/cometchat-core/SKILL.md +11 -6
- package/skills/cometchat-customization/references/component-catalog.md +1 -1
- package/skills/cometchat-features/SKILL.md +176 -108
- package/skills/cometchat-flutter-v5/SKILL.md +167 -0
- package/skills/cometchat-flutter-v5-calls/SKILL.md +192 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +117 -0
- package/skills/cometchat-flutter-v5-core/SKILL.md +221 -0
- package/skills/cometchat-flutter-v5-customization/SKILL.md +227 -0
- package/skills/cometchat-flutter-v5-events/SKILL.md +155 -0
- package/skills/cometchat-flutter-v5-messages/SKILL.md +258 -0
- package/skills/cometchat-flutter-v5-production/SKILL.md +207 -0
- package/skills/cometchat-flutter-v5-push/SKILL.md +284 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +160 -0
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +129 -0
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +151 -0
- package/skills/cometchat-flutter-v6/SKILL.md +445 -0
- package/skills/cometchat-flutter-v6-calls/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +365 -0
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +210 -0
- package/skills/cometchat-flutter-v6-core/SKILL.md +305 -0
- package/skills/cometchat-flutter-v6-customization/SKILL.md +666 -0
- package/skills/cometchat-flutter-v6-events/SKILL.md +216 -0
- package/skills/cometchat-flutter-v6-features/SKILL.md +406 -0
- package/skills/cometchat-flutter-v6-messages/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-migration/SKILL.md +381 -0
- package/skills/cometchat-flutter-v6-placement/SKILL.md +398 -0
- package/skills/cometchat-flutter-v6-production/SKILL.md +632 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +260 -0
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +726 -0
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +216 -0
- package/skills/cometchat-ios/SKILL.md +323 -0
- package/skills/cometchat-ios-components/SKILL.md +651 -0
- package/skills/cometchat-ios-core/SKILL.md +822 -0
- package/skills/cometchat-ios-customization/SKILL.md +825 -0
- package/skills/cometchat-ios-features/SKILL.md +725 -0
- package/skills/cometchat-ios-placement/SKILL.md +750 -0
- package/skills/cometchat-ios-production/SKILL.md +730 -0
- package/skills/cometchat-ios-push/SKILL.md +582 -0
- package/skills/cometchat-ios-theming/SKILL.md +631 -0
- package/skills/cometchat-ios-troubleshooting/SKILL.md +983 -0
- package/skills/cometchat-native-bare-patterns/SKILL.md +470 -0
- package/skills/cometchat-native-components/SKILL.md +594 -0
- package/skills/cometchat-native-core/SKILL.md +407 -0
- package/skills/cometchat-native-customization/SKILL.md +594 -0
- package/skills/cometchat-native-expo-patterns/SKILL.md +485 -0
- package/skills/cometchat-native-features/SKILL.md +608 -0
- package/skills/cometchat-native-placement/SKILL.md +500 -0
- package/skills/cometchat-native-production/SKILL.md +694 -0
- package/skills/cometchat-native-push/SKILL.md +593 -0
- package/skills/cometchat-native-testing/SKILL.md +583 -0
- package/skills/cometchat-native-theming/SKILL.md +656 -0
- package/skills/cometchat-native-troubleshooting/SKILL.md +433 -0
- package/skills/cometchat-nextjs-patterns/SKILL.md +5 -5
- package/skills/cometchat-production/SKILL.md +60 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +23 -21
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-ios-components
|
|
3
|
+
description: "Complete catalog of CometChat iOS UI Kit v5 components with correct usage patterns from official documentation."
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "CometChatUIKitSwift ^5; CometChatSDK ^4; iOS 13+"
|
|
6
|
+
allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "3.0.0"
|
|
10
|
+
tags: "chat cometchat ios swift components catalog reference ui-kit"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Purpose
|
|
14
|
+
|
|
15
|
+
This is the single source of truth for CometChat iOS UI Kit v5 component names, properties, and usage patterns. All examples are based on official CometChat documentation.
|
|
16
|
+
|
|
17
|
+
All components are imported from `CometChatUIKitSwift`. All SDK types are imported from `CometChatSDK`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 1. CometChatConversations
|
|
22
|
+
|
|
23
|
+
A `UIViewController` that displays a scrollable list of the logged-in user's conversations.
|
|
24
|
+
|
|
25
|
+
**Usage:**
|
|
26
|
+
```swift
|
|
27
|
+
import CometChatUIKitSwift
|
|
28
|
+
import CometChatSDK
|
|
29
|
+
|
|
30
|
+
let conversationsVC = CometChatConversations()
|
|
31
|
+
let navController = UINavigationController(rootViewController: conversationsVC)
|
|
32
|
+
|
|
33
|
+
conversationsVC.set(onItemClick: { [weak navController] conversation, indexPath in
|
|
34
|
+
let messagesVC = MessagesVC() // your own VC composing CometChatMessageHeader + List + Composer; see cometchat-ios-components § 12
|
|
35
|
+
if let group = conversation.conversationWith as? Group {
|
|
36
|
+
messagesVC.set(group: group)
|
|
37
|
+
} else if let user = conversation.conversationWith as? User {
|
|
38
|
+
messagesVC.set(user: user)
|
|
39
|
+
}
|
|
40
|
+
navController?.pushViewController(messagesVC, animated: true)
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Key Properties:**
|
|
45
|
+
| Property | Type | Description |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `style` | `ConversationsStyle` | Visual styling |
|
|
48
|
+
| `hideReceipts` | `Bool` | Hide message read receipts |
|
|
49
|
+
| `hideUserStatus` | `Bool` | Hide online/offline status |
|
|
50
|
+
| `disableTyping` | `Bool` | Disable typing indicators |
|
|
51
|
+
| `disableSoundForMessages` | `Bool` | Disable message sounds |
|
|
52
|
+
|
|
53
|
+
**Callbacks:**
|
|
54
|
+
| Callback | Method | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `onItemClick` | `set(onItemClick:)` | Conversation tapped |
|
|
57
|
+
| `onItemLongClick` | `set(onItemLongClick:)` | Conversation long-pressed |
|
|
58
|
+
| `onError` | `set(onError:)` | Error occurred |
|
|
59
|
+
| `onEmpty` | `set(onEmpty:)` | List is empty |
|
|
60
|
+
| `onLoad` | `set(onLoad:)` | Conversations loaded |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 2. CometChatUsers
|
|
65
|
+
|
|
66
|
+
A `UIViewController` that displays a list of users.
|
|
67
|
+
|
|
68
|
+
**Usage:**
|
|
69
|
+
```swift
|
|
70
|
+
let usersVC = CometChatUsers()
|
|
71
|
+
let usersNav = UINavigationController(rootViewController: usersVC)
|
|
72
|
+
|
|
73
|
+
usersVC.set(onItemClick: { [weak usersNav] user, indexPath in
|
|
74
|
+
let messagesVC = MessagesVC() // your own VC composing CometChatMessageHeader + List + Composer; see cometchat-ios-components § 12
|
|
75
|
+
messagesVC.set(user: user)
|
|
76
|
+
usersNav?.pushViewController(messagesVC, animated: true)
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Key Properties:**
|
|
81
|
+
| Property | Type | Description |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `style` | `UsersStyle` | Visual styling |
|
|
84
|
+
| `hideSearch` | `Bool` | Hide the built-in search bar (inherited from `CometChatListBase`; default `true`) |
|
|
85
|
+
| `hideUserStatus` | `Bool` | Hide online/offline indicator |
|
|
86
|
+
| `selectionMode` | `SelectionMode` | `.none`, `.single`, `.multiple` |
|
|
87
|
+
|
|
88
|
+
**Callbacks:**
|
|
89
|
+
| Callback | Method | Description |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `onItemClick` | `set(onItemClick:)` | User tapped |
|
|
92
|
+
| `onSelection` | `set(onSelection:)` | Selection changed |
|
|
93
|
+
| `onError` | `set(onError:)` | Error occurred |
|
|
94
|
+
|
|
95
|
+
**Custom Subtitle View:**
|
|
96
|
+
```swift
|
|
97
|
+
import CometChatSDK
|
|
98
|
+
|
|
99
|
+
let usersVC = CometChatUsers()
|
|
100
|
+
|
|
101
|
+
// Custom subtitle with explicit type annotation
|
|
102
|
+
usersVC.set(subtitle: { (user: User?) -> UIView in
|
|
103
|
+
let label = UILabel()
|
|
104
|
+
label.font = .systemFont(ofSize: 13)
|
|
105
|
+
if user?.status == .online {
|
|
106
|
+
label.text = "Online"
|
|
107
|
+
label.textColor = .systemGreen
|
|
108
|
+
} else {
|
|
109
|
+
label.text = "Offline"
|
|
110
|
+
label.textColor = .secondaryLabel
|
|
111
|
+
}
|
|
112
|
+
return label
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Custom Request Builder:**
|
|
117
|
+
```swift
|
|
118
|
+
let usersVC = CometChatUsers()
|
|
119
|
+
usersVC.set(userRequestBuilder: UsersRequest.UsersRequestBuilder()
|
|
120
|
+
.set(limit: 30)
|
|
121
|
+
.set(searchKeyword: "john")
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 3. CometChatGroups
|
|
128
|
+
|
|
129
|
+
A `UIViewController` that displays a list of groups.
|
|
130
|
+
|
|
131
|
+
**Usage:**
|
|
132
|
+
```swift
|
|
133
|
+
let groupsVC = CometChatGroups()
|
|
134
|
+
let groupsNav = UINavigationController(rootViewController: groupsVC)
|
|
135
|
+
|
|
136
|
+
groupsVC.set(onItemClick: { [weak groupsNav] group, indexPath in
|
|
137
|
+
let messagesVC = MessagesVC() // your own VC composing CometChatMessageHeader + List + Composer; see cometchat-ios-components § 12
|
|
138
|
+
messagesVC.set(group: group)
|
|
139
|
+
groupsNav?.pushViewController(messagesVC, animated: true)
|
|
140
|
+
})
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Key Properties:**
|
|
144
|
+
| Property | Type | Description |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| `style` | `GroupsStyle` | Visual styling |
|
|
147
|
+
| `hideSearch` | `Bool` | Hide the built-in search bar (inherited from `CometChatListBase`; default `true`) |
|
|
148
|
+
| `selectionMode` | `SelectionMode` | `.none`, `.single`, `.multiple` |
|
|
149
|
+
|
|
150
|
+
**Callbacks:**
|
|
151
|
+
| Callback | Method | Description |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| `onItemClick` | `set(onItemClick:)` | Group tapped |
|
|
154
|
+
| `onSelection` | `set(onSelection:)` | Selection changed |
|
|
155
|
+
| `onError` | `set(onError:)` | Error occurred |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 4. CometChatMessageHeader
|
|
160
|
+
|
|
161
|
+
A `UIView` that displays user/group info and back button at the top of a message view.
|
|
162
|
+
|
|
163
|
+
**Usage:**
|
|
164
|
+
```swift
|
|
165
|
+
private lazy var headerView: CometChatMessageHeader = {
|
|
166
|
+
let view = CometChatMessageHeader()
|
|
167
|
+
view.translatesAutoresizingMaskIntoConstraints = false
|
|
168
|
+
if let user = user {
|
|
169
|
+
view.set(user: user)
|
|
170
|
+
} else if let group = group {
|
|
171
|
+
view.set(group: group)
|
|
172
|
+
}
|
|
173
|
+
view.set(controller: self)
|
|
174
|
+
return view
|
|
175
|
+
}()
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Key Properties:**
|
|
179
|
+
| Property | Type | Description |
|
|
180
|
+
|---|---|---|
|
|
181
|
+
| `style` | `MessageHeaderStyle` | Visual styling |
|
|
182
|
+
| `hideBackButton` | `Bool` | Hide back button |
|
|
183
|
+
| `hideVideoCallButton` | `Bool` | Hide video call button |
|
|
184
|
+
| `hideVoiceCallButton` | `Bool` | Hide voice call button |
|
|
185
|
+
|
|
186
|
+
**Important:** Always call `view.set(controller: self)` to enable navigation.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 5. CometChatMessageList
|
|
191
|
+
|
|
192
|
+
A `UIView` that displays messages with real-time updates.
|
|
193
|
+
|
|
194
|
+
**Usage:**
|
|
195
|
+
```swift
|
|
196
|
+
private lazy var messageListView: CometChatMessageList = {
|
|
197
|
+
let listView = CometChatMessageList()
|
|
198
|
+
listView.translatesAutoresizingMaskIntoConstraints = false
|
|
199
|
+
if let user = user {
|
|
200
|
+
listView.set(user: user)
|
|
201
|
+
} else if let group = group {
|
|
202
|
+
listView.set(group: group)
|
|
203
|
+
}
|
|
204
|
+
listView.set(controller: self)
|
|
205
|
+
return listView
|
|
206
|
+
}()
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Key Properties:**
|
|
210
|
+
| Property | Type | Description |
|
|
211
|
+
|---|---|---|
|
|
212
|
+
| `style` | `MessageListStyle` | Visual styling |
|
|
213
|
+
| `hideReceipts` | `Bool` | Hide read receipts |
|
|
214
|
+
| `hideDateSeparator` | `Bool` | Hide date separators |
|
|
215
|
+
| `hideAvatar` | `Bool` | Hide sender avatars |
|
|
216
|
+
| `scrollToBottomOnNewMessages` | `Bool` | Auto-scroll on new messages |
|
|
217
|
+
| `messageAlignment` | `MessageListAlignment` | `.standard` or `.leftAligned` |
|
|
218
|
+
|
|
219
|
+
**Important:** Always call `listView.set(controller: self)` for proper functionality.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 6. CometChatMessageComposer
|
|
224
|
+
|
|
225
|
+
A `UIView` for composing and sending messages.
|
|
226
|
+
|
|
227
|
+
**Usage:**
|
|
228
|
+
```swift
|
|
229
|
+
private lazy var composerView: CometChatMessageComposer = {
|
|
230
|
+
let composer = CometChatMessageComposer()
|
|
231
|
+
composer.translatesAutoresizingMaskIntoConstraints = false
|
|
232
|
+
if let user = user {
|
|
233
|
+
composer.set(user: user)
|
|
234
|
+
} else if let group = group {
|
|
235
|
+
composer.set(group: group)
|
|
236
|
+
}
|
|
237
|
+
composer.set(controller: self)
|
|
238
|
+
return composer
|
|
239
|
+
}()
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Key Properties:**
|
|
243
|
+
| Property | Type | Description |
|
|
244
|
+
|---|---|---|
|
|
245
|
+
| `style` | `MessageComposerStyle` | Visual styling |
|
|
246
|
+
| `placeholderText` | `String` | Placeholder text |
|
|
247
|
+
| `hideVoiceRecordingButton` | `Bool` | Hide voice recording button |
|
|
248
|
+
| `hideAttachmentButton` | `Bool` | Hide attachment button |
|
|
249
|
+
| `hideStickersButton` | `Bool` | Hide stickers button |
|
|
250
|
+
|
|
251
|
+
**Important:** Always call `composer.set(controller: self)` for proper functionality.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 7. CometChatCallLogs
|
|
256
|
+
|
|
257
|
+
A `UIViewController` that displays call history.
|
|
258
|
+
|
|
259
|
+
**Requires:** `CometChatCallsSDK`
|
|
260
|
+
|
|
261
|
+
**Usage:**
|
|
262
|
+
```swift
|
|
263
|
+
#if canImport(CometChatCallsSDK)
|
|
264
|
+
let callLogsVC = CometChatCallLogs()
|
|
265
|
+
let callLogsNav = UINavigationController(rootViewController: callLogsVC)
|
|
266
|
+
#endif
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 8. CometChatGroupMembers
|
|
272
|
+
|
|
273
|
+
A `UIViewController` that displays members of a specific group.
|
|
274
|
+
|
|
275
|
+
**Usage:**
|
|
276
|
+
```swift
|
|
277
|
+
// CometChatGroupMembers has a zero-arg initializer; pass the group via
|
|
278
|
+
// `set(group:)`. There is no `CometChatGroupMembers(group:)` initializer.
|
|
279
|
+
let groupMembers = CometChatGroupMembers()
|
|
280
|
+
groupMembers.set(group: group)
|
|
281
|
+
navigationController?.pushViewController(groupMembers, animated: true)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 9. User / Group details — build your own VC
|
|
287
|
+
|
|
288
|
+
There is **no `CometChatDetails` view controller exported by the kit.** The sample app builds a details screen by composing avatar, list rows, and action sheets directly. Follow the same pattern in your app — `SampleApp/View Controllers/DetailsPage/UserDetailsViewController.swift` is a reasonable starting point to copy.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 10. CometChatUIKit
|
|
293
|
+
|
|
294
|
+
Static class for initialization and authentication.
|
|
295
|
+
|
|
296
|
+
**Initialization:**
|
|
297
|
+
```swift
|
|
298
|
+
let uikitSettings = UIKitSettings()
|
|
299
|
+
.set(appID: "APP_ID")
|
|
300
|
+
.set(region: "REGION")
|
|
301
|
+
.set(authKey: "AUTH_KEY")
|
|
302
|
+
.subscribePresenceForAllUsers()
|
|
303
|
+
.build()
|
|
304
|
+
|
|
305
|
+
// Init takes a `UIKitSettings` and a `Result<Bool, Error>` completion.
|
|
306
|
+
// Both `CometChatUIKit(uiKitSettings: ...) { ... }` (constructor form)
|
|
307
|
+
// and `CometChatUIKit.init(uiKitSettings: ...) { ... }` (explicit `.init`
|
|
308
|
+
// call) compile to the same thing in Swift; the kit's sample apps use
|
|
309
|
+
// the `.init` form, so don't be alarmed if you see both. See
|
|
310
|
+
// cometchat-ios-core § 2 for the recommended singleton pattern.
|
|
311
|
+
CometChatUIKit(uiKitSettings: uikitSettings) { result in
|
|
312
|
+
switch result {
|
|
313
|
+
case .success:
|
|
314
|
+
debugPrint("CometChat initialized")
|
|
315
|
+
case .failure(let error):
|
|
316
|
+
debugPrint("Init failed: \(error.localizedDescription)")
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Login:**
|
|
322
|
+
```swift
|
|
323
|
+
CometChatUIKit.login(uid: "cometchat-uid-1") { result in
|
|
324
|
+
switch result {
|
|
325
|
+
case .success(let user):
|
|
326
|
+
print("Login successful: \(user.name ?? "")")
|
|
327
|
+
case .onError(let error):
|
|
328
|
+
print("Login failed: \(error.errorDescription)")
|
|
329
|
+
@unknown default:
|
|
330
|
+
break
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Logout:**
|
|
336
|
+
```swift
|
|
337
|
+
if let currentUser = CometChat.getLoggedInUser() {
|
|
338
|
+
CometChatUIKit.logout(user: currentUser) { result in
|
|
339
|
+
switch result {
|
|
340
|
+
case .success:
|
|
341
|
+
print("Logged out successfully")
|
|
342
|
+
case .onError(let error):
|
|
343
|
+
print("Logout failed: \(error.errorDescription)")
|
|
344
|
+
@unknown default:
|
|
345
|
+
break
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## 11. Composing a chat screen — `MessagesVC`
|
|
354
|
+
|
|
355
|
+
The kit does **not** ship a `CometChatMessages` or `CometChatConversationsWithMessages` view controller. The standard pattern (and what the sample app uses) is to compose `CometChatMessageHeader` + `CometChatMessageList` + `CometChatMessageComposer` inside your own `UIViewController`. See § 12 below for the full implementation — it's ~50 lines and gives you full control over navigation and lifecycle.
|
|
356
|
+
|
|
357
|
+
If you previously read about a "pre-built `CometChatMessages` UIViewController" in older docs or AI-generated guides, that was incorrect. Always build your own `MessagesVC` as shown in § 12 (or copy `SampleApp/View Controllers/CometChat Components/MessagesVC.swift` from the kit's sample app).
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## 12. Custom MessagesVC Implementation
|
|
362
|
+
|
|
363
|
+
If you need more control over the messaging UI, create a custom view controller that combines header, list, and composer:
|
|
364
|
+
|
|
365
|
+
```swift
|
|
366
|
+
import UIKit
|
|
367
|
+
import CometChatSDK
|
|
368
|
+
import CometChatUIKitSwift
|
|
369
|
+
|
|
370
|
+
class MessagesVC: UIViewController {
|
|
371
|
+
|
|
372
|
+
// MARK: - Properties
|
|
373
|
+
var user: User?
|
|
374
|
+
var group: Group?
|
|
375
|
+
|
|
376
|
+
// MARK: - UI Components
|
|
377
|
+
private lazy var headerView: CometChatMessageHeader = {
|
|
378
|
+
let view = CometChatMessageHeader()
|
|
379
|
+
view.translatesAutoresizingMaskIntoConstraints = false
|
|
380
|
+
if let user = user {
|
|
381
|
+
view.set(user: user)
|
|
382
|
+
} else if let group = group {
|
|
383
|
+
view.set(group: group)
|
|
384
|
+
}
|
|
385
|
+
view.set(controller: self)
|
|
386
|
+
return view
|
|
387
|
+
}()
|
|
388
|
+
|
|
389
|
+
private lazy var messageListView: CometChatMessageList = {
|
|
390
|
+
let listView = CometChatMessageList()
|
|
391
|
+
listView.translatesAutoresizingMaskIntoConstraints = false
|
|
392
|
+
if let user = user {
|
|
393
|
+
listView.set(user: user)
|
|
394
|
+
} else if let group = group {
|
|
395
|
+
listView.set(group: group)
|
|
396
|
+
}
|
|
397
|
+
listView.set(controller: self)
|
|
398
|
+
return listView
|
|
399
|
+
}()
|
|
400
|
+
|
|
401
|
+
private lazy var composerView: CometChatMessageComposer = {
|
|
402
|
+
let composer = CometChatMessageComposer()
|
|
403
|
+
composer.translatesAutoresizingMaskIntoConstraints = false
|
|
404
|
+
if let user = user {
|
|
405
|
+
composer.set(user: user)
|
|
406
|
+
} else if let group = group {
|
|
407
|
+
composer.set(group: group)
|
|
408
|
+
}
|
|
409
|
+
composer.set(controller: self)
|
|
410
|
+
return composer
|
|
411
|
+
}()
|
|
412
|
+
|
|
413
|
+
// MARK: - Lifecycle
|
|
414
|
+
override func viewDidLoad() {
|
|
415
|
+
super.viewDidLoad()
|
|
416
|
+
configureView()
|
|
417
|
+
setupLayout()
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
override func viewWillDisappear(_ animated: Bool) {
|
|
421
|
+
super.viewWillDisappear(animated)
|
|
422
|
+
navigationController?.setNavigationBarHidden(false, animated: true)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// MARK: - Setup
|
|
426
|
+
private func configureView() {
|
|
427
|
+
view.backgroundColor = .systemBackground
|
|
428
|
+
navigationController?.setNavigationBarHidden(true, animated: false)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
private func setupLayout() {
|
|
432
|
+
[headerView, messageListView, composerView].forEach { view.addSubview($0) }
|
|
433
|
+
|
|
434
|
+
NSLayoutConstraint.activate([
|
|
435
|
+
headerView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
|
436
|
+
headerView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
437
|
+
headerView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
438
|
+
headerView.heightAnchor.constraint(equalToConstant: 50),
|
|
439
|
+
|
|
440
|
+
messageListView.topAnchor.constraint(equalTo: headerView.bottomAnchor),
|
|
441
|
+
messageListView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
442
|
+
messageListView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
443
|
+
messageListView.bottomAnchor.constraint(equalTo: composerView.topAnchor),
|
|
444
|
+
|
|
445
|
+
composerView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
446
|
+
composerView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
447
|
+
composerView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
|
|
448
|
+
])
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
## 14. Complete Tab-Based Chat App
|
|
456
|
+
|
|
457
|
+
Full implementation of a tabbed chat app with Chats, Calls, Users, and Groups:
|
|
458
|
+
|
|
459
|
+
```swift
|
|
460
|
+
import UIKit
|
|
461
|
+
import CometChatUIKitSwift
|
|
462
|
+
import CometChatSDK
|
|
463
|
+
|
|
464
|
+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
465
|
+
|
|
466
|
+
var window: UIWindow?
|
|
467
|
+
|
|
468
|
+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
|
469
|
+
guard let windowScene = (scene as? UIWindowScene) else { return }
|
|
470
|
+
|
|
471
|
+
let uikitSettings = UIKitSettings()
|
|
472
|
+
.set(appID: "APP_ID")
|
|
473
|
+
.set(region: "REGION")
|
|
474
|
+
.set(authKey: "AUTH_KEY")
|
|
475
|
+
.subscribePresenceForAllUsers()
|
|
476
|
+
.build()
|
|
477
|
+
|
|
478
|
+
CometChatUIKit.init(uiKitSettings: uikitSettings) { result in
|
|
479
|
+
switch result {
|
|
480
|
+
case .success:
|
|
481
|
+
CometChatUIKit.login(uid: "cometchat-uid-1") { loginResult in
|
|
482
|
+
switch loginResult {
|
|
483
|
+
case .success:
|
|
484
|
+
DispatchQueue.main.async {
|
|
485
|
+
self.setupTabbedView(windowScene: windowScene)
|
|
486
|
+
}
|
|
487
|
+
case .onError(let error):
|
|
488
|
+
print("Login failed: \(error.errorDescription)")
|
|
489
|
+
@unknown default:
|
|
490
|
+
break
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
case .failure(let error):
|
|
494
|
+
print("Init failed: \(error)")
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
func setupTabbedView(windowScene: UIWindowScene) {
|
|
500
|
+
let tabBarController = UITabBarController()
|
|
501
|
+
tabBarController.tabBar.backgroundColor = .white
|
|
502
|
+
|
|
503
|
+
// Conversations Tab
|
|
504
|
+
let conversationsVC = CometChatConversations()
|
|
505
|
+
let conversationsNav = UINavigationController(rootViewController: conversationsVC)
|
|
506
|
+
conversationsVC.tabBarItem = UITabBarItem(
|
|
507
|
+
title: "CHATS",
|
|
508
|
+
image: UIImage(systemName: "message.fill"),
|
|
509
|
+
tag: 0
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
conversationsVC.set(onItemClick: { [weak conversationsNav] conversation, indexPath in
|
|
513
|
+
let messagesVC = MessagesVC() // your own VC composing CometChatMessageHeader + List + Composer; see cometchat-ios-components § 12
|
|
514
|
+
if let group = conversation.conversationWith as? Group {
|
|
515
|
+
messagesVC.set(group: group)
|
|
516
|
+
} else if let user = conversation.conversationWith as? User {
|
|
517
|
+
messagesVC.set(user: user)
|
|
518
|
+
}
|
|
519
|
+
messagesVC.hidesBottomBarWhenPushed = true
|
|
520
|
+
conversationsNav?.pushViewController(messagesVC, animated: true)
|
|
521
|
+
})
|
|
522
|
+
|
|
523
|
+
// Call Logs Tab
|
|
524
|
+
#if canImport(CometChatCallsSDK)
|
|
525
|
+
let callLogsVC = CometChatCallLogs()
|
|
526
|
+
let callLogsNav = UINavigationController(rootViewController: callLogsVC)
|
|
527
|
+
callLogsVC.tabBarItem = UITabBarItem(
|
|
528
|
+
title: "CALLS",
|
|
529
|
+
image: UIImage(systemName: "phone.fill"),
|
|
530
|
+
tag: 1
|
|
531
|
+
)
|
|
532
|
+
#endif
|
|
533
|
+
|
|
534
|
+
// Users Tab
|
|
535
|
+
let usersVC = CometChatUsers()
|
|
536
|
+
let usersNav = UINavigationController(rootViewController: usersVC)
|
|
537
|
+
usersVC.tabBarItem = UITabBarItem(
|
|
538
|
+
title: "USERS",
|
|
539
|
+
image: UIImage(systemName: "person.2.fill"),
|
|
540
|
+
tag: 2
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
usersVC.set(onItemClick: { [weak usersNav] user, indexPath in
|
|
544
|
+
let messagesVC = MessagesVC() // your own VC composing CometChatMessageHeader + List + Composer; see cometchat-ios-components § 12
|
|
545
|
+
messagesVC.set(user: user)
|
|
546
|
+
messagesVC.hidesBottomBarWhenPushed = true
|
|
547
|
+
usersNav?.pushViewController(messagesVC, animated: true)
|
|
548
|
+
})
|
|
549
|
+
|
|
550
|
+
// Groups Tab
|
|
551
|
+
let groupsVC = CometChatGroups()
|
|
552
|
+
let groupsNav = UINavigationController(rootViewController: groupsVC)
|
|
553
|
+
groupsVC.tabBarItem = UITabBarItem(
|
|
554
|
+
title: "GROUPS",
|
|
555
|
+
image: UIImage(systemName: "person.3.fill"),
|
|
556
|
+
tag: 3
|
|
557
|
+
)
|
|
558
|
+
|
|
559
|
+
groupsVC.set(onItemClick: { [weak groupsNav] group, indexPath in
|
|
560
|
+
let messagesVC = MessagesVC() // your own VC composing CometChatMessageHeader + List + Composer; see cometchat-ios-components § 12
|
|
561
|
+
messagesVC.set(group: group)
|
|
562
|
+
messagesVC.hidesBottomBarWhenPushed = true
|
|
563
|
+
groupsNav?.pushViewController(messagesVC, animated: true)
|
|
564
|
+
})
|
|
565
|
+
|
|
566
|
+
#if canImport(CometChatCallsSDK)
|
|
567
|
+
tabBarController.viewControllers = [conversationsNav, callLogsNav, usersNav, groupsNav]
|
|
568
|
+
#else
|
|
569
|
+
tabBarController.viewControllers = [conversationsNav, usersNav, groupsNav]
|
|
570
|
+
#endif
|
|
571
|
+
|
|
572
|
+
window = UIWindow(windowScene: windowScene)
|
|
573
|
+
window?.rootViewController = tabBarController
|
|
574
|
+
window?.makeKeyAndVisible()
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
## 15. Shared UI Components
|
|
582
|
+
|
|
583
|
+
### CometChatAvatar
|
|
584
|
+
```swift
|
|
585
|
+
let avatar = CometChatAvatar()
|
|
586
|
+
avatar.setAvatar(avatarUrl: user.avatar ?? "", with: user.name)
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### CometChatBadge
|
|
590
|
+
```swift
|
|
591
|
+
let badge = CometChatBadge()
|
|
592
|
+
badge.set(count: 5)
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### CometChatStatusIndicator
|
|
596
|
+
```swift
|
|
597
|
+
let statusIndicator = CometChatStatusIndicator()
|
|
598
|
+
statusIndicator.set(status: .online)
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
## 16. AI Components
|
|
604
|
+
|
|
605
|
+
### CometChatAIConversationStarter
|
|
606
|
+
Displays AI-suggested conversation starters.
|
|
607
|
+
|
|
608
|
+
### CometChatAISmartReply
|
|
609
|
+
Displays AI-suggested quick replies.
|
|
610
|
+
|
|
611
|
+
### CometChatAIConversationSummary
|
|
612
|
+
Displays AI-generated conversation summary.
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## 17. Extensions
|
|
617
|
+
|
|
618
|
+
### CometChatPollsBubble
|
|
619
|
+
Renders poll messages.
|
|
620
|
+
|
|
621
|
+
### CometChatStickerKeyboard
|
|
622
|
+
Sticker picker keyboard.
|
|
623
|
+
|
|
624
|
+
### CometChatLinkPreviewBubble
|
|
625
|
+
Renders URL link previews.
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## 18. SwiftUI Integration
|
|
630
|
+
|
|
631
|
+
Wrap UIKit components for SwiftUI:
|
|
632
|
+
|
|
633
|
+
```swift
|
|
634
|
+
import SwiftUI
|
|
635
|
+
import CometChatUIKitSwift
|
|
636
|
+
import CometChatSDK
|
|
637
|
+
|
|
638
|
+
struct ConversationsView: UIViewControllerRepresentable {
|
|
639
|
+
@Binding var selectedConversation: Conversation?
|
|
640
|
+
|
|
641
|
+
func makeUIViewController(context: Context) -> UINavigationController {
|
|
642
|
+
let conversationsVC = CometChatConversations()
|
|
643
|
+
conversationsVC.set(onItemClick: { conversation, _ in
|
|
644
|
+
selectedConversation = conversation
|
|
645
|
+
})
|
|
646
|
+
return UINavigationController(rootViewController: conversationsVC)
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {}
|
|
650
|
+
}
|
|
651
|
+
```
|