@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,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-android-v5-placement
|
|
3
|
+
description: "Where to put CometChat in your Android app — Activity, Fragment, BottomSheet, Dialog, Tab, or embedded patterns."
|
|
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 placement activity fragment bottomsheet dialog tabs integration"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
> **Companion skills:** `cometchat-android-v5-core` covers init and login;
|
|
14
|
+
> `cometchat-android-v5-components` provides the component catalog.
|
|
15
|
+
|
|
16
|
+
## Purpose
|
|
17
|
+
|
|
18
|
+
This skill teaches WHERE to put CometChat in an existing Android project. It covers six placement patterns: dedicated Activity, Fragment, BottomSheet, Dialog, Tab/ViewPager, and embedded view. Each pattern includes step-by-step instructions and code examples in both Java and Kotlin.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Use this skill when
|
|
23
|
+
|
|
24
|
+
- Integrating CometChat into an existing Android app
|
|
25
|
+
- Deciding between Activity vs Fragment vs BottomSheet
|
|
26
|
+
- "Where should I put the chat screen?"
|
|
27
|
+
- "How do I add chat as a tab?"
|
|
28
|
+
- "How do I show chat in a bottom sheet?"
|
|
29
|
+
|
|
30
|
+
## Do not use this skill when
|
|
31
|
+
|
|
32
|
+
- Setting up init/login → use `cometchat-android-v5-core`
|
|
33
|
+
- Looking up component APIs → use `cometchat-android-v5-components`
|
|
34
|
+
- Customizing appearance → use `cometchat-android-v5-theming`
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 1. Placement recommendation
|
|
39
|
+
|
|
40
|
+
| User intent | Recommended placement | Why |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| Messaging app | Dedicated Activity with bottom tabs | Full-screen chat experience |
|
|
43
|
+
| Marketplace | Chat button → new Activity | Separate context from product browsing |
|
|
44
|
+
| SaaS / dashboard | Fragment in existing Activity | Chat alongside other features |
|
|
45
|
+
| Social / community | ViewPager + BottomNav tabs | Multi-section messenger |
|
|
46
|
+
| Support / helpdesk | BottomSheet overlay | Non-intrusive, dismissible |
|
|
47
|
+
| Quick reply | Dialog | Lightweight, modal |
|
|
48
|
+
| Embedded widget | View in existing layout | Inline chat within a screen |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 2. Pattern A — Dedicated Activity
|
|
53
|
+
|
|
54
|
+
The simplest and most common pattern. A full-screen Activity for the message view.
|
|
55
|
+
|
|
56
|
+
**MessagesActivity layout (`activity_messages.xml`):**
|
|
57
|
+
```xml
|
|
58
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
59
|
+
android:layout_width="match_parent"
|
|
60
|
+
android:layout_height="match_parent"
|
|
61
|
+
android:orientation="vertical">
|
|
62
|
+
|
|
63
|
+
<com.cometchat.chatuikit.messageheader.CometChatMessageHeader
|
|
64
|
+
android:id="@+id/header"
|
|
65
|
+
android:layout_width="match_parent"
|
|
66
|
+
android:layout_height="wrap_content" />
|
|
67
|
+
|
|
68
|
+
<com.cometchat.chatuikit.messagelist.CometChatMessageList
|
|
69
|
+
android:id="@+id/messageList"
|
|
70
|
+
android:layout_width="match_parent"
|
|
71
|
+
android:layout_height="0dp"
|
|
72
|
+
android:layout_weight="1" />
|
|
73
|
+
|
|
74
|
+
<com.cometchat.chatuikit.messagecomposer.CometChatMessageComposer
|
|
75
|
+
android:id="@+id/composer"
|
|
76
|
+
android:layout_width="match_parent"
|
|
77
|
+
android:layout_height="wrap_content" />
|
|
78
|
+
</LinearLayout>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Java:**
|
|
82
|
+
```java
|
|
83
|
+
public class MessagesActivity extends AppCompatActivity {
|
|
84
|
+
@Override
|
|
85
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
86
|
+
super.onCreate(savedInstanceState);
|
|
87
|
+
setContentView(R.layout.activity_messages);
|
|
88
|
+
|
|
89
|
+
CometChatMessageHeader header = findViewById(R.id.header);
|
|
90
|
+
CometChatMessageList messageList = findViewById(R.id.messageList);
|
|
91
|
+
CometChatMessageComposer composer = findViewById(R.id.composer);
|
|
92
|
+
|
|
93
|
+
String uid = getIntent().getStringExtra("uid");
|
|
94
|
+
String guid = getIntent().getStringExtra("guid");
|
|
95
|
+
|
|
96
|
+
if (uid != null) {
|
|
97
|
+
CometChat.getUser(uid, new CometChat.CallbackListener<User>() {
|
|
98
|
+
@Override
|
|
99
|
+
public void onSuccess(User user) {
|
|
100
|
+
header.setUser(user);
|
|
101
|
+
messageList.setUser(user);
|
|
102
|
+
composer.setUser(user);
|
|
103
|
+
}
|
|
104
|
+
@Override
|
|
105
|
+
public void onError(CometChatException e) { }
|
|
106
|
+
});
|
|
107
|
+
} else if (guid != null) {
|
|
108
|
+
CometChat.getGroup(guid, new CometChat.CallbackListener<Group>() {
|
|
109
|
+
@Override
|
|
110
|
+
public void onSuccess(Group group) {
|
|
111
|
+
header.setGroup(group);
|
|
112
|
+
messageList.setGroup(group);
|
|
113
|
+
composer.setGroup(group);
|
|
114
|
+
}
|
|
115
|
+
@Override
|
|
116
|
+
public void onError(CometChatException e) { }
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
header.setBackIconVisibility(View.VISIBLE);
|
|
121
|
+
header.setOnBackPress(() -> finish());
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Kotlin:**
|
|
127
|
+
```kotlin
|
|
128
|
+
class MessagesActivity : AppCompatActivity() {
|
|
129
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
130
|
+
super.onCreate(savedInstanceState)
|
|
131
|
+
setContentView(R.layout.activity_messages)
|
|
132
|
+
|
|
133
|
+
val header = findViewById<CometChatMessageHeader>(R.id.header)
|
|
134
|
+
val messageList = findViewById<CometChatMessageList>(R.id.messageList)
|
|
135
|
+
val composer = findViewById<CometChatMessageComposer>(R.id.composer)
|
|
136
|
+
|
|
137
|
+
val uid = intent.getStringExtra("uid")
|
|
138
|
+
val guid = intent.getStringExtra("guid")
|
|
139
|
+
|
|
140
|
+
when {
|
|
141
|
+
uid != null -> CometChat.getUser(uid, object : CometChat.CallbackListener<User>() {
|
|
142
|
+
override fun onSuccess(user: User) {
|
|
143
|
+
header.setUser(user)
|
|
144
|
+
messageList.setUser(user)
|
|
145
|
+
composer.setUser(user)
|
|
146
|
+
}
|
|
147
|
+
override fun onError(e: CometChatException) { }
|
|
148
|
+
})
|
|
149
|
+
guid != null -> CometChat.getGroup(guid, object : CometChat.CallbackListener<Group>() {
|
|
150
|
+
override fun onSuccess(group: Group) {
|
|
151
|
+
header.setGroup(group)
|
|
152
|
+
messageList.setGroup(group)
|
|
153
|
+
composer.setGroup(group)
|
|
154
|
+
}
|
|
155
|
+
override fun onError(e: CometChatException) { }
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
header.setBackIconVisibility(View.VISIBLE)
|
|
160
|
+
header.setOnBackPress { finish() }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 3. Pattern B — Fragment
|
|
168
|
+
|
|
169
|
+
Embed chat in a Fragment within an existing Activity. Useful for SaaS apps or multi-pane layouts.
|
|
170
|
+
|
|
171
|
+
**Java:**
|
|
172
|
+
```java
|
|
173
|
+
public class ChatFragment extends Fragment {
|
|
174
|
+
@Override
|
|
175
|
+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
176
|
+
View view = inflater.inflate(R.layout.fragment_chat, container, false);
|
|
177
|
+
|
|
178
|
+
CometChatConversations conversations = view.findViewById(R.id.conversations);
|
|
179
|
+
conversations.setOnItemClick((v, position, conversation) -> {
|
|
180
|
+
// Navigate to messages — either replace fragment or start Activity
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
return view;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Kotlin:**
|
|
189
|
+
```kotlin
|
|
190
|
+
class ChatFragment : Fragment() {
|
|
191
|
+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
|
192
|
+
val view = inflater.inflate(R.layout.fragment_chat, container, false)
|
|
193
|
+
|
|
194
|
+
val conversations = view.findViewById<CometChatConversations>(R.id.conversations)
|
|
195
|
+
conversations.setOnItemClick { v, position, conversation ->
|
|
196
|
+
// Navigate to messages — either replace fragment or start Activity
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return view
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 4. Pattern C — BottomSheet
|
|
207
|
+
|
|
208
|
+
Show chat as a bottom sheet overlay. Good for support/helpdesk.
|
|
209
|
+
|
|
210
|
+
**Java:**
|
|
211
|
+
```java
|
|
212
|
+
BottomSheetDialog bottomSheet = new BottomSheetDialog(this);
|
|
213
|
+
View view = getLayoutInflater().inflate(R.layout.bottom_sheet_chat, null);
|
|
214
|
+
|
|
215
|
+
CometChatMessageList messageList = view.findViewById(R.id.messageList);
|
|
216
|
+
CometChatMessageComposer composer = view.findViewById(R.id.composer);
|
|
217
|
+
|
|
218
|
+
messageList.setUser(user);
|
|
219
|
+
composer.setUser(user);
|
|
220
|
+
|
|
221
|
+
bottomSheet.setContentView(view);
|
|
222
|
+
bottomSheet.show();
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Kotlin:**
|
|
226
|
+
```kotlin
|
|
227
|
+
val bottomSheet = BottomSheetDialog(this)
|
|
228
|
+
val view = layoutInflater.inflate(R.layout.bottom_sheet_chat, null)
|
|
229
|
+
|
|
230
|
+
val messageList = view.findViewById<CometChatMessageList>(R.id.messageList)
|
|
231
|
+
val composer = view.findViewById<CometChatMessageComposer>(R.id.composer)
|
|
232
|
+
|
|
233
|
+
messageList.setUser(user)
|
|
234
|
+
composer.setUser(user)
|
|
235
|
+
|
|
236
|
+
bottomSheet.setContentView(view)
|
|
237
|
+
bottomSheet.show()
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 5. Pattern D — Bottom Navigation Tabs
|
|
243
|
+
|
|
244
|
+
Full messenger with Conversations, Users, Groups, and Calls as tabs.
|
|
245
|
+
|
|
246
|
+
**Java:**
|
|
247
|
+
```java
|
|
248
|
+
binding.bottomNavigationView.setOnItemSelectedListener(item -> {
|
|
249
|
+
Fragment fragment;
|
|
250
|
+
int id = item.getItemId();
|
|
251
|
+
if (id == R.id.nav_chats) {
|
|
252
|
+
fragment = new ChatsFragment(); // Contains CometChatConversations
|
|
253
|
+
} else if (id == R.id.nav_users) {
|
|
254
|
+
fragment = new UsersFragment(); // Contains CometChatUsers
|
|
255
|
+
} else if (id == R.id.nav_groups) {
|
|
256
|
+
fragment = new GroupsFragment(); // Contains CometChatGroups
|
|
257
|
+
} else if (id == R.id.nav_calls) {
|
|
258
|
+
fragment = new CallsFragment(); // Contains CometChatCallLogs
|
|
259
|
+
} else {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
getSupportFragmentManager().beginTransaction()
|
|
263
|
+
.replace(R.id.fragment_container, fragment)
|
|
264
|
+
.commit();
|
|
265
|
+
return true;
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Hard rules
|
|
272
|
+
|
|
273
|
+
- **Always set `User` or `Group` on message components.** `CometChatMessageList`, `CometChatMessageComposer`, and `CometChatMessageHeader` require either `setUser()` or `setGroup()` — never both, never neither.
|
|
274
|
+
- **Fetch the `User`/`Group` object before setting it.** Use `CometChat.getUser(uid)` or `CometChat.getGroup(guid)` — don't construct objects manually.
|
|
275
|
+
- **Set back icon visibility on `CometChatMessageHeader`.** The method is `setBackIconVisibility()`. Default is `GONE`. Set to `VISIBLE` when the user needs to navigate back.
|
|
276
|
+
- **Register the Activity in `AndroidManifest.xml`.** Every new Activity needs a manifest entry.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-android-v5-production
|
|
3
|
+
description: "Production readiness for CometChat Android — server-side token auth, user management CRUD, ProGuard rules, and security checklist."
|
|
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: "cometchat android production auth token security user-management proguard"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
> **Companion skills:** `cometchat-android-v5-core` covers dev-mode login;
|
|
14
|
+
> `cometchat-android-v5-push` covers push notification setup for production.
|
|
15
|
+
|
|
16
|
+
## Purpose
|
|
17
|
+
|
|
18
|
+
This skill covers hardening a CometChat Android integration for production: replacing client-side Auth Key with server-side token generation, user management CRUD, ProGuard/R8 rules, and security best practices.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Use this skill when
|
|
23
|
+
|
|
24
|
+
- "Set up production auth"
|
|
25
|
+
- "Replace Auth Key with tokens"
|
|
26
|
+
- "ProGuard is breaking CometChat"
|
|
27
|
+
- "How do I create CometChat users from my backend?"
|
|
28
|
+
|
|
29
|
+
## Do not use this skill when
|
|
30
|
+
|
|
31
|
+
- Setting up dev-mode login → use `cometchat-android-v5-core`
|
|
32
|
+
- Adding features → use `cometchat-android-v5-features`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 1. Why production auth matters
|
|
37
|
+
|
|
38
|
+
In dev mode, `CometChatUIKit.login(uid)` uses the Auth Key embedded in your app. Anyone can decompile the APK, extract the key, and login as ANY user. Production deployments MUST use server-side token generation.
|
|
39
|
+
|
|
40
|
+
## 2. Token auth flow
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Client → Your Server → CometChat REST API → auth token → Client
|
|
44
|
+
Client calls CometChatUIKit.loginWithAuthToken(token)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Your server calls: `POST https://{APP_ID}.api-{REGION}.cometchat.io/v3/users/{uid}/auth_tokens`
|
|
48
|
+
with headers: `appId`, `apiKey` (REST API Key, NOT Auth Key).
|
|
49
|
+
|
|
50
|
+
## 3. Client-side implementation
|
|
51
|
+
|
|
52
|
+
**Java:**
|
|
53
|
+
```java
|
|
54
|
+
// Fetch token from YOUR backend
|
|
55
|
+
String token = fetchTokenFromYourServer(currentUserId);
|
|
56
|
+
|
|
57
|
+
CometChatUIKit.loginWithAuthToken(token, new CometChat.CallbackListener<User>() {
|
|
58
|
+
@Override
|
|
59
|
+
public void onSuccess(User user) {
|
|
60
|
+
// Navigate to chat
|
|
61
|
+
}
|
|
62
|
+
@Override
|
|
63
|
+
public void onError(CometChatException e) {
|
|
64
|
+
// Handle error
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 4. ProGuard/R8 rules
|
|
70
|
+
|
|
71
|
+
Add to `proguard-rules.pro`:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
-keep class com.cometchat.** { *; }
|
|
75
|
+
-keep class com.cometchat.chatuikit.** { *; }
|
|
76
|
+
-dontwarn com.cometchat.**
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 5. Security checklist
|
|
80
|
+
|
|
81
|
+
- [ ] Auth Key removed from client code
|
|
82
|
+
- [ ] REST API Key stored server-side only
|
|
83
|
+
- [ ] `loginWithAuthToken()` used instead of `login(uid)`
|
|
84
|
+
- [ ] ProGuard rules added
|
|
85
|
+
- [ ] Network security config allows CometChat domains
|
|
86
|
+
- [ ] Push token unregistered on logout
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Hard rules
|
|
91
|
+
|
|
92
|
+
- **Never ship Auth Key in production APKs.** Use `loginWithAuthToken()`.
|
|
93
|
+
- **REST API Key ≠ Auth Key.** REST API Key is server-only. Auth Key is client-side dev-only.
|
|
94
|
+
- **Add ProGuard keep rules.** R8 can strip CometChat classes needed at runtime.
|