@cometchat/skills 4.1.0 → 4.2.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 (257) hide show
  1. package/bin/install.js +298 -41
  2. package/package.json +1 -1
  3. package/skills/cometchat/SKILL.md +146 -27
  4. package/skills/cometchat-a11y/SKILL.md +476 -0
  5. package/skills/cometchat-android-v5/SKILL.md +1 -1
  6. package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
  7. package/skills/cometchat-android-v5-calls/references/README.md +53 -0
  8. package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
  9. package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
  10. package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
  11. package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
  12. package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
  13. package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
  14. package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
  15. package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
  16. package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
  17. package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
  18. package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
  19. package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
  20. package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
  21. package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
  22. package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
  23. package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
  24. package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
  25. package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
  26. package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
  27. package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
  28. package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
  29. package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
  30. package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
  31. package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
  32. package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
  33. package/skills/cometchat-android-v5-components/SKILL.md +1 -1
  34. package/skills/cometchat-android-v5-core/SKILL.md +1 -1
  35. package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
  36. package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
  37. package/skills/cometchat-android-v5-features/SKILL.md +1 -1
  38. package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
  39. package/skills/cometchat-android-v5-production/SKILL.md +1 -1
  40. package/skills/cometchat-android-v5-push/SKILL.md +1 -1
  41. package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
  42. package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
  43. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
  44. package/skills/cometchat-android-v6/SKILL.md +1 -1
  45. package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
  46. package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
  47. package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
  48. package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
  49. package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
  50. package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
  51. package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
  52. package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
  53. package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
  54. package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
  55. package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
  56. package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
  57. package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
  58. package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
  59. package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
  60. package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
  61. package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
  62. package/skills/cometchat-android-v6-core/SKILL.md +1 -1
  63. package/skills/cometchat-android-v6-events/SKILL.md +1 -1
  64. package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
  65. package/skills/cometchat-android-v6-features/SKILL.md +1 -1
  66. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
  67. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
  68. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
  69. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
  70. package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
  71. package/skills/cometchat-android-v6-production/SKILL.md +1 -1
  72. package/skills/cometchat-android-v6-push/SKILL.md +1 -1
  73. package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
  74. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
  75. package/skills/cometchat-angular-calls/SKILL.md +511 -0
  76. package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
  77. package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
  78. package/skills/cometchat-angular-calls/references/call-session.md +167 -0
  79. package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
  80. package/skills/cometchat-angular-calls/references/device-management.md +135 -0
  81. package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
  82. package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
  83. package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
  84. package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
  85. package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
  86. package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
  87. package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
  88. package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
  89. package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
  90. package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
  91. package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
  92. package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
  93. package/skills/cometchat-angular-components/SKILL.md +1 -1
  94. package/skills/cometchat-angular-core/SKILL.md +1 -1
  95. package/skills/cometchat-angular-customization/SKILL.md +1 -1
  96. package/skills/cometchat-angular-features/SKILL.md +1 -1
  97. package/skills/cometchat-angular-patterns/SKILL.md +1 -1
  98. package/skills/cometchat-angular-placement/SKILL.md +1 -1
  99. package/skills/cometchat-angular-production/SKILL.md +1 -1
  100. package/skills/cometchat-angular-push/SKILL.md +403 -0
  101. package/skills/cometchat-angular-testing/SKILL.md +333 -0
  102. package/skills/cometchat-angular-theming/SKILL.md +1 -1
  103. package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
  104. package/skills/cometchat-astro-patterns/SKILL.md +1 -1
  105. package/skills/cometchat-calls/SKILL.md +358 -0
  106. package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
  107. package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
  108. package/skills/cometchat-calls/references/use-case-support.md +190 -0
  109. package/skills/cometchat-calls/references/use-case-team.md +169 -0
  110. package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
  111. package/skills/cometchat-components/SKILL.md +1 -1
  112. package/skills/cometchat-core/SKILL.md +1 -1
  113. package/skills/cometchat-customization/SKILL.md +2 -2
  114. package/skills/cometchat-features/SKILL.md +2 -2
  115. package/skills/cometchat-flutter-v5/SKILL.md +1 -1
  116. package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
  117. package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
  118. package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
  119. package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
  120. package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
  121. package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
  122. package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
  123. package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
  124. package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
  125. package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
  126. package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
  127. package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
  128. package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
  129. package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
  130. package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
  131. package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
  132. package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
  133. package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
  134. package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
  135. package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
  136. package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
  137. package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
  138. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
  139. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
  140. package/skills/cometchat-flutter-v6/SKILL.md +1 -1
  141. package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
  142. package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
  143. package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
  144. package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
  145. package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
  146. package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
  147. package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
  148. package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
  149. package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
  150. package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
  151. package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
  152. package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
  153. package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
  154. package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
  155. package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
  156. package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
  157. package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
  158. package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
  159. package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
  160. package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
  161. package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
  162. package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
  163. package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
  164. package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
  165. package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
  166. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
  167. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
  168. package/skills/cometchat-i18n/SKILL.md +358 -0
  169. package/skills/cometchat-ios/SKILL.md +5 -5
  170. package/skills/cometchat-ios-calls/SKILL.md +409 -0
  171. package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
  172. package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
  173. package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
  174. package/skills/cometchat-ios-calls/references/call-session.md +221 -0
  175. package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
  176. package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
  177. package/skills/cometchat-ios-calls/references/device-management.md +171 -0
  178. package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
  179. package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
  180. package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
  181. package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
  182. package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
  183. package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
  184. package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
  185. package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
  186. package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
  187. package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
  188. package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
  189. package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
  190. package/skills/cometchat-ios-components/SKILL.md +1 -1
  191. package/skills/cometchat-ios-core/SKILL.md +1 -1
  192. package/skills/cometchat-ios-customization/SKILL.md +1 -1
  193. package/skills/cometchat-ios-features/SKILL.md +1 -1
  194. package/skills/cometchat-ios-placement/SKILL.md +1 -1
  195. package/skills/cometchat-ios-production/SKILL.md +1 -1
  196. package/skills/cometchat-ios-push/SKILL.md +1 -1
  197. package/skills/cometchat-ios-testing/SKILL.md +371 -0
  198. package/skills/cometchat-ios-theming/SKILL.md +1 -1
  199. package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
  200. package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
  201. package/skills/cometchat-native-calls/SKILL.md +599 -0
  202. package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
  203. package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
  204. package/skills/cometchat-native-calls/references/call-session.md +182 -0
  205. package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
  206. package/skills/cometchat-native-calls/references/device-management.md +135 -0
  207. package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
  208. package/skills/cometchat-native-calls/references/group-calls.md +291 -0
  209. package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
  210. package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
  211. package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
  212. package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
  213. package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
  214. package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
  215. package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
  216. package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
  217. package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
  218. package/skills/cometchat-native-calls/references/share-invite.md +144 -0
  219. package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
  220. package/skills/cometchat-native-components/SKILL.md +1 -1
  221. package/skills/cometchat-native-core/SKILL.md +1 -1
  222. package/skills/cometchat-native-customization/SKILL.md +1 -1
  223. package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
  224. package/skills/cometchat-native-features/SKILL.md +1 -1
  225. package/skills/cometchat-native-placement/SKILL.md +1 -1
  226. package/skills/cometchat-native-production/SKILL.md +1 -1
  227. package/skills/cometchat-native-push/SKILL.md +1 -1
  228. package/skills/cometchat-native-testing/SKILL.md +1 -1
  229. package/skills/cometchat-native-theming/SKILL.md +1 -1
  230. package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
  231. package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
  232. package/skills/cometchat-placement/SKILL.md +1 -1
  233. package/skills/cometchat-production/SKILL.md +1 -1
  234. package/skills/cometchat-react-calls/SKILL.md +539 -0
  235. package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
  236. package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
  237. package/skills/cometchat-react-calls/references/call-session.md +235 -0
  238. package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
  239. package/skills/cometchat-react-calls/references/device-management.md +206 -0
  240. package/skills/cometchat-react-calls/references/group-calls.md +262 -0
  241. package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
  242. package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
  243. package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
  244. package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
  245. package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
  246. package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
  247. package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
  248. package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
  249. package/skills/cometchat-react-calls/references/share-invite.md +176 -0
  250. package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
  251. package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
  252. package/skills/cometchat-react-patterns/SKILL.md +1 -1
  253. package/skills/cometchat-react-push/SKILL.md +448 -0
  254. package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
  255. package/skills/cometchat-react-testing/SKILL.md +404 -0
  256. package/skills/cometchat-theming/SKILL.md +3 -3
  257. package/skills/cometchat-troubleshooting/SKILL.md +2 -2
@@ -0,0 +1,448 @@
1
+ ---
2
+ name: cometchat-react-push
3
+ description: Push notifications for CometChat React UI Kit v6 in Vite / Next.js / React Router / Astro projects. Web doesn't have native push — covers Web Push (Service Worker + Push API + Notification API + VAPID keys), CometChat dashboard PushPlatform configuration, server-side webhook to send pushes when a message arrives, click-through to chat, foreground vs background handling, iOS Safari 16.4+ PWA-only quirks, and HTTPS requirements.
4
+ license: "MIT"
5
+ compatibility: "React >= 18; Web Push API (Chrome 50+, Firefox 44+, Edge 17+, Safari 16+ desktop, Safari 16.4+ iOS PWA-only); HTTPS required (or localhost); CometChat dashboard PushPlatform configured"
6
+ allowed-tools: "shell, file-read, file-search, file-list, ask-user"
7
+ metadata:
8
+ author: "CometChat"
9
+ version: "4.0.0"
10
+ tags: "cometchat react web push notifications service-worker vapid push-api notification-api ios-safari-pwa nextjs astro react-router"
11
+ ---
12
+
13
+ ## Purpose
14
+
15
+ Web Push for CometChat chat. The web has no native VoIP-push equivalent for incoming-call ringing (see `cometchat-react-calls/references/voip-and-web-push.md` for that limit), but it does have **Web Push** for new-message notifications when the user's tab is backgrounded or closed. This skill wires the full path: client subscription → server webhook → push send → notification → click-through.
16
+
17
+ **Not the same as the calls Web Push.** Calls Web Push tries to ring the device through a closed tab (best-effort, browser-dependent). Chat Web Push notifies on new messages — fundamentally similar plumbing, different payload + UX. Many apps need both.
18
+
19
+ **Read these other skills first:**
20
+ - `cometchat-core` — provider pattern, login order
21
+ - `cometchat-{react,nextjs,react-router,astro}-patterns` — framework-specific Service Worker registration
22
+ - `cometchat-react-calls/references/voip-and-web-push.md` — calls-specific Web Push (overlap with this; both can coexist)
23
+ - `cometchat-production` — server-minted auth tokens (push payloads should NOT contain Auth Key)
24
+
25
+ **Ground truth:**
26
+ - Web Push spec — https://datatracker.ietf.org/doc/html/rfc8030
27
+ - VAPID — https://datatracker.ietf.org/doc/html/rfc8292
28
+ - Push API — https://developer.mozilla.org/en-US/docs/Web/API/Push_API
29
+ - CometChat dashboard `PushNotifications` (formerly Extensions → Enhanced Push Notifications)
30
+
31
+ ---
32
+
33
+ ## 1. Architecture
34
+
35
+ ```
36
+ Browser (your React app)
37
+ ├── Service Worker — long-lived; receives push events
38
+ ├── Push subscription — issued by browser, sent to your server
39
+ └── Notification UI — fired by SW on push event
40
+
41
+ CometChat backend
42
+ └── Webhook → your push server when a message is sent
43
+
44
+ Your push server (Node, Cloudflare Worker, Lambda, etc.)
45
+ ├── Stores push subscriptions per UID
46
+ ├── Receives CometChat webhook
47
+ └── Sends push payload via web-push lib → browser
48
+ ```
49
+
50
+ Three pieces, all yours: client SW, push server, webhook integration. CometChat doesn't host the push server for you — its dashboard's "PushPlatform" config is for FCM/APNs (mobile), not Web Push.
51
+
52
+ ---
53
+
54
+ ## 2. Generate VAPID keys (server-side, one-time)
55
+
56
+ VAPID = Voluntary Application Server Identification — proves to the browser that the push originated from an authorized server.
57
+
58
+ ```bash
59
+ npx web-push generate-vapid-keys
60
+ ```
61
+
62
+ Output:
63
+ ```
64
+ =======================================
65
+ Public Key: BLBz-...
66
+ Private Key: 9tT...
67
+ =======================================
68
+ ```
69
+
70
+ Public key → client (env var). Private key → push server only (never ship to client).
71
+
72
+ ---
73
+
74
+ ## 3. Service Worker
75
+
76
+ ### `public/sw.js` (Vite / CRA / React Router) or `app/sw.js` (Next.js / Astro)
77
+
78
+ ```js
79
+ // Fired when a push payload arrives
80
+ self.addEventListener("push", (event) => {
81
+ if (!event.data) return;
82
+
83
+ let payload;
84
+ try {
85
+ payload = event.data.json();
86
+ } catch {
87
+ return;
88
+ }
89
+
90
+ if (payload.type !== "new_message") return;
91
+
92
+ event.waitUntil(
93
+ self.registration.showNotification(payload.senderName, {
94
+ body: payload.preview, // truncated message
95
+ icon: payload.senderAvatar ?? "/icons/chat.png",
96
+ tag: `chat-${payload.conversationId}`, // dedupe — replace prior unread for same conversation
97
+ badge: "/icons/badge.png",
98
+ data: {
99
+ conversationId: payload.conversationId,
100
+ senderUid: payload.senderUid,
101
+ receiverType: payload.receiverType, // "user" or "group"
102
+ },
103
+ }),
104
+ );
105
+ });
106
+
107
+ // Fired when user clicks the notification
108
+ self.addEventListener("notificationclick", (event) => {
109
+ event.notification.close();
110
+
111
+ const data = event.notification.data;
112
+ const targetUrl = data.receiverType === "group"
113
+ ? `/messages?group=${data.conversationId}`
114
+ : `/messages?user=${data.senderUid}`;
115
+
116
+ event.waitUntil(
117
+ clients.matchAll({ type: "window", includeUncontrolled: true }).then((wins) => {
118
+ // Focus existing tab if open
119
+ for (const w of wins) {
120
+ if (w.url.includes(self.registration.scope)) {
121
+ w.focus();
122
+ w.postMessage({ type: "open_conversation", ...data });
123
+ return;
124
+ }
125
+ }
126
+ // Otherwise open a new tab
127
+ return clients.openWindow(targetUrl);
128
+ }),
129
+ );
130
+ });
131
+
132
+ // Optional: fired when a notification is dismissed without click
133
+ self.addEventListener("notificationclose", (event) => {
134
+ // Send a "dismissed" beacon to your server if you track this
135
+ });
136
+ ```
137
+
138
+ ---
139
+
140
+ ## 4. Client-side registration
141
+
142
+ ```ts
143
+ // cometchat/registerWebPush.ts
144
+ const VAPID_PUBLIC = import.meta.env.VITE_VAPID_PUBLIC_KEY; // adjust prefix per framework
145
+
146
+ export async function registerWebPushForChat(uid: string): Promise<void> {
147
+ if (!("serviceWorker" in navigator) || !("PushManager" in window)) return;
148
+
149
+ // Register the SW (one-time per origin)
150
+ const reg = await navigator.serviceWorker.register("/sw.js");
151
+
152
+ // Wait for SW activation
153
+ await navigator.serviceWorker.ready;
154
+
155
+ // Ask permission — must be in response to a user gesture (click)
156
+ const permission = await Notification.requestPermission();
157
+ if (permission !== "granted") return;
158
+
159
+ // Get or create subscription
160
+ let subscription = await reg.pushManager.getSubscription();
161
+ if (!subscription) {
162
+ subscription = await reg.pushManager.subscribe({
163
+ userVisibleOnly: true, // required by Chrome
164
+ applicationServerKey: urlBase64ToUint8Array(VAPID_PUBLIC),
165
+ });
166
+ }
167
+
168
+ // Send subscription to YOUR push server, keyed by uid
169
+ await fetch("/api/push/subscribe", {
170
+ method: "POST",
171
+ headers: { "Content-Type": "application/json" },
172
+ body: JSON.stringify({ uid, subscription }),
173
+ });
174
+ }
175
+
176
+ function urlBase64ToUint8Array(base64: string): Uint8Array {
177
+ const padding = "=".repeat((4 - (base64.length % 4)) % 4);
178
+ const raw = atob((base64 + padding).replace(/-/g, "+").replace(/_/g, "/"));
179
+ return Uint8Array.from(raw, (c) => c.charCodeAt(0));
180
+ }
181
+ ```
182
+
183
+ Call this from your CometChatProvider AFTER login resolves:
184
+
185
+ ```tsx
186
+ // CometChatProvider.tsx
187
+ useEffect(() => {
188
+ if (!user) return;
189
+ registerWebPushForChat(user.uid).catch((err) => {
190
+ // surface to UI but don't block chat — push is opt-in
191
+ console.warn("Web Push registration failed:", err);
192
+ });
193
+ }, [user]);
194
+ ```
195
+
196
+ **The permission prompt rule:** Chrome / Firefox / Safari all require permission requests in response to a user gesture. If you call `Notification.requestPermission()` from a top-level `useEffect` that runs on page load, browsers reject it. Best pattern: a "Enable notifications" button the user clicks once.
197
+
198
+ ---
199
+
200
+ ## 5. Listen for SW messages in the React app
201
+
202
+ ```tsx
203
+ // CometChatProvider.tsx
204
+ useEffect(() => {
205
+ if (!("serviceWorker" in navigator)) return;
206
+
207
+ const handler = (event: MessageEvent) => {
208
+ if (event.data?.type === "open_conversation") {
209
+ navigate(`/messages?${event.data.receiverType}=${event.data.conversationId}`);
210
+ }
211
+ };
212
+ navigator.serviceWorker.addEventListener("message", handler);
213
+ return () => navigator.serviceWorker.removeEventListener("message", handler);
214
+ }, [navigate]);
215
+ ```
216
+
217
+ When the SW posts `open_conversation`, the React app navigates to the right thread.
218
+
219
+ ---
220
+
221
+ ## 6. Server-side push send
222
+
223
+ Your push server runs on Node.js / Cloudflare Worker / Lambda / Vercel Functions. The shape:
224
+
225
+ ```ts
226
+ // server/push.ts
227
+ import express from "express";
228
+ import webpush from "web-push";
229
+ import { z } from "zod";
230
+
231
+ webpush.setVapidDetails(
232
+ "mailto:notifications@yourapp.com",
233
+ process.env.VAPID_PUBLIC!,
234
+ process.env.VAPID_PRIVATE!,
235
+ );
236
+
237
+ const app = express();
238
+ app.use(express.json());
239
+
240
+ // 1. Client registers a subscription
241
+ app.post("/api/push/subscribe", async (req, res) => {
242
+ const { uid, subscription } = req.body; // validate with zod in production
243
+ await db.savePushSubscription(uid, subscription);
244
+ res.status(204).send();
245
+ });
246
+
247
+ // 2. CometChat fires a webhook when a message is sent
248
+ app.post("/webhook/cometchat/message-sent", async (req, res) => {
249
+ const { receiver, sender, data } = req.body.data;
250
+
251
+ // Don't notify the sender — they sent the message
252
+ const subs = await db.getPushSubscriptions(receiver);
253
+ if (!subs.length) return res.status(204).send();
254
+
255
+ const payload = JSON.stringify({
256
+ type: "new_message",
257
+ conversationId: receiver,
258
+ senderUid: sender.uid,
259
+ senderName: sender.name,
260
+ senderAvatar: sender.avatar,
261
+ preview: truncate(data.text, 80),
262
+ receiverType: data.entityType, // "user" or "group"
263
+ });
264
+
265
+ // Send to all of receiver's subscriptions in parallel; clean up dead ones
266
+ await Promise.allSettled(
267
+ subs.map(async (sub) => {
268
+ try {
269
+ await webpush.sendNotification(sub, payload);
270
+ } catch (err: unknown) {
271
+ if ((err as { statusCode?: number }).statusCode === 410) {
272
+ await db.removePushSubscription(receiver, sub); // browser unsubscribed
273
+ }
274
+ }
275
+ }),
276
+ );
277
+
278
+ res.status(204).send();
279
+ });
280
+
281
+ function truncate(s: string, n: number) {
282
+ return s.length <= n ? s : s.slice(0, n - 1) + "…";
283
+ }
284
+
285
+ app.listen(3000);
286
+ ```
287
+
288
+ The skill writes a starter version of this server file (`server/push.example.ts`) with a README pointing at env vars; the user owns the actual deployment.
289
+
290
+ ---
291
+
292
+ ## 7. CometChat webhook setup (manual)
293
+
294
+ In the CometChat dashboard:
295
+
296
+ 1. Navigate to **Webhooks**.
297
+ 2. Click **+ Webhook**.
298
+ 3. URL: `https://your-push-server.example.com/webhook/cometchat/message-sent`
299
+ 4. Trigger: **Message sent**
300
+ 5. Verification: copy the signing secret to your push server's env (`COMETCHAT_WEBHOOK_SECRET`).
301
+
302
+ The webhook fires for EVERY message — your server filters out the sender, dedupes per conversation, and respects user notification preferences.
303
+
304
+ ---
305
+
306
+ ## 8. Webhook signature verification
307
+
308
+ ```ts
309
+ import crypto from "crypto";
310
+
311
+ app.use("/webhook/cometchat", (req, res, next) => {
312
+ const signature = req.header("x-cometchat-signature");
313
+ const expected = crypto
314
+ .createHmac("sha256", process.env.COMETCHAT_WEBHOOK_SECRET!)
315
+ .update(JSON.stringify(req.body))
316
+ .digest("hex");
317
+ if (signature !== expected) return res.status(401).send({ error: "invalid signature" });
318
+ next();
319
+ });
320
+ ```
321
+
322
+ Without this, anyone with your endpoint URL can flood your users with fake notifications.
323
+
324
+ ---
325
+
326
+ ## 9. Browser support matrix + iOS PWA caveat
327
+
328
+ | Browser | Web Push | Notification while closed | Notes |
329
+ |---|---|---|---|
330
+ | Chrome desktop | ✓ | ✓ if Chrome process alive | Service Worker terminates after ~30s idle |
331
+ | Edge desktop | ✓ | ✓ | Same as Chrome |
332
+ | Firefox desktop | ✓ | ✓ | Slightly more SW survival |
333
+ | Safari 16+ desktop | ✓ | ✓ if Safari running | macOS 13+ |
334
+ | Safari 16.4+ iOS | ✓ | **Only when added to Home Screen as PWA** | Critical caveat |
335
+ | Chrome mobile | ✓ | ✓ | Aggressive throttling on Android |
336
+ | Edge mobile | ✓ | ✓ | Same as Chrome mobile |
337
+
338
+ **iOS PWA-only requirement:** iOS 16.4+ supports Web Push, but ONLY for sites added to the Home Screen as a PWA. Safari-the-browser-app does NOT receive Web Push. To unlock iOS Web Push:
339
+
340
+ 1. App must have a `manifest.json` (PWA manifest)
341
+ 2. User must use Safari → Share → "Add to Home Screen"
342
+ 3. Subsequent push subscriptions and notifications work as expected
343
+
344
+ This is a real production constraint. The skill detects whether the project ships a `manifest.json` and warns if not.
345
+
346
+ ---
347
+
348
+ ## 10. Framework-specific Service Worker registration
349
+
350
+ ### Vite / React (CRA)
351
+
352
+ `public/sw.js` is served from `/sw.js`. `register("/sw.js")` works directly.
353
+
354
+ ### Next.js (App Router)
355
+
356
+ Service Workers + Next.js have a known gotcha: the SW can't be inside `app/` because Next handles those routes. Place it in `public/sw.js` and serve from `/sw.js`. Register from a `"use client"` component that runs after hydration.
357
+
358
+ ### Next.js (Pages Router)
359
+
360
+ Same — `public/sw.js`.
361
+
362
+ ### React Router
363
+
364
+ `public/sw.js` works. If using SSR (loaders), the SW registration code must be guarded by `typeof window !== "undefined"`.
365
+
366
+ ### Astro
367
+
368
+ Place the SW at `public/sw.js`. Register from a `client:only="react"` island.
369
+
370
+ The framework-specific patterns skills cover the SSR guards in detail.
371
+
372
+ ---
373
+
374
+ ## 11. HTTPS requirement
375
+
376
+ Service Workers + Push API both require HTTPS (or `localhost` for dev). The skill detects the dev server protocol and warns:
377
+
378
+ ```
379
+ ⚠️ Web Push requires HTTPS or localhost. Your dev server is running on http://192.168.x.x.
380
+ Web Push subscriptions will fail. Either:
381
+ - Use http://localhost (Chrome/Firefox/Safari all allow Push API on localhost), or
382
+ - Set up HTTPS dev (mkcert, ngrok, or Vite's --https flag)
383
+ ```
384
+
385
+ For production, the Vercel / Netlify / Cloudflare default deploys are HTTPS — no extra work.
386
+
387
+ ---
388
+
389
+ ## 12. Anti-patterns
390
+
391
+ 1. **Calling `Notification.requestPermission()` on page load.** Browsers reject this. Wire to a user-clicked "Enable notifications" button.
392
+ 2. **Sending the Auth Key in push payloads.** Push payloads are visible in the SW; never include credentials. Use the user's UID as a key into your server's session store.
393
+ 3. **Missing webhook signature verification.** Without HMAC verification, anyone with the URL can spoof notifications.
394
+ 4. **Showing notifications even when the chat tab is open.** Check `clients.matchAll()` from the SW and skip if the user already has the chat focused.
395
+ 5. **Skipping the iOS PWA warning.** iOS users will silently get nothing. The skill explicitly tells them to "Add to Home Screen."
396
+ 6. **Service Worker registered before login completes.** Race conditions where the subscription exists but the server doesn't know whose UID it belongs to. Register from inside the auth state effect.
397
+ 7. **Forgetting subscription cleanup on logout.** The previous user's subscription keeps notifying them with the new user's messages. Call `subscription.unsubscribe()` and DELETE the server record on logout.
398
+
399
+ ---
400
+
401
+ ## 13. Logout cleanup
402
+
403
+ ```ts
404
+ async function unsubscribeWebPush(uid: string): Promise<void> {
405
+ const reg = await navigator.serviceWorker.getRegistration();
406
+ if (!reg) return;
407
+ const subscription = await reg.pushManager.getSubscription();
408
+ if (!subscription) return;
409
+
410
+ await fetch("/api/push/unsubscribe", {
411
+ method: "POST",
412
+ headers: { "Content-Type": "application/json" },
413
+ body: JSON.stringify({ uid, subscription }),
414
+ });
415
+ await subscription.unsubscribe();
416
+ }
417
+ ```
418
+
419
+ Call this from your logout flow before `CometChat.logout()`.
420
+
421
+ ---
422
+
423
+ ## 14. Verification checklist
424
+
425
+ - [ ] `public/sw.js` (or framework equivalent) exists and listens for `push` + `notificationclick` events
426
+ - [ ] VAPID public key in client env vars (correct framework prefix)
427
+ - [ ] VAPID private key in server env, NOT client
428
+ - [ ] `Notification.requestPermission()` triggered from a user gesture, not page load
429
+ - [ ] Push subscription registered AFTER login resolves
430
+ - [ ] Subscription POSTed to your push server, keyed by CometChat UID
431
+ - [ ] CometChat dashboard webhook configured for `Message sent` events
432
+ - [ ] Webhook signature verification on the push server (HMAC SHA256)
433
+ - [ ] Notifications dedupe per conversation via `tag` field
434
+ - [ ] `notificationclick` focuses existing tab via `clients.matchAll` OR opens new tab
435
+ - [ ] Foreground tab does NOT show notifications (check tab focus before `showNotification`)
436
+ - [ ] Logout flow calls `subscription.unsubscribe()` and deletes server record
437
+ - [ ] HTTPS or localhost only (warned otherwise)
438
+ - [ ] `manifest.json` shipped if iOS users are expected (PWA caveat)
439
+ - [ ] Server cleanup of dead subscriptions on 410 response
440
+
441
+ ---
442
+
443
+ ## 15. Pointers
444
+
445
+ - `cometchat-react-calls/references/voip-and-web-push.md` — Web Push for incoming calls (overlap; both can coexist on the same SW)
446
+ - `cometchat-{react,nextjs,react-router,astro}-patterns` — framework-specific SSR handling
447
+ - `cometchat-production` — auth tokens, security
448
+ - `cometchat-troubleshooting` — Web Push debugging (chrome://serviceworker-internals, Firefox about:debugging)
@@ -3,7 +3,7 @@ name: cometchat-react-router-patterns
3
3
  description: "Framework-specific patterns for integrating CometChat React UI Kit v6 into React Router projects (v6 library mode and v7 framework mode). Covers SSR prevention, routing patterns, outlet nesting, and common pitfalls."
4
4
  license: "MIT"
5
5
  compatibility: "Node.js >=18; React >=18; react-router-dom ^6 or react-router ^7; @cometchat/chat-uikit-react ^6; @cometchat/chat-sdk-javascript ^4"
6
- allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
6
+ allowed-tools: "shell, file-read, file-search, file-list"
7
7
  metadata:
8
8
  author: "CometChat"
9
9
  version: "3.0.0"