@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,632 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-flutter-v6-production
|
|
3
|
+
description: >
|
|
4
|
+
Production readiness for CometChat Flutter UIKit v6 — server-side auth tokens,
|
|
5
|
+
user management, Android ProGuard/R8, iOS Info.plist, minSdk, release build
|
|
6
|
+
checklist, environment configuration, and security hardening. Use when preparing
|
|
7
|
+
a CometChat Flutter app for production deployment.
|
|
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 production release auth-token proguard security"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# CometChat Flutter UIKit v6 — Production Readiness
|
|
18
|
+
|
|
19
|
+
Everything you need to move a CometChat Flutter app from development to production. Covers authentication, platform configuration, environment management, and security hardening.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 1. Dev Mode vs Production
|
|
24
|
+
|
|
25
|
+
CometChat supports two authentication modes. Understanding the difference is critical before shipping.
|
|
26
|
+
|
|
27
|
+
### Dev Mode (authKey — development only)
|
|
28
|
+
|
|
29
|
+
The `authKey` is embedded in client code and lets any user log in by UID alone. Convenient for prototyping, but **anyone who decompiles your app can impersonate any user**.
|
|
30
|
+
|
|
31
|
+
```dart
|
|
32
|
+
// ✅ Dev mode — fine for prototyping, NEVER ship this
|
|
33
|
+
final settings = (UIKitSettingsBuilder()
|
|
34
|
+
..appId = 'APP_ID'
|
|
35
|
+
..region = 'us'
|
|
36
|
+
..authKey = 'AUTH_KEY' // Client-side secret — dev only
|
|
37
|
+
..subscriptionType = CometChatSubscriptionType.allUsers)
|
|
38
|
+
.build();
|
|
39
|
+
|
|
40
|
+
await CometChatUIKit.init(uiKitSettings: settings);
|
|
41
|
+
|
|
42
|
+
// Login with authKey (SDK uses the key from UIKitSettings internally)
|
|
43
|
+
await CometChatUIKit.login('user_uid',
|
|
44
|
+
onSuccess: (user) => debugPrint('Logged in: ${user.name}'),
|
|
45
|
+
onError: (e) => debugPrint('Login failed: ${e.message}'),
|
|
46
|
+
);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Production Mode (authToken — server-minted)
|
|
50
|
+
|
|
51
|
+
Your backend generates a short-lived `authToken` for each authenticated user. The client never sees the `authKey`.
|
|
52
|
+
|
|
53
|
+
```dart
|
|
54
|
+
// ✅ Production — authKey is NOT in client code
|
|
55
|
+
final settings = (UIKitSettingsBuilder()
|
|
56
|
+
..appId = 'APP_ID'
|
|
57
|
+
..region = 'us'
|
|
58
|
+
// No authKey here — tokens come from your server
|
|
59
|
+
..subscriptionType = CometChatSubscriptionType.allUsers)
|
|
60
|
+
.build();
|
|
61
|
+
|
|
62
|
+
await CometChatUIKit.init(uiKitSettings: settings);
|
|
63
|
+
|
|
64
|
+
// Login with server-provided token
|
|
65
|
+
final authToken = await yourBackend.getCometChatToken(currentUserId);
|
|
66
|
+
await CometChatUIKit.loginWithAuthToken(authToken,
|
|
67
|
+
onSuccess: (user) => debugPrint('Logged in: ${user.name}'),
|
|
68
|
+
onError: (e) => debugPrint('Login failed: ${e.message}'),
|
|
69
|
+
);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Rule**: If `authKey` appears anywhere in your production build, you have a security vulnerability.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 2. Server-Side Auth Token Flow
|
|
77
|
+
|
|
78
|
+
### How It Works
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
┌──────────┐ 1. Authenticate ┌──────────────┐
|
|
82
|
+
│ Flutter │ ──────────────────────> │ Your Server │
|
|
83
|
+
│ App │ │ (Backend) │
|
|
84
|
+
│ │ 4. Return authToken │ │
|
|
85
|
+
│ │ <────────────────────── │ │
|
|
86
|
+
└──────────┘ └──────────────┘
|
|
87
|
+
│ │
|
|
88
|
+
│ 5. loginWithAuthToken(token) │ 2. Verify user identity
|
|
89
|
+
│ │ 3. POST /auth-tokens
|
|
90
|
+
v v
|
|
91
|
+
┌──────────┐ ┌──────────────┐
|
|
92
|
+
│ CometChat│ │ CometChat │
|
|
93
|
+
│ SDK │ │ REST API │
|
|
94
|
+
└──────────┘ └──────────────┘
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Step 1: Your Backend Generates the Token
|
|
98
|
+
|
|
99
|
+
Your server calls the CometChat REST API with the `authKey` (which stays server-side):
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
curl -X POST "https://API_REGION.cometchat.io/v3/users/USER_UID/auth_tokens" \
|
|
103
|
+
-H "appId: YOUR_APP_ID" \
|
|
104
|
+
-H "apiKey: YOUR_AUTH_KEY" \
|
|
105
|
+
-H "Content-Type: application/json"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Response:
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"data": {
|
|
112
|
+
"uid": "user_uid",
|
|
113
|
+
"authToken": "user_uid_1a2b3c4d5e6f7a8b9c0d1e2f",
|
|
114
|
+
"createdAt": 1700000000
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Replace `API_REGION` with your region endpoint:
|
|
120
|
+
- US: `api-us.cometchat.io`
|
|
121
|
+
- EU: `api-eu.cometchat.io`
|
|
122
|
+
- IN: `api-in.cometchat.io`
|
|
123
|
+
|
|
124
|
+
### Step 2: Your Backend Returns the Token to the Client
|
|
125
|
+
|
|
126
|
+
Your Flutter app calls your own backend (after the user authenticates with your auth system), and your backend returns the CometChat `authToken`.
|
|
127
|
+
|
|
128
|
+
### Step 3: Flutter Client Logs In with the Token
|
|
129
|
+
|
|
130
|
+
```dart
|
|
131
|
+
Future<void> loginWithToken(String uid) async {
|
|
132
|
+
// 1. Call YOUR backend to get a CometChat auth token
|
|
133
|
+
final response = await http.post(
|
|
134
|
+
Uri.parse('https://your-api.com/cometchat/token'),
|
|
135
|
+
headers: {'Authorization': 'Bearer ${yourJwt}'},
|
|
136
|
+
body: jsonEncode({'uid': uid}),
|
|
137
|
+
);
|
|
138
|
+
final authToken = jsonDecode(response.body)['authToken'];
|
|
139
|
+
|
|
140
|
+
// 2. Login to CometChat with the token
|
|
141
|
+
CometChatUIKit.loginWithAuthToken(authToken,
|
|
142
|
+
onSuccess: (user) {
|
|
143
|
+
// CometChatUIKit.loggedInUser is now set
|
|
144
|
+
debugPrint('Logged in as ${user.name}');
|
|
145
|
+
},
|
|
146
|
+
onError: (e) {
|
|
147
|
+
debugPrint('CometChat login failed: ${e.message}');
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Note**: `loginWithAuthToken` populates `CometChatUIKit.loggedInUser` before calling `onSuccess` — same as `login()` and `init()`. No need to call `getLoggedInUser()` afterward.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 3. User Management
|
|
158
|
+
|
|
159
|
+
### Creating Users
|
|
160
|
+
|
|
161
|
+
```dart
|
|
162
|
+
final user = User(
|
|
163
|
+
uid: 'user_123',
|
|
164
|
+
name: 'Jane Doe',
|
|
165
|
+
avatar: 'https://example.com/avatar.png',
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
await CometChatUIKit.createUser(user,
|
|
169
|
+
onSuccess: (created) => debugPrint('Created: ${created.uid}'),
|
|
170
|
+
onError: (e) => debugPrint('Create failed: ${e.message}'),
|
|
171
|
+
);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Updating Users
|
|
175
|
+
|
|
176
|
+
```dart
|
|
177
|
+
final user = User(
|
|
178
|
+
uid: 'user_123',
|
|
179
|
+
name: 'Jane Smith', // Updated name
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
await CometChatUIKit.updateUser(user,
|
|
183
|
+
onSuccess: (updated) => debugPrint('Updated: ${updated.name}'),
|
|
184
|
+
onError: (e) => debugPrint('Update failed: ${e.message}'),
|
|
185
|
+
);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Production Warning
|
|
189
|
+
|
|
190
|
+
`createUser()` and `updateUser()` require the `authKey` (set in UIKitSettings). In production:
|
|
191
|
+
|
|
192
|
+
- **Move user creation to your backend** — call the CometChat REST API server-side
|
|
193
|
+
- **Move user updates to your backend** — same approach
|
|
194
|
+
- The Flutter client should only call `loginWithAuthToken()` — never create or update users directly
|
|
195
|
+
|
|
196
|
+
Server-side user creation:
|
|
197
|
+
```bash
|
|
198
|
+
curl -X POST "https://API_REGION.cometchat.io/v3/users" \
|
|
199
|
+
-H "appId: YOUR_APP_ID" \
|
|
200
|
+
-H "apiKey: YOUR_AUTH_KEY" \
|
|
201
|
+
-H "Content-Type: application/json" \
|
|
202
|
+
-d '{"uid": "user_123", "name": "Jane Doe"}'
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 4. Android Build Requirements
|
|
208
|
+
|
|
209
|
+
These are required for CometChat UIKit v6 on Android. Without them, debug builds may work but release builds will crash.
|
|
210
|
+
|
|
211
|
+
### gradle.properties
|
|
212
|
+
|
|
213
|
+
Ensure these are in `android/gradle.properties`:
|
|
214
|
+
|
|
215
|
+
```properties
|
|
216
|
+
android.useAndroidX=true
|
|
217
|
+
android.enableJetifier=true
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`enableJetifier` resolves old Android Support Library conflicts from transitive dependencies in the CometChat SDK.
|
|
221
|
+
|
|
222
|
+
### minSdk 26
|
|
223
|
+
|
|
224
|
+
In `android/app/build.gradle` (Groovy) or `build.gradle.kts` (Kotlin DSL):
|
|
225
|
+
|
|
226
|
+
```kotlin
|
|
227
|
+
// build.gradle.kts
|
|
228
|
+
android {
|
|
229
|
+
defaultConfig {
|
|
230
|
+
minSdk = 26 // Required by cometchat_calls_sdk
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
```groovy
|
|
236
|
+
// build.gradle (Groovy)
|
|
237
|
+
android {
|
|
238
|
+
defaultConfig {
|
|
239
|
+
minSdkVersion 26
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
If your `minSdk` is lower than 26, the build will fail with a manifest merger error referencing `cometchat_calls_sdk`.
|
|
245
|
+
|
|
246
|
+
### ProGuard / R8 Keep Rules
|
|
247
|
+
|
|
248
|
+
Create `android/app/proguard-rules.pro` with these exact contents:
|
|
249
|
+
|
|
250
|
+
```proguard
|
|
251
|
+
# CometChat — prevent R8 from stripping SDK classes used via reflection
|
|
252
|
+
-keep class com.cometchat.** { *; }
|
|
253
|
+
-keep interface com.cometchat.** { *; }
|
|
254
|
+
|
|
255
|
+
# Suppress warnings for Calls SDK classes referenced cross-module
|
|
256
|
+
-dontwarn com.cometchat.calls.CometChatRTCView$CometChatRTCViewBuilder
|
|
257
|
+
-dontwarn com.cometchat.calls.CometChatRTCView
|
|
258
|
+
-dontwarn com.cometchat.calls.CometChatRTCViewListener
|
|
259
|
+
-dontwarn com.cometchat.calls.model.AnalyticsSettings
|
|
260
|
+
-dontwarn com.cometchat.calls.model.RTCCallback
|
|
261
|
+
-dontwarn com.cometchat.calls.model.RTCReceiver
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Reference the ProGuard file in your release build type. In `android/app/build.gradle.kts`:
|
|
265
|
+
|
|
266
|
+
```kotlin
|
|
267
|
+
android {
|
|
268
|
+
buildTypes {
|
|
269
|
+
release {
|
|
270
|
+
isMinifyEnabled = true
|
|
271
|
+
isShrinkResources = true
|
|
272
|
+
proguardFiles(
|
|
273
|
+
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
274
|
+
"proguard-rules.pro"
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Or in `android/app/build.gradle` (Groovy):
|
|
282
|
+
|
|
283
|
+
```groovy
|
|
284
|
+
android {
|
|
285
|
+
buildTypes {
|
|
286
|
+
release {
|
|
287
|
+
minifyEnabled true
|
|
288
|
+
shrinkResources true
|
|
289
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Without these rules, release builds crash with `ClassNotFoundException` for CometChat classes.** Debug builds work fine because R8/ProGuard only runs on release.
|
|
296
|
+
|
|
297
|
+
### Multidex (if targeting API < 21 elsewhere)
|
|
298
|
+
|
|
299
|
+
CometChat requires minSdk 26, so multidex is not needed (it's automatic above API 21). If you have a multi-module setup where another module targets lower, ensure the app module still sets `minSdk = 26`.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## 5. iOS Build Requirements
|
|
304
|
+
|
|
305
|
+
### Info.plist Permissions
|
|
306
|
+
|
|
307
|
+
Add these to `ios/Runner/Info.plist` inside the top-level `<dict>`:
|
|
308
|
+
|
|
309
|
+
```xml
|
|
310
|
+
<!-- Camera access (video calls, sending photos) -->
|
|
311
|
+
<key>NSCameraUsageDescription</key>
|
|
312
|
+
<string>$(PRODUCT_NAME) needs camera access for video calls and sending photos</string>
|
|
313
|
+
|
|
314
|
+
<!-- Microphone access (voice/video calls, audio messages) -->
|
|
315
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
316
|
+
<string>$(PRODUCT_NAME) needs microphone access for voice and video calls</string>
|
|
317
|
+
|
|
318
|
+
<!-- Photo library access (sending images from gallery) -->
|
|
319
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
320
|
+
<string>$(PRODUCT_NAME) needs photo library access to send images</string>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Without these, the app crashes when the user taps the camera/gallery/mic button — iOS terminates apps that access protected APIs without a usage description.
|
|
324
|
+
|
|
325
|
+
### VoIP Background Mode (for CallKit)
|
|
326
|
+
|
|
327
|
+
If using CometChat calling with CallKit (incoming call notifications when app is backgrounded), add to `Info.plist`:
|
|
328
|
+
|
|
329
|
+
```xml
|
|
330
|
+
<key>UIBackgroundModes</key>
|
|
331
|
+
<array>
|
|
332
|
+
<string>voip</string>
|
|
333
|
+
<string>remote-notification</string>
|
|
334
|
+
</array>
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Or enable via Xcode: Target → Signing & Capabilities → + Background Modes → check "Voice over IP" and "Remote notifications".
|
|
338
|
+
|
|
339
|
+
### App Transport Security
|
|
340
|
+
|
|
341
|
+
CometChat uses HTTPS by default, so no ATS exceptions are needed. If you're loading user avatars or media from HTTP URLs (not recommended), add:
|
|
342
|
+
|
|
343
|
+
```xml
|
|
344
|
+
<key>NSAppTransportSecurity</key>
|
|
345
|
+
<dict>
|
|
346
|
+
<key>NSAllowsArbitraryLoads</key>
|
|
347
|
+
<true/>
|
|
348
|
+
</dict>
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Avoid this in production** — it disables all transport security. Instead, ensure all media URLs use HTTPS.
|
|
352
|
+
|
|
353
|
+
### Minimum iOS Deployment Target
|
|
354
|
+
|
|
355
|
+
In `ios/Podfile`, ensure:
|
|
356
|
+
|
|
357
|
+
```ruby
|
|
358
|
+
platform :ios, '13.0'
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
CometChat UIKit v6 requires iOS 13.0+. If your Podfile has a lower target, `pod install` will fail.
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## 6. Environment Configuration
|
|
366
|
+
|
|
367
|
+
Never hardcode credentials in source code. The `AppCredentials` pattern used in development:
|
|
368
|
+
|
|
369
|
+
```dart
|
|
370
|
+
// ❌ DON'T ship this — credentials visible in decompiled binary
|
|
371
|
+
class AppCredentials {
|
|
372
|
+
static const String appId = '26580020f03ff346';
|
|
373
|
+
static const String region = 'in';
|
|
374
|
+
static const String authKey = '4152b0366478871f0fa8d19a287dd6f5ed5f8eff';
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Option A: Dart Defines (recommended for simple setups)
|
|
379
|
+
|
|
380
|
+
Pass credentials at build time:
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
flutter run \
|
|
384
|
+
--dart-define=COMETCHAT_APP_ID=your_app_id \
|
|
385
|
+
--dart-define=COMETCHAT_REGION=us
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Read them in code:
|
|
389
|
+
|
|
390
|
+
```dart
|
|
391
|
+
class CometChatConfig {
|
|
392
|
+
static const appId = String.fromEnvironment('COMETCHAT_APP_ID');
|
|
393
|
+
static const region = String.fromEnvironment('COMETCHAT_REGION');
|
|
394
|
+
// No authKey in production builds — use authToken flow
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
For release builds:
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
flutter build apk \
|
|
402
|
+
--dart-define=COMETCHAT_APP_ID=your_app_id \
|
|
403
|
+
--dart-define=COMETCHAT_REGION=us
|
|
404
|
+
|
|
405
|
+
flutter build ipa \
|
|
406
|
+
--dart-define=COMETCHAT_APP_ID=your_app_id \
|
|
407
|
+
--dart-define=COMETCHAT_REGION=us
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Option B: .env File with flutter_dotenv
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
dart pub add flutter_dotenv
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Create `.env` (add to `.gitignore`):
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
COMETCHAT_APP_ID=your_app_id
|
|
420
|
+
COMETCHAT_REGION=us
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Load in code:
|
|
424
|
+
|
|
425
|
+
```dart
|
|
426
|
+
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
427
|
+
|
|
428
|
+
Future<void> main() async {
|
|
429
|
+
await dotenv.load(fileName: '.env');
|
|
430
|
+
runApp(const MyApp());
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
class CometChatConfig {
|
|
434
|
+
static String get appId => dotenv.env['COMETCHAT_APP_ID'] ?? '';
|
|
435
|
+
static String get region => dotenv.env['COMETCHAT_REGION'] ?? 'us';
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**Note**: `.env` files bundled in the app asset can still be extracted. For true secret protection, fetch config from your backend at runtime.
|
|
440
|
+
|
|
441
|
+
### Option C: Flavor-Based Configuration
|
|
442
|
+
|
|
443
|
+
For apps with dev/staging/prod environments:
|
|
444
|
+
|
|
445
|
+
```dart
|
|
446
|
+
enum Environment { dev, staging, prod }
|
|
447
|
+
|
|
448
|
+
class CometChatConfig {
|
|
449
|
+
final String appId;
|
|
450
|
+
final String region;
|
|
451
|
+
final bool useAuthToken; // true for staging/prod
|
|
452
|
+
|
|
453
|
+
const CometChatConfig._({
|
|
454
|
+
required this.appId,
|
|
455
|
+
required this.region,
|
|
456
|
+
required this.useAuthToken,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
static CometChatConfig of(Environment env) {
|
|
460
|
+
switch (env) {
|
|
461
|
+
case Environment.dev:
|
|
462
|
+
return const CometChatConfig._(
|
|
463
|
+
appId: 'dev_app_id',
|
|
464
|
+
region: 'us',
|
|
465
|
+
useAuthToken: false,
|
|
466
|
+
);
|
|
467
|
+
case Environment.staging:
|
|
468
|
+
return const CometChatConfig._(
|
|
469
|
+
appId: 'staging_app_id',
|
|
470
|
+
region: 'us',
|
|
471
|
+
useAuthToken: true,
|
|
472
|
+
);
|
|
473
|
+
case Environment.prod:
|
|
474
|
+
return const CometChatConfig._(
|
|
475
|
+
appId: 'prod_app_id',
|
|
476
|
+
region: 'us',
|
|
477
|
+
useAuthToken: true,
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## 7. Release Build Checklist
|
|
487
|
+
|
|
488
|
+
### Authentication
|
|
489
|
+
- [ ] `authKey` is NOT in any client-side code for production builds
|
|
490
|
+
- [ ] Server-side auth token generation is implemented and tested
|
|
491
|
+
- [ ] `CometChatUIKit.loginWithAuthToken()` is used instead of `CometChatUIKit.login()`
|
|
492
|
+
- [ ] User creation/update calls are server-side, not client-side
|
|
493
|
+
|
|
494
|
+
### Android
|
|
495
|
+
- [ ] `minSdk = 26` in `android/app/build.gradle`
|
|
496
|
+
- [ ] `android.enableJetifier=true` in `gradle.properties`
|
|
497
|
+
- [ ] `proguard-rules.pro` created with CometChat keep rules
|
|
498
|
+
- [ ] Release build type references `proguard-rules.pro`
|
|
499
|
+
- [ ] `isMinifyEnabled = true` and `isShrinkResources = true` for release
|
|
500
|
+
- [ ] Release APK/AAB tested on a real device (not just debug)
|
|
501
|
+
- [ ] Push notification provider ID configured (FCM)
|
|
502
|
+
|
|
503
|
+
### iOS
|
|
504
|
+
- [ ] `NSCameraUsageDescription` in Info.plist
|
|
505
|
+
- [ ] `NSMicrophoneUsageDescription` in Info.plist
|
|
506
|
+
- [ ] `NSPhotoLibraryUsageDescription` in Info.plist
|
|
507
|
+
- [ ] VoIP background mode enabled (if using CallKit)
|
|
508
|
+
- [ ] Minimum deployment target is iOS 13.0+
|
|
509
|
+
- [ ] Release build tested on a real device
|
|
510
|
+
- [ ] Push notification entitlements configured (APNs)
|
|
511
|
+
|
|
512
|
+
### Environment
|
|
513
|
+
- [ ] No hardcoded credentials in source code
|
|
514
|
+
- [ ] Credentials passed via dart-define, .env, or flavor config
|
|
515
|
+
- [ ] `.env` files are in `.gitignore`
|
|
516
|
+
- [ ] Production app ID and region are correct (not dev/staging)
|
|
517
|
+
|
|
518
|
+
### CometChat Configuration
|
|
519
|
+
- [ ] `CometChatUIKit.init()` called before any login or component usage
|
|
520
|
+
- [ ] `subscriptionType` set in UIKitSettingsBuilder (or presence events won't fire)
|
|
521
|
+
- [ ] `region` is lowercase (`'us'`, `'eu'`, `'in'`)
|
|
522
|
+
- [ ] Logout properly calls `CometChatUIKit.logout()` and clears local state
|
|
523
|
+
|
|
524
|
+
### Testing
|
|
525
|
+
- [ ] Release build tested end-to-end: init → login → send message → receive message → logout
|
|
526
|
+
- [ ] Tested on both Android and iOS physical devices
|
|
527
|
+
- [ ] Tested with ProGuard/R8 enabled (Android release)
|
|
528
|
+
- [ ] Tested push notifications in production environment
|
|
529
|
+
- [ ] Tested calling features if enabled (audio + video)
|
|
530
|
+
- [ ] Tested app kill → reopen → session restore (cached login via `CometChatUIKit.loggedInUser`)
|
|
531
|
+
|
|
532
|
+
---
|
|
533
|
+
|
|
534
|
+
## 8. Security Hardening
|
|
535
|
+
|
|
536
|
+
### Never Ship authKey in Production
|
|
537
|
+
|
|
538
|
+
The `authKey` allows anyone to:
|
|
539
|
+
- Log in as any user
|
|
540
|
+
- Create users
|
|
541
|
+
- Update user profiles
|
|
542
|
+
|
|
543
|
+
If it's in your APK/IPA, it can be extracted in minutes with standard decompilation tools.
|
|
544
|
+
|
|
545
|
+
```dart
|
|
546
|
+
// ❌ SECURITY VULNERABILITY — authKey in client code
|
|
547
|
+
final settings = (UIKitSettingsBuilder()
|
|
548
|
+
..appId = 'APP_ID'
|
|
549
|
+
..region = 'us'
|
|
550
|
+
..authKey = 'AUTH_KEY_VISIBLE_TO_ATTACKERS')
|
|
551
|
+
.build();
|
|
552
|
+
|
|
553
|
+
// ✅ SECURE — no authKey, use server-minted tokens
|
|
554
|
+
final settings = (UIKitSettingsBuilder()
|
|
555
|
+
..appId = appId // App ID is not secret (it's in network requests anyway)
|
|
556
|
+
..region = region
|
|
557
|
+
..subscriptionType = CometChatSubscriptionType.allUsers)
|
|
558
|
+
.build();
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Don't Log Sensitive Data
|
|
562
|
+
|
|
563
|
+
```dart
|
|
564
|
+
// ❌ WRONG — auth tokens in logs
|
|
565
|
+
debugPrint('Token: $authToken');
|
|
566
|
+
debugPrint('User: ${user.toJson()}'); // May contain tokens
|
|
567
|
+
|
|
568
|
+
// ✅ CORRECT — log only non-sensitive identifiers
|
|
569
|
+
debugPrint('Logged in as uid: ${user.uid}');
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
In release builds, consider disabling debug prints entirely:
|
|
573
|
+
|
|
574
|
+
```dart
|
|
575
|
+
// In main.dart for release
|
|
576
|
+
if (kReleaseMode) {
|
|
577
|
+
debugPrint = (String? message, {int? wrapWidth}) {};
|
|
578
|
+
}
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### ProGuard Obfuscation
|
|
582
|
+
|
|
583
|
+
The ProGuard rules in Section 4 keep CometChat classes intact (required for the SDK to work), but R8 will still obfuscate your own application code. This makes reverse engineering harder.
|
|
584
|
+
|
|
585
|
+
Ensure `isMinifyEnabled = true` is set for release builds — it enables both code shrinking and obfuscation.
|
|
586
|
+
|
|
587
|
+
### Token Expiry and Refresh
|
|
588
|
+
|
|
589
|
+
CometChat auth tokens don't expire by default, but you can configure token expiry in the CometChat dashboard. If you enable expiry:
|
|
590
|
+
|
|
591
|
+
```dart
|
|
592
|
+
CometChatUIKit.loginWithAuthToken(authToken,
|
|
593
|
+
onSuccess: (user) {
|
|
594
|
+
// Token accepted, proceed
|
|
595
|
+
},
|
|
596
|
+
onError: (e) {
|
|
597
|
+
if (e.code == 'ERR_AUTH_TOKEN_NOT_FOUND' || e.code == 'AUTH_ERR_AUTH_TOKEN_NOT_FOUND') {
|
|
598
|
+
// Token expired or invalid — fetch a new one from your backend
|
|
599
|
+
refreshAndRetryLogin();
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
);
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Network Security
|
|
606
|
+
|
|
607
|
+
- CometChat SDK uses HTTPS/WSS by default — no additional configuration needed
|
|
608
|
+
- Don't add `NSAllowsArbitraryLoads` to Info.plist unless absolutely necessary
|
|
609
|
+
- If using a proxy or custom certificate pinning, ensure CometChat domains are whitelisted:
|
|
610
|
+
- `*.cometchat.io`
|
|
611
|
+
- `*.cometchat.com`
|
|
612
|
+
|
|
613
|
+
### Session Management
|
|
614
|
+
|
|
615
|
+
```dart
|
|
616
|
+
// Always logout when user signs out of your app
|
|
617
|
+
Future<void> signOut() async {
|
|
618
|
+
// 1. Logout from CometChat
|
|
619
|
+
CometChatUIKit.logout(
|
|
620
|
+
onSuccess: (_) => debugPrint('CometChat logout success'),
|
|
621
|
+
onError: (e) => debugPrint('CometChat logout failed: ${e.message}'),
|
|
622
|
+
);
|
|
623
|
+
|
|
624
|
+
// 2. Clear your own auth state
|
|
625
|
+
await yourAuthService.signOut();
|
|
626
|
+
|
|
627
|
+
// 3. Navigate to login screen
|
|
628
|
+
navigator.pushReplacementNamed('/login');
|
|
629
|
+
}
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
Don't just navigate away — always call `CometChatUIKit.logout()` to clear the SDK session, disconnect WebSocket, and remove cached credentials.
|