@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,726 @@
1
+ ---
2
+ name: cometchat-flutter-v6-troubleshooting
3
+ description: >
4
+ Diagnose and fix CometChat Flutter UIKit v6 integration problems. Covers init
5
+ failures, login errors, UI rendering issues, keyboard problems, call failures,
6
+ listener leaks, theme jank, and platform-specific build errors. Use when seeing
7
+ errors, crashes, or unexpected behavior with CometChat components.
8
+ license: "MIT"
9
+ compatibility: "cometchat_chat_uikit ^6.0.0-beta2"
10
+ allowed-tools: "executeBash, readFile, readCode, fileSearch, listDirectory, grepSearch"
11
+ metadata:
12
+ author: "CometChat"
13
+ version: "3.0.0"
14
+ tags: "cometchat flutter troubleshooting errors debugging crashes fixes"
15
+ ---
16
+
17
+ # CometChat Flutter UIKit v6 — Troubleshooting Guide
18
+
19
+ Comprehensive guide for diagnosing and fixing CometChat Flutter UIKit v6 integration problems.
20
+
21
+ ---
22
+
23
+ ## 1. Quick Diagnosis Flow
24
+
25
+ Use this decision tree to jump to the right section:
26
+
27
+ ```
28
+ What's happening?
29
+
30
+ ├─ App crashes or errors on startup
31
+ │ └─ Go to → Section 2: Init & Login Errors
32
+
33
+ ├─ UI looks wrong, layout broken, keyboard issues
34
+ │ └─ Go to → Section 3: UI Rendering Issues
35
+
36
+ ├─ Calls not working, call screen blank or stuck
37
+ │ └─ Go to → Section 4: Call Issues
38
+
39
+ ├─ Events not firing, duplicate events, memory leaks
40
+ │ └─ Go to → Section 5: Listener Issues
41
+
42
+ ├─ Build fails on Android or iOS
43
+ │ └─ Go to → Section 6: Build Errors
44
+
45
+ ├─ App is slow, janky scrolling, laggy keyboard
46
+ │ └─ Go to → Section 7: Performance Issues
47
+
48
+ └─ Platform-specific weirdness (Android/iOS/Web)
49
+ └─ Go to → Section 8: Platform-Specific Issues
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 2. Init & Login Errors
55
+
56
+ ### 2.1 "Authentication null"
57
+
58
+ - **Symptom**: Error message `Authentication null` or `Please log in to CometChat before calling this method` when using any CometChat component or SDK call.
59
+ - **Cause**: `CometChatUIKit.init()` was not called, or was called but not awaited before using components or calling login.
60
+ - **Fix**: Ensure `init()` completes before any other CometChat usage:
61
+
62
+ ```dart
63
+ // ✅ CORRECT — await init before anything else
64
+ final settings = (UIKitSettingsBuilder()
65
+ ..appId = 'APP_ID'
66
+ ..region = 'us'
67
+ ..authKey = 'AUTH_KEY'
68
+ ..subscriptionType = CometChatSubscriptionType.allUsers)
69
+ .build();
70
+
71
+ await CometChatUIKit.init(
72
+ uiKitSettings: settings,
73
+ onSuccess: (_) => debugPrint('Init done'),
74
+ onError: (e) => debugPrint('Init failed: ${e.message}'),
75
+ );
76
+
77
+ // ❌ WRONG — login before init completes (race condition)
78
+ CometChatUIKit.init(uiKitSettings: settings);
79
+ CometChatUIKit.login('uid');
80
+ ```
81
+
82
+ ### 2.2 "APP ID null"
83
+
84
+ - **Symptom**: Error `APP ID null` or `appId is required` during init.
85
+ - **Cause**: `appId` not set in `UIKitSettingsBuilder`.
86
+ - **Fix**: Set `appId` before calling `.build()`:
87
+
88
+ ```dart
89
+ final settings = (UIKitSettingsBuilder()
90
+ ..appId = 'YOUR_APP_ID' // ← Must be set
91
+ ..region = 'us'
92
+ ..authKey = 'YOUR_AUTH_KEY')
93
+ .build();
94
+ ```
95
+
96
+ ### 2.3 ERR_ALREADY_LOGGED_IN
97
+
98
+ - **Symptom**: Error `ERR_ALREADY_LOGGED_IN` when calling `CometChatUIKit.login()`.
99
+ - **Cause**: Calling login when a session already exists. After `init()`, the SDK restores cached sessions automatically.
100
+ - **Fix**: Check `CometChatUIKit.loggedInUser` after init before calling login:
101
+
102
+ ```dart
103
+ CometChatUIKit.init(
104
+ uiKitSettings: settings,
105
+ onSuccess: (_) {
106
+ if (CometChatUIKit.loggedInUser != null) {
107
+ // Already logged in — skip login, go to home
108
+ navigateToHome();
109
+ } else {
110
+ // No session — show login screen
111
+ navigateToLogin();
112
+ }
113
+ },
114
+ );
115
+ ```
116
+
117
+ ### 2.4 "Android internal error" on login
118
+
119
+ - **Symptom**: Login fails with a vague `Android internal error` message.
120
+ - **Cause**: Multiple possible causes — incorrect auth key, UID doesn't exist in CometChat dashboard, beta SDK bug, or network issue.
121
+ - **Fix**:
122
+ 1. Verify credentials are correct in the CometChat dashboard
123
+ 2. Verify the UID exists in the dashboard
124
+ 3. Try calling `CometChat.login(uid, authKey)` directly to isolate UIKit vs SDK issue
125
+ 4. If using beta SDK, try the stable release
126
+ 5. Check network connectivity and firewall rules
127
+
128
+ ### 2.5 Guard screen stuck on spinner
129
+
130
+ - **Symptom**: App shows a loading spinner forever after init. The auth guard never resolves.
131
+ - **Cause**: Using the callback-based `CometChat.getLoggedInUser()` after init instead of the synchronous `CometChatUIKit.loggedInUser`. The callback API silently fails when no session exists — neither `onSuccess` nor `onError` fires.
132
+ - **Fix**: Use the synchronous check after init:
133
+
134
+ ```dart
135
+ // ✅ CORRECT — synchronous check, always resolves
136
+ CometChatUIKit.init(
137
+ uiKitSettings: settings,
138
+ onSuccess: (_) {
139
+ final hasUser = CometChatUIKit.loggedInUser != null;
140
+ setState(() {
141
+ _loggedIn = hasUser;
142
+ _initializing = false;
143
+ });
144
+ },
145
+ );
146
+
147
+ // ❌ WRONG — callback may never fire when no session exists
148
+ CometChatUIKit.init(
149
+ uiKitSettings: settings,
150
+ onSuccess: (_) {
151
+ CometChat.getLoggedInUser(
152
+ onSuccess: (user) { /* may never fire */ },
153
+ onError: (e) { /* may never fire */ },
154
+ );
155
+ },
156
+ );
157
+
158
+ // ❌ ALSO WRONG — redundant native bridge round-trip
159
+ CometChatUIKit.init(
160
+ uiKitSettings: settings,
161
+ onSuccess: (_) async {
162
+ final user = await CometChatUIKit.getLoggedInUser(); // Unnecessary!
163
+ },
164
+ );
165
+ ```
166
+
167
+ ### 2.6 Region error (ERR_INVALID_REGION)
168
+
169
+ - **Symptom**: Init fails with `ERR_INVALID_REGION`.
170
+ - **Cause**: Region string is uppercase or not one of the valid values.
171
+ - **Fix**: Use lowercase region string — valid values are `'us'`, `'eu'`, `'in'`:
172
+
173
+ ```dart
174
+ // ✅ CORRECT
175
+ ..region = 'us'
176
+
177
+ // ❌ WRONG
178
+ ..region = 'US'
179
+ ..region = 'United States'
180
+ ```
181
+
182
+ ### 2.7 StateError from uninitialized ServiceLocator
183
+
184
+ - **Symptom**: `StateError: not initialized` when creating a BLoC manually.
185
+ - **Cause**: Component's `ServiceLocator.instance.setup()` was not called before creating the BLoC. UIKit widgets do this automatically, but manual BLoC creation requires it.
186
+ - **Fix**: Call setup before creating the BLoC:
187
+
188
+ ```dart
189
+ // ✅ CORRECT
190
+ ConversationsServiceLocator.instance.setup();
191
+ final bloc = ConversationsBloc(
192
+ getLoggedInUserUseCase: ConversationsServiceLocator.instance.getLoggedInUserUseCase,
193
+ );
194
+
195
+ // ❌ WRONG — setup not called
196
+ final bloc = ConversationsBloc(
197
+ getLoggedInUserUseCase: ConversationsServiceLocator.instance.getLoggedInUserUseCase,
198
+ );
199
+ ```
200
+
201
+ ---
202
+
203
+ ## 3. UI Rendering Issues
204
+
205
+ ### 3.1 Double keyboard compensation (layout jumps)
206
+
207
+ - **Symptom**: When the keyboard opens, the message list jumps or there's extra white space. Content shifts twice — once from Flutter's Scaffold resize, once from the composer's internal keyboard handling.
208
+ - **Cause**: The `Scaffold` containing `CometChatMessageComposer` has `resizeToAvoidBottomInset` set to `true` (the default). The composer handles keyboard spacing internally via `SliverSpacing`. Both systems react to the keyboard, causing double-compensation.
209
+ - **Fix**: Set `resizeToAvoidBottomInset: false` on any Scaffold containing the composer:
210
+
211
+ ```dart
212
+ // ✅ CORRECT
213
+ Scaffold(
214
+ resizeToAvoidBottomInset: false, // REQUIRED
215
+ body: Column(
216
+ children: [
217
+ Expanded(child: CometChatMessageList(user: user)),
218
+ CometChatMessageComposer(user: user),
219
+ ],
220
+ ),
221
+ )
222
+
223
+ // ❌ WRONG — default is true, causes double keyboard compensation
224
+ Scaffold(
225
+ body: Column(
226
+ children: [
227
+ Expanded(child: CometChatMessageList(user: user)),
228
+ CometChatMessageComposer(user: user),
229
+ ],
230
+ ),
231
+ )
232
+ ```
233
+
234
+ This applies everywhere the composer is used: messages screen, thread screen, or any custom screen.
235
+
236
+ ### 3.2 Stale user/group data
237
+
238
+ - **Symptom**: User name, avatar, or group info doesn't update in real-time. Old data persists even after changes.
239
+ - **Cause**: Passing `widget.user` or `widget.group` directly to UIKit components instead of maintaining mutable state that updates from listeners.
240
+ - **Fix**: Keep mutable `_user`/`_group` in your State class and update from SDK listeners:
241
+
242
+ ```dart
243
+ class _MessagesScreenState extends State<MessagesScreen> {
244
+ late User? _user;
245
+ late Group? _group;
246
+
247
+ @override
248
+ void initState() {
249
+ super.initState();
250
+ _user = widget.user;
251
+ _group = widget.group;
252
+ // Register listeners to update _user/_group on changes
253
+ }
254
+
255
+ @override
256
+ Widget build(BuildContext context) {
257
+ return Scaffold(
258
+ resizeToAvoidBottomInset: false,
259
+ body: Column(
260
+ children: [
261
+ Expanded(child: CometChatMessageList(user: _user, group: _group)),
262
+ CometChatMessageComposer(user: _user, group: _group),
263
+ ],
264
+ ),
265
+ );
266
+ }
267
+ }
268
+ ```
269
+
270
+ ### 3.3 No typing indicators / presence events
271
+
272
+ - **Symptom**: Online/offline status never updates. Typing indicators don't appear. No presence events fire. No error is thrown.
273
+ - **Cause**: `subscriptionType` was not set in `UIKitSettingsBuilder`. Omitting it silently disables all presence events.
274
+ - **Fix**: Always set `subscriptionType`:
275
+
276
+ ```dart
277
+ // ✅ CORRECT
278
+ UIKitSettingsBuilder()
279
+ ..appId = 'APP_ID'
280
+ ..region = 'us'
281
+ ..authKey = 'AUTH_KEY'
282
+ ..subscriptionType = CometChatSubscriptionType.allUsers
283
+
284
+ // ❌ WRONG — no error, but presence events never fire
285
+ UIKitSettingsBuilder()
286
+ ..appId = 'APP_ID'
287
+ ..region = 'us'
288
+ ..authKey = 'AUTH_KEY'
289
+ // subscriptionType missing!
290
+ ```
291
+
292
+ ### 3.4 Messages not updating in real-time
293
+
294
+ - **Symptom**: New messages don't appear until the screen is refreshed or re-opened.
295
+ - **Cause**: Multiple possible causes:
296
+ 1. SDK message listener not registered (BLoC handles this automatically — check component is mounted)
297
+ 2. `subscriptionType` not set (see 3.3)
298
+ 3. Component was disposed and listener removed
299
+ - **Fix**:
300
+ 1. Ensure `subscriptionType` is set in UIKitSettings
301
+ 2. Verify the `CometChatMessageList` widget is mounted and not disposed
302
+ 3. If using custom BLoC, ensure it registers `CometChat.addMessageListener()` in its constructor and removes it in `close()`
303
+
304
+ ### 3.5 Theme jank during keyboard animation
305
+
306
+ - **Symptom**: Visible jank (stuttering, dropped frames) when the keyboard opens or closes, especially on message screens.
307
+ - **Cause**: Theme values (`CometChatThemeHelper.getColorPalette(context)`, etc.) are being looked up inside `build()`. During keyboard animation, `MediaQuery` changes trigger rebuilds, and each lookup does expensive InheritedWidget traversal (44–95ms instead of <16ms).
308
+ - **Fix**: Cache theme values in `didChangeDependencies()` with a `_themeInitialized` flag:
309
+
310
+ ```dart
311
+ // ✅ CORRECT — cache once, reuse on every build
312
+ class _MyWidgetState extends State<MyWidget> {
313
+ late CometChatColorPalette _colorPalette;
314
+ late CometChatSpacing _spacing;
315
+ late CometChatTypography _typography;
316
+ bool _themeInitialized = false;
317
+
318
+ @override
319
+ void didChangeDependencies() {
320
+ super.didChangeDependencies();
321
+ if (!_themeInitialized) {
322
+ _colorPalette = CometChatThemeHelper.getColorPalette(context);
323
+ _spacing = CometChatThemeHelper.getSpacing(context);
324
+ _typography = CometChatThemeHelper.getTypography(context);
325
+ _themeInitialized = true;
326
+ }
327
+ }
328
+
329
+ @override
330
+ Widget build(BuildContext context) {
331
+ // Use _colorPalette, _spacing, _typography — no lookups here
332
+ return Container(color: _colorPalette.primary);
333
+ }
334
+ }
335
+
336
+ // ❌ WRONG — lookup in build causes jank during keyboard animation
337
+ @override
338
+ Widget build(BuildContext context) {
339
+ final colors = CometChatThemeHelper.getColorPalette(context); // Expensive!
340
+ return Container(color: colors.primary);
341
+ }
342
+ ```
343
+
344
+ ### 3.6 Extra white space between composer and keyboard
345
+
346
+ - **Symptom**: Visible gap between the message composer and the keyboard when it opens.
347
+ - **Cause**: Safe area bottom padding being applied when the keyboard is open. The keyboard already covers the safe area, so adding safe area padding on top creates extra space.
348
+ - **Fix**: Always use `MediaQuery.paddingOf(context).bottom` for safe area (set once in `didChangeDependencies()`). Never overwrite it with native plugin values. The `SliverSpacing` widget handles this automatically — ensure you're not adding extra `SafeArea` wrappers around the composer.
349
+
350
+ ---
351
+
352
+ ## 4. Call Issues
353
+
354
+ ### 4.1 "auth token null" on call init
355
+
356
+ - **Symptom**: Calls SDK fails with `auth token null` or similar authentication error when trying to start a call.
357
+ - **Cause**: The Calls SDK was initialized before the Chat SDK completed init and login. The Calls SDK needs the auth token from a successful chat login.
358
+ - **Fix**: Ensure `CometChatUIKit.init()` and login complete before any calls-related initialization. The UIKit handles this order internally — if you're initializing calls manually, ensure the chat session is established first.
359
+
360
+ ### 4.2 "session already started"
361
+
362
+ - **Symptom**: Error `session already started` when trying to join or start a call.
363
+ - **Cause**: A previous call session was not properly ended. This can happen if the user navigated away from the call screen without ending the call, or if the app was killed during a call.
364
+ - **Fix**: Ensure call sessions are properly ended when leaving call screens. If the error persists, call `CometChat.endCall()` or `CometChat.rejectCall()` to clean up the stale session before starting a new one.
365
+
366
+ ### 4.3 "CallManager not found" / "Calling module not found"
367
+
368
+ - **Symptom**: Android native error `CallManager not found` or `CometChat Calling module not found`.
369
+ - **Cause**: The CometChat Calling native module is not properly linked on Android. This can happen with ProGuard stripping, missing dependencies, or build configuration issues.
370
+ - **Fix**:
371
+ 1. Ensure ProGuard keep rules are in place (see Section 6.1)
372
+ 2. Verify `cometchat_chat_uikit` is properly added to `pubspec.yaml`
373
+ 3. Run `flutter clean` and rebuild
374
+ 4. Check that `android.enableJetifier=true` is in `gradle.properties`
375
+
376
+ ### 4.4 "startSession null" on Android
377
+
378
+ - **Symptom**: `startSession` returns null on Android with no error feedback. The call screen may appear blank or stuck.
379
+ - **Cause**: Known Android SDK issue where `startSession` silently fails. A 5-second timeout workaround exists but provides no error feedback.
380
+ - **Fix**: This is a known SDK-level issue. Workarounds:
381
+ 1. Implement a timeout wrapper around `startSession` calls
382
+ 2. Show a retry option to the user if the call screen doesn't load within 5 seconds
383
+ 3. Check for updates to `cometchat_calls_sdk` that may fix this
384
+
385
+ ### 4.5 Incoming call not received
386
+
387
+ - **Symptom**: Incoming calls are not shown to the receiver. The caller sees the outgoing call screen but the receiver gets nothing.
388
+ - **Cause**: Multiple possible causes:
389
+ 1. `subscriptionType` not set (presence/events disabled)
390
+ 2. Push notification / VoIP setup incomplete
391
+ 3. Call listeners not registered
392
+ 4. App is in background without proper background handling
393
+ - **Fix**:
394
+ 1. Ensure `subscriptionType` is set to `CometChatSubscriptionType.allUsers`
395
+ 2. Verify FCM/APNs push notification setup for background calls
396
+ 3. Check that call event listeners are registered
397
+ 4. For cross-platform issues (Android↔iOS↔React), verify all platforms are on compatible SDK versions
398
+
399
+ ### 4.6 Calls SDK not re-initialized after logout
400
+
401
+ - **Symptom**: After logout and re-login, calls don't work. Call screens may be blank or throw errors.
402
+ - **Cause**: The Calls SDK maintains its own session state. After `CometChatUIKit.logout()`, the Calls SDK session is invalidated but may not be properly re-initialized on the next login.
403
+ - **Fix**: Ensure the Calls SDK is re-initialized after login. The UIKit handles this internally — if you're managing calls manually, call the Calls SDK init after each successful login.
404
+
405
+ ---
406
+
407
+ ## 5. Listener Issues
408
+
409
+ ### 5.1 Duplicate events (hardcoded listener IDs)
410
+
411
+ - **Symptom**: Event handlers fire multiple times for a single event. Messages appear twice, typing indicators flicker.
412
+ - **Cause**: Listener registered with a hardcoded ID. When the widget is recreated (e.g., navigation), the new listener overwrites the old one but the old widget's handler may still be referenced, or multiple instances collide.
413
+ - **Fix**: Use a unique listener ID per widget instance:
414
+
415
+ ```dart
416
+ // ✅ CORRECT — unique ID per instance
417
+ class _MyScreenState extends State<MyScreen> with MessageListener {
418
+ late final String _listenerId;
419
+
420
+ @override
421
+ void initState() {
422
+ super.initState();
423
+ _listenerId = 'my_screen_${DateTime.now().millisecondsSinceEpoch}';
424
+ CometChat.addMessageListener(_listenerId, this);
425
+ }
426
+
427
+ @override
428
+ void dispose() {
429
+ CometChat.removeMessageListener(_listenerId);
430
+ super.dispose();
431
+ }
432
+ }
433
+
434
+ // ❌ WRONG — hardcoded ID causes collisions across instances
435
+ CometChat.addMessageListener('messages', this); // Collision!
436
+ ```
437
+
438
+ ### 5.2 Listener leaks (missing dispose)
439
+
440
+ - **Symptom**: Memory usage grows over time. Events fire on screens that are no longer visible. App becomes sluggish.
441
+ - **Cause**: SDK listeners registered in `initState()` but not removed in `dispose()`.
442
+ - **Fix**: Always remove listeners with the same ID used to register:
443
+
444
+ ```dart
445
+ @override
446
+ void dispose() {
447
+ CometChat.removeMessageListener(_listenerId);
448
+ CometChat.removeUserListener(_listenerId);
449
+ CometChat.removeGroupListener(_listenerId);
450
+ CometChat.removeCallListener(_listenerId);
451
+ super.dispose();
452
+ }
453
+ ```
454
+
455
+ ### 5.3 No events firing (subscriptionType not set)
456
+
457
+ - **Symptom**: All listeners are properly registered and removed, but no events ever fire. No errors in console.
458
+ - **Cause**: `subscriptionType` not set in `UIKitSettingsBuilder`. This silently disables all real-time events.
459
+ - **Fix**: Set `subscriptionType` during init:
460
+
461
+ ```dart
462
+ UIKitSettingsBuilder()
463
+ ..subscriptionType = CometChatSubscriptionType.allUsers
464
+ ```
465
+
466
+ ---
467
+
468
+ ## 6. Build Errors
469
+
470
+ ### 6.1 Android: ClassNotFoundException (missing ProGuard rules)
471
+
472
+ - **Symptom**: Release build crashes with `ClassNotFoundException` for CometChat classes. Debug builds work fine.
473
+ - **Cause**: R8/ProGuard strips CometChat SDK classes during release minification.
474
+ - **Fix**: Create `android/app/proguard-rules.pro` with:
475
+
476
+ ```
477
+ # CometChat — prevent R8 from stripping SDK classes
478
+ -keep class com.cometchat.** { *; }
479
+ -keep interface com.cometchat.** { *; }
480
+
481
+ # Suppress warnings for Calls SDK classes referenced cross-module
482
+ -dontwarn com.cometchat.calls.CometChatRTCView$CometChatRTCViewBuilder
483
+ -dontwarn com.cometchat.calls.CometChatRTCView
484
+ -dontwarn com.cometchat.calls.CometChatRTCViewListener
485
+ -dontwarn com.cometchat.calls.model.AnalyticsSettings
486
+ -dontwarn com.cometchat.calls.model.RTCCallback
487
+ -dontwarn com.cometchat.calls.model.RTCReceiver
488
+ ```
489
+
490
+ Reference it in `android/app/build.gradle`:
491
+
492
+ ```kotlin
493
+ buildTypes {
494
+ release {
495
+ isMinifyEnabled = true
496
+ isShrinkResources = true
497
+ proguardFiles(
498
+ getDefaultProguardFile("proguard-android-optimize.txt"),
499
+ "proguard-rules.pro"
500
+ )
501
+ }
502
+ }
503
+ ```
504
+
505
+ ### 6.2 Android: minSdk too low
506
+
507
+ - **Symptom**: Build fails with error about minimum SDK version. Error mentions `minSdkVersion` incompatibility.
508
+ - **Cause**: `minSdk` is set below 26. The `cometchat_calls_sdk` requires minSdk 26.
509
+ - **Fix**: In `android/app/build.gradle` (or `.kts`):
510
+
511
+ ```kotlin
512
+ defaultConfig {
513
+ minSdk = 26 // Required by cometchat_calls_sdk
514
+ }
515
+ ```
516
+
517
+ ### 6.3 Android: Jetifier missing
518
+
519
+ - **Symptom**: Build fails with errors about Android Support Library classes not found, or `androidx` conflicts.
520
+ - **Cause**: `android.enableJetifier=true` not set. Transitive dependencies from the CometChat SDK use old Android Support Library references.
521
+ - **Fix**: In `android/gradle.properties`:
522
+
523
+ ```properties
524
+ android.useAndroidX=true
525
+ android.enableJetifier=true
526
+ ```
527
+
528
+ ### 6.4 iOS: pod install failures
529
+
530
+ - **Symptom**: `pod install` fails with dependency resolution errors, version conflicts, or missing pods.
531
+ - **Cause**: Cocoapods cache is stale, or the Podfile needs updating.
532
+ - **Fix**:
533
+
534
+ ```bash
535
+ cd ios
536
+ rm -rf Pods Podfile.lock
537
+ pod repo update
538
+ pod install --repo-update
539
+ cd ..
540
+ flutter clean
541
+ flutter pub get
542
+ ```
543
+
544
+ If still failing, check that the iOS deployment target in `ios/Podfile` is high enough:
545
+
546
+ ```ruby
547
+ platform :ios, '13.0' # Minimum for CometChat
548
+ ```
549
+
550
+ ### 6.5 iOS: missing permissions
551
+
552
+ - **Symptom**: App crashes or shows blank screen when trying to access camera, microphone, or photo library on iOS.
553
+ - **Cause**: Required permission descriptions missing from `Info.plist`.
554
+ - **Fix**: Add to `ios/Runner/Info.plist`:
555
+
556
+ ```xml
557
+ <key>NSCameraUsageDescription</key>
558
+ <string>Camera access is needed for video calls and sending photos</string>
559
+ <key>NSMicrophoneUsageDescription</key>
560
+ <string>Microphone access is needed for voice and video calls</string>
561
+ <key>NSPhotoLibraryUsageDescription</key>
562
+ <string>Photo library access is needed for sending images</string>
563
+ ```
564
+
565
+ For VoIP calls, also add:
566
+
567
+ ```xml
568
+ <key>UIBackgroundModes</key>
569
+ <array>
570
+ <string>voip</string>
571
+ <string>remote-notification</string>
572
+ </array>
573
+ ```
574
+
575
+ ---
576
+
577
+ ## 7. Performance Issues
578
+
579
+ ### 7.1 Theme lookup in build() causing jank
580
+
581
+ - **Symptom**: Dropped frames during scrolling or keyboard animation. Flutter DevTools shows long build times (44–95ms).
582
+ - **Cause**: `CometChatThemeHelper.getColorPalette(context)` and similar calls in `build()` do expensive InheritedWidget traversal on every rebuild.
583
+ - **Fix**: Cache theme values in `didChangeDependencies()` — see Section 3.5 for the full pattern. For child widgets, pass pre-cached theme values from the parent:
584
+
585
+ ```dart
586
+ // Parent passes cached values to children
587
+ CometChatImageBubble(
588
+ imageUrl: message.attachment?.fileUrl,
589
+ colorPalette: _colorPalette, // Pre-cached from parent
590
+ spacing: _spacing, // Pre-cached from parent
591
+ );
592
+ ```
593
+
594
+ ### 7.2 Missing buildWhen optimization
595
+
596
+ - **Symptom**: Entire widget tree rebuilds on every BLoC state change, even when only a small part of the state changed.
597
+ - **Cause**: `BlocConsumer` or `BlocBuilder` without `buildWhen` — rebuilds on every state emission.
598
+ - **Fix**: Add `buildWhen` to limit rebuilds to relevant state changes:
599
+
600
+ ```dart
601
+ BlocConsumer<MessageComposerBloc, MessageComposerState>(
602
+ buildWhen: (previous, current) =>
603
+ previous.isEditMode != current.isEditMode ||
604
+ previous.isReplyMode != current.isReplyMode ||
605
+ previous.isRecordingMode != current.isRecordingMode ||
606
+ previous.editMessage != current.editMessage ||
607
+ previous.replyMessage != current.replyMessage,
608
+ listener: (context, state) { /* still receives ALL state changes */ },
609
+ builder: (context, state) { /* only rebuilds when buildWhen is true */ },
610
+ )
611
+ ```
612
+
613
+ ### 7.3 O(n) lookups instead of O(1)
614
+
615
+ - **Symptom**: Slow scrolling in long message lists. `findChildIndexCallback` takes too long.
616
+ - **Cause**: Using `list.indexWhere()` (O(n)) to find messages instead of a Map-based O(1) lookup.
617
+ - **Fix**: Maintain a `Map<int, int>` alongside the message list for O(1) index lookups:
618
+
619
+ ```dart
620
+ // In BLoC — maintain O(1) lookup map
621
+ final Map<int, int> _messageIndexMap = {};
622
+
623
+ int? findMessageIndex(int messageId) => _messageIndexMap[messageId];
624
+
625
+ // In SliverAnimatedList
626
+ SliverAnimatedList(
627
+ findChildIndexCallback: (Key key) {
628
+ if (key is ValueKey<int>) {
629
+ final index = widget.findMessageIndex?.call(key.value) ??
630
+ _messages.indexWhere((m) => m.id == key.value);
631
+ if (index != -1) return visualPosition(index);
632
+ }
633
+ return null;
634
+ },
635
+ )
636
+ ```
637
+
638
+ ---
639
+
640
+ ## 8. Platform-Specific Issues
641
+
642
+ ### 8.1 Android-specific
643
+
644
+ | Symptom | Cause | Fix |
645
+ |---------|-------|-----|
646
+ | Release crash `ClassNotFoundException` | Missing ProGuard rules | Add `-keep class com.cometchat.** { *; }` — see Section 6.1 |
647
+ | Build fail `minSdk` | minSdk < 26 | Set `minSdk = 26` in `build.gradle` |
648
+ | Build fail support library | Missing Jetifier | Add `android.enableJetifier=true` to `gradle.properties` |
649
+ | `startSession` returns null | Known Calls SDK issue | Implement timeout + retry — see Section 4.4 |
650
+ | `CallManager not found` | Native module not linked | Clean build + verify ProGuard + Jetifier — see Section 4.3 |
651
+ | Audio recording stuck after permission | Permission callback race | Ensure permission is granted before starting recording; handle the permission result callback properly |
652
+
653
+ ### 8.2 iOS-specific
654
+
655
+ | Symptom | Cause | Fix |
656
+ |---------|-------|-----|
657
+ | Pod install fails | Stale cache or version conflict | `rm -rf Pods Podfile.lock && pod install --repo-update` |
658
+ | Camera/mic crash | Missing `Info.plist` permissions | Add `NSCameraUsageDescription`, `NSMicrophoneUsageDescription` — see Section 6.5 |
659
+ | Media not sending | File access or permission issue | Verify `NSPhotoLibraryUsageDescription` in Info.plist; check file picker permissions |
660
+ | App crash on iPhone 11 | Device-specific compatibility | Check iOS deployment target ≥ 13.0; verify no 32-bit dependencies |
661
+ | VoIP calls not received in background | Missing background modes | Add `voip` and `remote-notification` to `UIBackgroundModes` in Info.plist |
662
+
663
+ ### 8.3 Web-specific
664
+
665
+ | Symptom | Cause | Fix |
666
+ |---------|-------|-----|
667
+ | Runtime error on web | Platform-specific code without `kIsWeb` guard | Wrap platform-specific code with `if (!kIsWeb)` checks |
668
+ | Native plugins crash on web | Plugin not available on web | Use conditional imports or `kIsWeb` guards before calling native APIs |
669
+ | CORS errors | API calls blocked by browser | Ensure CometChat API endpoints are accessible; check proxy configuration |
670
+
671
+ ```dart
672
+ // ✅ CORRECT — guard platform-specific code
673
+ import 'package:flutter/foundation.dart' show kIsWeb;
674
+
675
+ if (!kIsWeb) {
676
+ // Native-only code (e.g., push notifications, file system access)
677
+ setupPushNotifications();
678
+ }
679
+
680
+ // For conditional imports:
681
+ // lib/platform/native_service.dart — native implementation
682
+ // lib/platform/web_service.dart — web implementation
683
+ ```
684
+
685
+ ---
686
+
687
+ ## Quick Reference: Error → Fix Table
688
+
689
+ | Error / Symptom | Section | One-Line Fix |
690
+ |----------------|---------|-------------|
691
+ | "Authentication null" | 2.1 | Call `CometChatUIKit.init()` before any usage |
692
+ | "APP ID null" | 2.2 | Set `..appId = 'YOUR_APP_ID'` in UIKitSettingsBuilder |
693
+ | ERR_ALREADY_LOGGED_IN | 2.3 | Check `CometChatUIKit.loggedInUser` before calling login |
694
+ | "Android internal error" | 2.4 | Verify credentials, UID existence, try stable SDK |
695
+ | Guard screen stuck on spinner | 2.5 | Use `CometChatUIKit.loggedInUser` synchronously after init |
696
+ | ERR_INVALID_REGION | 2.6 | Use lowercase: `'us'`, `'eu'`, `'in'` |
697
+ | StateError: not initialized | 2.7 | Call `ServiceLocator.instance.setup()` before creating BLoC |
698
+ | Double keyboard compensation | 3.1 | Set `resizeToAvoidBottomInset: false` on Scaffold |
699
+ | No typing indicators / presence | 3.3 | Set `..subscriptionType = CometChatSubscriptionType.allUsers` |
700
+ | Theme jank during keyboard | 3.5 | Cache theme in `didChangeDependencies()`, not `build()` |
701
+ | Duplicate events | 5.1 | Use unique listener ID per widget instance |
702
+ | Listener leak | 5.2 | Remove listener in `dispose()` with same ID |
703
+ | ClassNotFoundException (release) | 6.1 | Add ProGuard keep rules for `com.cometchat.**` |
704
+ | minSdk too low | 6.2 | Set `minSdk = 26` |
705
+ | Jetifier missing | 6.3 | Add `android.enableJetifier=true` |
706
+ | Pod install failure | 6.4 | Delete Pods + Podfile.lock, `pod install --repo-update` |
707
+ | Missing iOS permissions | 6.5 | Add camera/mic/photo descriptions to Info.plist |
708
+
709
+ ---
710
+
711
+ ## Checklist — Every CometChat Integration
712
+
713
+ Use this checklist to verify your integration is correct:
714
+
715
+ - [ ] `CometChatUIKit.init()` called and awaited before any usage
716
+ - [ ] Auth check uses `CometChatUIKit.loggedInUser` after init (not `CometChat.getLoggedInUser()`)
717
+ - [ ] `subscriptionType` set in UIKitSettingsBuilder
718
+ - [ ] `region` is lowercase (`'us'`, `'eu'`, `'in'`)
719
+ - [ ] Scaffold has `resizeToAvoidBottomInset: false` if composer is present
720
+ - [ ] Theme cached in `didChangeDependencies()`, not `build()`
721
+ - [ ] SDK listeners registered with unique ID, removed in `dispose()`
722
+ - [ ] Colors from `CometChatThemeHelper`, never hardcoded
723
+ - [ ] Strings from `Translations.of(context)`, never hardcoded
724
+ - [ ] Android: minSdk ≥ 26, Jetifier enabled, ProGuard rules added
725
+ - [ ] iOS: permissions in Info.plist, deployment target ≥ 13.0
726
+ - [ ] Web: `kIsWeb` guards on platform-specific code