@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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -17
  3. package/bin/install.js +389 -43
  4. package/package.json +19 -9
  5. package/skills/cometchat/SKILL.md +1066 -265
  6. package/skills/cometchat-android-v5/SKILL.md +120 -0
  7. package/skills/cometchat-android-v5-components/SKILL.md +430 -0
  8. package/skills/cometchat-android-v5-core/SKILL.md +468 -0
  9. package/skills/cometchat-android-v5-customization/SKILL.md +305 -0
  10. package/skills/cometchat-android-v5-extensions/SKILL.md +124 -0
  11. package/skills/cometchat-android-v5-features/SKILL.md +130 -0
  12. package/skills/cometchat-android-v5-placement/SKILL.md +276 -0
  13. package/skills/cometchat-android-v5-production/SKILL.md +94 -0
  14. package/skills/cometchat-android-v5-push/SKILL.md +620 -0
  15. package/skills/cometchat-android-v5-testing/SKILL.md +187 -0
  16. package/skills/cometchat-android-v5-theming/SKILL.md +166 -0
  17. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +73 -0
  18. package/skills/cometchat-android-v6/SKILL.md +107 -0
  19. package/skills/cometchat-android-v6-builder-settings/SKILL.md +145 -0
  20. package/skills/cometchat-android-v6-compose-components/SKILL.md +202 -0
  21. package/skills/cometchat-android-v6-compose-customization/SKILL.md +280 -0
  22. package/skills/cometchat-android-v6-compose-placement/SKILL.md +213 -0
  23. package/skills/cometchat-android-v6-compose-theming/SKILL.md +224 -0
  24. package/skills/cometchat-android-v6-core/SKILL.md +354 -0
  25. package/skills/cometchat-android-v6-events/SKILL.md +212 -0
  26. package/skills/cometchat-android-v6-extensions/SKILL.md +191 -0
  27. package/skills/cometchat-android-v6-features/SKILL.md +130 -0
  28. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +197 -0
  29. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +268 -0
  30. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +248 -0
  31. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +202 -0
  32. package/skills/cometchat-android-v6-production/SKILL.md +187 -0
  33. package/skills/cometchat-android-v6-push/SKILL.md +274 -0
  34. package/skills/cometchat-android-v6-testing/SKILL.md +279 -0
  35. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +249 -0
  36. package/skills/cometchat-angular-components/SKILL.md +706 -0
  37. package/skills/cometchat-angular-core/SKILL.md +444 -0
  38. package/skills/cometchat-angular-customization/SKILL.md +424 -0
  39. package/skills/cometchat-angular-features/SKILL.md +447 -0
  40. package/skills/cometchat-angular-patterns/SKILL.md +447 -0
  41. package/skills/cometchat-angular-placement/SKILL.md +685 -0
  42. package/skills/cometchat-angular-production/SKILL.md +415 -0
  43. package/skills/cometchat-angular-theming/SKILL.md +365 -0
  44. package/skills/cometchat-angular-troubleshooting/SKILL.md +329 -0
  45. package/skills/cometchat-astro-patterns/SKILL.md +3 -3
  46. package/skills/cometchat-components/SKILL.md +11 -0
  47. package/skills/cometchat-core/SKILL.md +11 -6
  48. package/skills/cometchat-customization/references/component-catalog.md +1 -1
  49. package/skills/cometchat-features/SKILL.md +176 -108
  50. package/skills/cometchat-flutter-v5/SKILL.md +167 -0
  51. package/skills/cometchat-flutter-v5-calls/SKILL.md +192 -0
  52. package/skills/cometchat-flutter-v5-conversations/SKILL.md +117 -0
  53. package/skills/cometchat-flutter-v5-core/SKILL.md +221 -0
  54. package/skills/cometchat-flutter-v5-customization/SKILL.md +227 -0
  55. package/skills/cometchat-flutter-v5-events/SKILL.md +155 -0
  56. package/skills/cometchat-flutter-v5-messages/SKILL.md +258 -0
  57. package/skills/cometchat-flutter-v5-production/SKILL.md +207 -0
  58. package/skills/cometchat-flutter-v5-push/SKILL.md +284 -0
  59. package/skills/cometchat-flutter-v5-theming/SKILL.md +160 -0
  60. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +129 -0
  61. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +151 -0
  62. package/skills/cometchat-flutter-v6/SKILL.md +445 -0
  63. package/skills/cometchat-flutter-v6-calls/SKILL.md +333 -0
  64. package/skills/cometchat-flutter-v6-components/SKILL.md +365 -0
  65. package/skills/cometchat-flutter-v6-conversations/SKILL.md +210 -0
  66. package/skills/cometchat-flutter-v6-core/SKILL.md +305 -0
  67. package/skills/cometchat-flutter-v6-customization/SKILL.md +666 -0
  68. package/skills/cometchat-flutter-v6-events/SKILL.md +216 -0
  69. package/skills/cometchat-flutter-v6-features/SKILL.md +406 -0
  70. package/skills/cometchat-flutter-v6-messages/SKILL.md +333 -0
  71. package/skills/cometchat-flutter-v6-migration/SKILL.md +381 -0
  72. package/skills/cometchat-flutter-v6-placement/SKILL.md +398 -0
  73. package/skills/cometchat-flutter-v6-production/SKILL.md +632 -0
  74. package/skills/cometchat-flutter-v6-theming/SKILL.md +260 -0
  75. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +726 -0
  76. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +216 -0
  77. package/skills/cometchat-ios/SKILL.md +323 -0
  78. package/skills/cometchat-ios-components/SKILL.md +651 -0
  79. package/skills/cometchat-ios-core/SKILL.md +822 -0
  80. package/skills/cometchat-ios-customization/SKILL.md +825 -0
  81. package/skills/cometchat-ios-features/SKILL.md +725 -0
  82. package/skills/cometchat-ios-placement/SKILL.md +750 -0
  83. package/skills/cometchat-ios-production/SKILL.md +730 -0
  84. package/skills/cometchat-ios-push/SKILL.md +582 -0
  85. package/skills/cometchat-ios-theming/SKILL.md +631 -0
  86. package/skills/cometchat-ios-troubleshooting/SKILL.md +983 -0
  87. package/skills/cometchat-native-bare-patterns/SKILL.md +470 -0
  88. package/skills/cometchat-native-components/SKILL.md +594 -0
  89. package/skills/cometchat-native-core/SKILL.md +407 -0
  90. package/skills/cometchat-native-customization/SKILL.md +594 -0
  91. package/skills/cometchat-native-expo-patterns/SKILL.md +485 -0
  92. package/skills/cometchat-native-features/SKILL.md +608 -0
  93. package/skills/cometchat-native-placement/SKILL.md +500 -0
  94. package/skills/cometchat-native-production/SKILL.md +694 -0
  95. package/skills/cometchat-native-push/SKILL.md +593 -0
  96. package/skills/cometchat-native-testing/SKILL.md +583 -0
  97. package/skills/cometchat-native-theming/SKILL.md +656 -0
  98. package/skills/cometchat-native-troubleshooting/SKILL.md +433 -0
  99. package/skills/cometchat-nextjs-patterns/SKILL.md +5 -5
  100. package/skills/cometchat-production/SKILL.md +60 -0
  101. package/skills/cometchat-react-router-patterns/SKILL.md +23 -21
@@ -0,0 +1,468 @@
1
+ ---
2
+ name: cometchat-android-v5-core
3
+ description: "Foundational rules for CometChat Android UI Kit v5. Initialization, login, UIKitSettings builder, dependency setup, and anti-patterns. Read this first."
4
+ license: "MIT"
5
+ compatibility: "Android 7.0+; Java 8+; Kotlin 1.8+; com.cometchat:chat-uikit-android:5.x"
6
+ allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
7
+ metadata:
8
+ author: "CometChat"
9
+ version: "3.0.0"
10
+ tags: "chat cometchat android core rules initialization login builder patterns"
11
+ ---
12
+
13
+ > **Companion skills:** `cometchat-android-v5-components` provides the component
14
+ > catalog (what exists); `cometchat-android-v5-placement` covers where to put
15
+ > chat in your app; `cometchat-android-v5-theming` covers visual customization.
16
+
17
+ ## Purpose
18
+
19
+ This is the foundational skill for every CometChat Android UI Kit v5 integration. It teaches how CometChat works on Android — initialization, login, the UIKitSettings builder, Gradle dependency setup, manifest permissions, and the anti-patterns that silently break integrations.
20
+
21
+ **Read this skill first, before any component or placement skill.**
22
+
23
+ ---
24
+
25
+ ## Use this skill when
26
+
27
+ - Setting up CometChat in a new Android project
28
+ - Initializing the SDK (`CometChatUIKit.init`)
29
+ - Logging in / logging out users
30
+ - Configuring `UIKitSettings` via the builder
31
+ - Adding Gradle dependencies
32
+ - Debugging init or login failures
33
+ - "How do I set up CometChat?"
34
+ - "CometChat isn't initializing"
35
+
36
+ ## Do not use this skill when
37
+
38
+ - Customizing component appearance → use `cometchat-android-v5-theming`
39
+ - Adding a specific feature (calls, reactions) → use `cometchat-android-v5-features`
40
+ - Writing custom message templates → use `cometchat-android-v5-customization`
41
+ - Diagnosing runtime crashes → use `cometchat-android-v5-troubleshooting`
42
+
43
+ ---
44
+
45
+ ## 1. Gradle Dependencies
46
+
47
+ Add the CometChat UI Kit dependency to your app-level `build.gradle`:
48
+
49
+ ```groovy
50
+ dependencies {
51
+ implementation 'com.cometchat:chat-uikit-android:5.+'
52
+ }
53
+ ```
54
+
55
+ The UI Kit transitively pulls in the CometChat Chat SDK. For voice/video calling, add the calling SDK separately:
56
+
57
+ ```groovy
58
+ dependencies {
59
+ implementation 'com.cometchat:chat-uikit-android:5.+'
60
+ implementation 'com.cometchat:calls-sdk-android:4.+' // optional — only for calls
61
+ }
62
+ ```
63
+
64
+ Ensure your project-level `build.gradle` includes the CometChat Maven repository:
65
+
66
+ ```groovy
67
+ allprojects {
68
+ repositories {
69
+ google()
70
+ mavenCentral()
71
+ maven { url "https://dl.cloudsmith.io/public/cometchat/cometchat/maven/" }
72
+ }
73
+ }
74
+ ```
75
+
76
+ **Min SDK:** 24 (Android 7.0). **Compile SDK:** 34+. **Java:** 8+. **Kotlin:** 1.8+.
77
+
78
+ > **⚠️ Important:** Always use the published Maven artifact (`com.cometchat:chat-uikit-android:5.+`). Never use `implementation project(':chatuikit')` or other local module references — those are only for CometChat's own internal development. The Chat SDK (`com.cometchat:chat-sdk-android`) is transitively included by the UI Kit, so you do not need to add it separately.
79
+
80
+ ### 1a. AndroidX + Jetifier (REQUIRED — non-negotiable)
81
+
82
+ The CometChat Chat SDK transitively depends on the legacy `com.android.support:support-compat` library. Modern Android Studio projects (Arctic Fox+) default to `androidx.core` instead. Without Jetifier, Gradle sees the same classes (`android.support.v4.os.ResultReceiver`, etc.) declared in both libraries and fails the build with:
83
+
84
+ ```
85
+ Duplicate class android.support.v4.os.ResultReceiver$1 found in modules
86
+ core-1.16.0.aar -> core-1.16.0-runtime (androidx.core:core:1.16.0)
87
+ and support-compat-26.1.0.aar -> support-compat-26.1.0-runtime
88
+ (com.android.support:support-compat:26.1.0)
89
+ ```
90
+
91
+ **Add these two lines to `gradle.properties` at the project root** before any UI Kit code is wired in:
92
+
93
+ ```properties
94
+ android.useAndroidX=true
95
+ android.enableJetifier=true
96
+ ```
97
+
98
+ Both are **mandatory**. Jetifier rewrites the legacy `android.support.*` references in the CometChat SDK's transitive deps to their `androidx.*` equivalents at build time, so the duplicate-class error doesn't happen.
99
+
100
+ A freshly-created Android Studio project usually has `android.useAndroidX=true` already (Arctic Fox+) but **Jetifier is OFF by default** since it's deprecated in newer SDK landscapes. The CometChat V5 SDK still needs it. If `gradle.properties` doesn't have either line, append both. If it has `useAndroidX=true` but no Jetifier line, add the Jetifier line. Idempotent.
101
+
102
+ ---
103
+
104
+ ## 2. Initialization
105
+
106
+ CometChat must be initialized exactly once before any UI component is used. Initialization is asynchronous and must complete fully before mounting any `CometChat*` view.
107
+
108
+ ### The UIKitSettingsBuilder
109
+
110
+ **Java:**
111
+ ```java
112
+ import com.cometchat.chatuikit.shared.cometchatuikit.CometChatUIKit;
113
+ import com.cometchat.chatuikit.shared.cometchatuikit.UIKitSettings;
114
+
115
+ UIKitSettings uiKitSettings = new UIKitSettings.UIKitSettingsBuilder()
116
+ .setAppId(APP_ID) // Required. String from the CometChat dashboard.
117
+ .setRegion(REGION) // Required. "us", "eu", "in", etc.
118
+ .setAuthKey(AUTH_KEY) // Required for dev mode. Omit in production.
119
+ .subscribePresenceForAllUsers() // Optional — enables online/offline indicators.
120
+ .build();
121
+ ```
122
+
123
+ **Kotlin:**
124
+ ```kotlin
125
+ import com.cometchat.chatuikit.shared.cometchatuikit.CometChatUIKit
126
+ import com.cometchat.chatuikit.shared.cometchatuikit.UIKitSettings
127
+
128
+ val uiKitSettings = UIKitSettings.UIKitSettingsBuilder()
129
+ .setAppId(APP_ID)
130
+ .setRegion(REGION)
131
+ .setAuthKey(AUTH_KEY)
132
+ .subscribePresenceForAllUsers()
133
+ .build()
134
+ ```
135
+
136
+ ### UIKitSettingsBuilder — full method reference
137
+
138
+ | Method | Type | Description |
139
+ |---|---|---|
140
+ | `setAppId(String)` | Required | CometChat App ID from the dashboard |
141
+ | `setRegion(String)` | Required | Region: `"us"`, `"eu"`, `"in"` |
142
+ | `setAuthKey(String)` | Dev only | Auth Key for client-side login. Omit in production. |
143
+ | `subscribePresenceForAllUsers()` | Optional | Subscribe to presence for all users |
144
+ | `subscribePresenceForFriends()` | Optional | Subscribe to presence for friends only |
145
+ | `subscribePresenceForRoles(List<String>)` | Optional | Subscribe to presence for specific roles |
146
+ | `setAutoEstablishSocketConnection(Boolean)` | Optional | Auto-connect WebSocket. Default: `true` |
147
+ | `setAIFeatures(List<AIExtensionDataSource>)` | Optional | Custom AI features list. Default: built-in AI features |
148
+ | `setExtensions(List<ExtensionsDataSource>)` | Optional | Custom extensions list. Default: built-in extensions |
149
+ | `setDateTimeFormatterCallback(DateTimeFormatterCallback)` | Optional | Custom date/time formatting |
150
+ | `overrideAdminHost(String)` | Advanced | Override admin API host |
151
+ | `overrideClientHost(String)` | Advanced | Override client API host |
152
+
153
+ ### Init call
154
+
155
+ **Java:**
156
+ ```java
157
+ CometChatUIKit.init(context, uiKitSettings, new CometChat.CallbackListener<String>() {
158
+ @Override
159
+ public void onSuccess(String s) {
160
+ // SDK initialized — safe to login and use components
161
+ }
162
+
163
+ @Override
164
+ public void onError(CometChatException e) {
165
+ // Handle init failure
166
+ }
167
+ });
168
+ ```
169
+
170
+ **Kotlin:**
171
+ ```kotlin
172
+ CometChatUIKit.init(context, uiKitSettings, object : CometChat.CallbackListener<String>() {
173
+ override fun onSuccess(s: String) {
174
+ // SDK initialized — safe to login and use components
175
+ }
176
+
177
+ override fun onError(e: CometChatException) {
178
+ // Handle init failure
179
+ }
180
+ })
181
+ ```
182
+
183
+ ### Init must happen once
184
+
185
+ Call `CometChatUIKit.init()` in your `Application.onCreate()` or your launcher `Activity.onCreate()`. Use `CometChatUIKit.isSDKInitialized()` to guard against double-init:
186
+
187
+ **Java:**
188
+ ```java
189
+ if (!CometChatUIKit.isSDKInitialized()) {
190
+ CometChatUIKit.init(this, uiKitSettings, new CometChat.CallbackListener<String>() {
191
+ @Override
192
+ public void onSuccess(String s) {
193
+ // proceed to login
194
+ }
195
+
196
+ @Override
197
+ public void onError(CometChatException e) {
198
+ // show error
199
+ }
200
+ });
201
+ }
202
+ ```
203
+
204
+ ---
205
+
206
+ ## 3. Login
207
+
208
+ ### Development mode
209
+
210
+ Use `CometChatUIKit.login(uid, callback)` with a test UID. Every new CometChat app comes with five pre-created test users: `cometchat-uid-1` through `cometchat-uid-5`.
211
+
212
+ **Java:**
213
+ ```java
214
+ if (CometChatUIKit.getLoggedInUser() == null) {
215
+ CometChatUIKit.login("cometchat-uid-1", new CometChat.CallbackListener<User>() {
216
+ @Override
217
+ public void onSuccess(User user) {
218
+ // Navigate to chat screen
219
+ }
220
+
221
+ @Override
222
+ public void onError(CometChatException e) {
223
+ // Handle login failure
224
+ }
225
+ });
226
+ }
227
+ ```
228
+
229
+ **Kotlin:**
230
+ ```kotlin
231
+ if (CometChatUIKit.getLoggedInUser() == null) {
232
+ CometChatUIKit.login("cometchat-uid-1", object : CometChat.CallbackListener<User>() {
233
+ override fun onSuccess(user: User) {
234
+ // Navigate to chat screen
235
+ }
236
+
237
+ override fun onError(e: CometChatException) {
238
+ // Handle login failure
239
+ }
240
+ })
241
+ }
242
+ ```
243
+
244
+ ### Production mode
245
+
246
+ Use `CometChatUIKit.loginWithAuthToken(token, callback)` with a token obtained from your backend. The backend generates the token using the CometChat REST API with your REST API Key (not the client-side Auth Key).
247
+
248
+ **Java:**
249
+ ```java
250
+ CometChatUIKit.loginWithAuthToken(authToken, new CometChat.CallbackListener<User>() {
251
+ @Override
252
+ public void onSuccess(User user) {
253
+ // Navigate to chat screen
254
+ }
255
+
256
+ @Override
257
+ public void onError(CometChatException e) {
258
+ // Handle login failure
259
+ }
260
+ });
261
+ ```
262
+
263
+ ### Getting the current logged-in user
264
+
265
+ ```java
266
+ User currentUser = CometChatUIKit.getLoggedInUser();
267
+ if (currentUser != null) {
268
+ String uid = currentUser.getUid();
269
+ }
270
+ ```
271
+
272
+ ### Logout
273
+
274
+ **Java:**
275
+ ```java
276
+ CometChatUIKit.logout(new CometChat.CallbackListener<String>() {
277
+ @Override
278
+ public void onSuccess(String s) {
279
+ // Navigate to login screen
280
+ }
281
+
282
+ @Override
283
+ public void onError(CometChatException e) {
284
+ // Handle logout failure
285
+ }
286
+ });
287
+ ```
288
+
289
+ ### Create user (dev mode only)
290
+
291
+ ```java
292
+ User user = new User();
293
+ user.setUid("user-123");
294
+ user.setName("John Doe");
295
+
296
+ CometChatUIKit.createUser(user, new CometChat.CallbackListener<User>() {
297
+ @Override
298
+ public void onSuccess(User user) { }
299
+
300
+ @Override
301
+ public void onError(CometChatException e) { }
302
+ });
303
+ ```
304
+
305
+ ---
306
+
307
+ ## 4. CometChatUIKit — full public API
308
+
309
+ | Method | Signature | Description |
310
+ |---|---|---|
311
+ | `init` | `static void init(Context, UIKitSettings, CallbackListener<String>)` | Initialize the SDK |
312
+ | `login` | `static void login(String uid, CallbackListener<User>)` | Login with UID (dev mode) |
313
+ | `loginWithAuthToken` | `static void loginWithAuthToken(String token, CallbackListener<User>)` | Login with auth token (production) |
314
+ | `logout` | `static void logout(CallbackListener<String>)` | Logout current user |
315
+ | `getLoggedInUser` | `static User getLoggedInUser()` | Get current logged-in user (null if none) |
316
+ | `isSDKInitialized` | `static boolean isSDKInitialized()` | Check if SDK is initialized |
317
+ | `createUser` | `static void createUser(User, CallbackListener<User>)` | Create a new user (dev mode) |
318
+ | `sendTextMessage` | `static void sendTextMessage(TextMessage, CallbackListener<TextMessage>)` | Send a text message |
319
+ | `sendMediaMessage` | `static void sendMediaMessage(MediaMessage, CallbackListener<MediaMessage>)` | Send a media message |
320
+ | `sendCustomMessage` | `static void sendCustomMessage(CustomMessage, CallbackListener<CustomMessage>)` | Send a custom message |
321
+ | `sendFormMessage` | `static void sendFormMessage(FormMessage, boolean, CallbackListener<FormMessage>)` | Send a form message |
322
+ | `sendSchedulerMessage` | `static void sendSchedulerMessage(SchedulerMessage, boolean, CallbackListener<SchedulerMessage>)` | Send a scheduler message |
323
+
324
+ ---
325
+
326
+ ## 5. Manifest Permissions
327
+
328
+ Add these to your `AndroidManifest.xml`:
329
+
330
+ ```xml
331
+ <uses-permission android:name="android.permission.INTERNET" />
332
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
333
+
334
+ <!-- For media messages -->
335
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
336
+ android:maxSdkVersion="32" />
337
+ <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
338
+ <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
339
+ <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
340
+
341
+ <!-- For voice notes and calls -->
342
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
343
+ <uses-permission android:name="android.permission.CAMERA" />
344
+
345
+ <!-- For push notifications (Android 13+) -->
346
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
347
+ ```
348
+
349
+ ---
350
+
351
+ ## 5b. App Theme Requirement
352
+
353
+ CometChat UI Kit v5 ships its own theme (`CometChatTheme.DayNight`) which itself inherits from `Theme.MaterialComponents.DayNight.NoActionBar` (Material 2 — see the kit's own `chatuikit/src/main/res/values/themes.xml`). Your app's theme **must** inherit from `CometChatTheme.DayNight` so the kit's attribute set is in scope. Using `Theme.AppCompat.*` (which lacks Material attributes the kit relies on) leads to attribute-resolution failures at inflate time.
354
+
355
+ **Recommended — use CometChat's built-in theme as parent:**
356
+ ```xml
357
+ <!-- res/values/themes.xml -->
358
+ <style name="AppTheme" parent="CometChatTheme.DayNight">
359
+ <!-- Your customizations -->
360
+ <item name="colorPrimary">@color/your_brand_color</item>
361
+ </style>
362
+ ```
363
+
364
+ **Do NOT inherit from `Theme.AppCompat.*`** — it doesn't pull in the Material attributes the UI Kit reads at inflate time, and you'll see `UnsupportedOperationException: Failed to resolve attribute`. Inheriting directly from `Theme.MaterialComponents.*` works at runtime but you lose the kit's preconfigured color tokens — prefer `CometChatTheme.DayNight` so both the kit's defaults and your overrides apply cleanly.
365
+
366
+ > **Material 2 vs Material 3.** The kit currently parents on Material 2 (`Theme.MaterialComponents.DayNight.NoActionBar`). Do NOT switch to `Theme.Material3.*` as your app theme parent — the kit's resource attrs are resolved against the Material 2 namespace; mixing in Material 3 leaves some attributes undefined and triggers the same `UnsupportedOperationException` at inflate.
367
+
368
+ ---
369
+
370
+ ## 6. Typical init + login flow (complete example)
371
+
372
+ This is the pattern used in the sample apps. Place it in your launcher Activity:
373
+
374
+ **Java:**
375
+ ```java
376
+ public class SplashActivity extends AppCompatActivity {
377
+ @Override
378
+ protected void onCreate(Bundle savedInstanceState) {
379
+ super.onCreate(savedInstanceState);
380
+
381
+ UIKitSettings uiKitSettings = new UIKitSettings.UIKitSettingsBuilder()
382
+ .setAppId("YOUR_APP_ID")
383
+ .setRegion("us")
384
+ .setAuthKey("YOUR_AUTH_KEY")
385
+ .subscribePresenceForAllUsers()
386
+ .build();
387
+
388
+ CometChatUIKit.init(this, uiKitSettings, new CometChat.CallbackListener<String>() {
389
+ @Override
390
+ public void onSuccess(String s) {
391
+ if (CometChatUIKit.getLoggedInUser() != null) {
392
+ startActivity(new Intent(SplashActivity.this, HomeActivity.class));
393
+ finish();
394
+ } else {
395
+ startActivity(new Intent(SplashActivity.this, LoginActivity.class));
396
+ finish();
397
+ }
398
+ }
399
+
400
+ @Override
401
+ public void onError(CometChatException e) {
402
+ Toast.makeText(SplashActivity.this, "Init failed: " + e.getMessage(), Toast.LENGTH_LONG).show();
403
+ }
404
+ });
405
+ }
406
+ }
407
+ ```
408
+
409
+ **Kotlin:**
410
+ ```kotlin
411
+ class SplashActivity : AppCompatActivity() {
412
+ override fun onCreate(savedInstanceState: Bundle?) {
413
+ super.onCreate(savedInstanceState)
414
+
415
+ val uiKitSettings = UIKitSettings.UIKitSettingsBuilder()
416
+ .setAppId("YOUR_APP_ID")
417
+ .setRegion("us")
418
+ .setAuthKey("YOUR_AUTH_KEY")
419
+ .subscribePresenceForAllUsers()
420
+ .build()
421
+
422
+ CometChatUIKit.init(this, uiKitSettings, object : CometChat.CallbackListener<String>() {
423
+ override fun onSuccess(s: String) {
424
+ if (CometChatUIKit.getLoggedInUser() != null) {
425
+ startActivity(Intent(this@SplashActivity, HomeActivity::class.java))
426
+ } else {
427
+ startActivity(Intent(this@SplashActivity, LoginActivity::class.java))
428
+ }
429
+ finish()
430
+ }
431
+
432
+ override fun onError(e: CometChatException) {
433
+ Toast.makeText(this@SplashActivity, "Init failed: ${e.message}", Toast.LENGTH_LONG).show()
434
+ }
435
+ })
436
+ }
437
+ }
438
+ ```
439
+
440
+ ---
441
+
442
+ ## 7. Anti-patterns
443
+
444
+ | Anti-pattern | Why it breaks | Fix |
445
+ |---|---|---|
446
+ | Calling `login()` before `init()` completes | SDK not ready, login silently fails or throws | Always call `login()` inside `init()`'s `onSuccess` |
447
+ | Double `init()` calls | Wastes resources, can cause race conditions | Guard with `CometChatUIKit.isSDKInitialized()` |
448
+ | Hardcoding Auth Key in production | Anyone can decompile your APK and login as any user | Use `loginWithAuthToken()` with server-minted tokens |
449
+ | Using UI components before login | Components require a logged-in user to fetch data | Always verify `getLoggedInUser() != null` before showing chat UI |
450
+ | Missing INTERNET permission | SDK can't reach CometChat servers | Add `<uses-permission android:name="android.permission.INTERNET" />` |
451
+ | Wrong region string | SDK connects to wrong datacenter, gets 404s | Use exact region from dashboard: `"us"`, `"eu"`, `"in"` |
452
+ | Calling `init()` in every Activity | Redundant, wastes network calls | Call once in `Application.onCreate()` or launcher Activity |
453
+ | Using `Theme.AppCompat.*` or `Theme.Material3.*` as app theme | The kit's attrs are resolved against Material 2 (which `CometChatTheme.DayNight` inherits from); mixing namespaces fails with `UnsupportedOperationException` at inflate time | Inherit from `CometChatTheme.DayNight` |
454
+ | Using `implementation project(':chatuikit')` for the UI Kit dependency | Local module references only work inside CometChat's own monorepo; external apps can't resolve the module | Use `implementation 'com.cometchat:chat-uikit-android:5.+'` from the CometChat Maven repository |
455
+ | Forgetting `android.useAndroidX=true` + `android.enableJetifier=true` in `gradle.properties` | CometChat SDK's transitive `com.android.support` deps collide with the project's `androidx.core` → "Duplicate class android.support.v4.os.ResultReceiver$1" build failure | See § 1a — both lines mandatory in every greenfield Android Studio integration |
456
+
457
+ ---
458
+
459
+ ## Hard rules
460
+
461
+ - **Init once, login once.** `CometChatUIKit.init()` must be called exactly once before any UI component is used. `login()` must be called inside `init()`'s `onSuccess`.
462
+ - **Always check `getLoggedInUser()`.** Before navigating to any chat screen, verify the user is logged in.
463
+ - **Never hardcode Auth Key in production.** Use `loginWithAuthToken()` with server-side token generation.
464
+ - **INTERNET permission is mandatory.** Without it, the SDK silently fails.
465
+ - **All UI components require a logged-in user.** Mounting `CometChatConversations`, `CometChatMessageList`, etc. without a logged-in user results in empty views or crashes.
466
+ - **App theme must inherit from `CometChatTheme.DayNight`.** The kit itself parents on `Theme.MaterialComponents.DayNight.NoActionBar` (Material 2). Inheriting from `Theme.AppCompat.*` or `Theme.Material3.*` triggers `UnsupportedOperationException: Failed to resolve attribute` at inflate time.
467
+ - **Always use the published Maven artifact for dependencies, never local project modules.** Use `implementation 'com.cometchat:chat-uikit-android:5.+'` — never `implementation project(':chatuikit')`. Local module references only apply to CometChat's own internal sample apps. External apps must always depend on the published artifact from the CometChat Maven repository.
468
+ - **`gradle.properties` MUST contain `android.useAndroidX=true` AND `android.enableJetifier=true`.** Both lines, no exceptions. The CometChat V5 Android SDK transitively depends on the legacy `com.android.support:support-compat`. Without Jetifier rewriting those references to `androidx.*` at build time, Gradle hits "Duplicate class android.support.v4.os.ResultReceiver$1" and the build fails. Modern Android Studio scaffolds set `useAndroidX=true` by default but leave Jetifier off — the integration must add the Jetifier line. Idempotent — if both lines are already present, no change.