@cometchat/skills 4.4.2 → 5.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/.claude-plugin/marketplace.json +55 -0
- package/.claude-plugin/plugin.json +14 -0
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +41 -163
- package/RULES.md +114 -0
- package/bin/cometchat-skills.mjs +1180 -0
- package/bin/legacy-skills.json +95 -0
- package/catalogs/android-v6.json +1646 -0
- package/catalogs/flutter-v6.json +651 -0
- package/catalogs/ios-v5.json +1383 -0
- package/catalogs/rn-calls-v5.json +134 -0
- package/catalogs/rn-calls-v5.symbols.txt +58 -0
- package/catalogs/rn-sdk-v4.json +672 -0
- package/catalogs/rn-v5.json +449 -0
- package/catalogs/rn-v5.symbols.txt +216 -0
- package/catalogs/sdk-android-v5.json +514 -0
- package/contracts.android-calls-v5.json +122 -0
- package/contracts.android-v6.json +135 -0
- package/contracts.angular-v5.json +694 -0
- package/contracts.flutter-calls-v5.json +77 -0
- package/contracts.flutter-v6.json +126 -0
- package/contracts.ios-calls-v5.json +67 -0
- package/contracts.ios-v5.json +436 -0
- package/contracts.json +82 -0
- package/contracts.rn-calls-v5.json +77 -0
- package/contracts.rn-v5.json +727 -0
- package/contracts.sdk-android-v5.json +15 -0
- package/contracts.web-calls-v5.json +45 -0
- package/features.android-calls-v5.json +246 -0
- package/features.android-v6.json +65 -0
- package/features.angular-v5.json +521 -0
- package/features.flutter-calls-v5.json +286 -0
- package/features.flutter-v6.json +484 -0
- package/features.ios-calls-v5.json +236 -0
- package/features.ios-v5.json +573 -0
- package/features.json +61 -0
- package/features.rn-calls-v5.json +187 -0
- package/features.rn-v5.json +614 -0
- package/features.sdk-android-v5.json +40 -0
- package/features.sdk-jsv4.json +24 -0
- package/features.web-calls-v5.json +108 -0
- package/package.json +151 -74
- package/peers.yaml +312 -0
- package/registry/README.md +31 -0
- package/registry/android-calls-v5.json +54 -0
- package/registry/android-v6.json +137 -0
- package/registry/angular-v5.json +114 -0
- package/registry/flutter-calls-v5.json +54 -0
- package/registry/flutter-v6.json +119 -0
- package/registry/ios-calls-v5.json +59 -0
- package/registry/ios-v5.json +97 -0
- package/registry/rn-calls-v5.json +59 -0
- package/registry/rn-v5.json +129 -0
- package/registry/sdk-android-v5.json +53 -0
- package/registry/sdk-jsv4.json +53 -0
- package/registry/web-calls-v5.json +54 -0
- package/registry/web-v7.json +99 -0
- package/skills/cometchat/SKILL.md +42 -2096
- package/skills/cometchat-android-v5-calls-sdk/SKILL.md +206 -0
- package/skills/cometchat-android-v5-calls-sdk/references/build-truth.md +63 -0
- package/skills/cometchat-android-v5-calls-sdk/references/docs-map.md +119 -0
- package/skills/cometchat-android-v5-calls-sdk/references/method-map.md +53 -0
- package/skills/cometchat-android-v5-calls-sdk/references/pitfalls.md +72 -0
- package/skills/cometchat-android-v5-calls-sdk/references/ringing.md +92 -0
- package/skills/cometchat-android-v5-calls-sdk/references/user-switch.md +90 -0
- package/skills/cometchat-android-v5-sdk/SKILL.md +127 -0
- package/skills/cometchat-android-v5-sdk/references/app-surface.md +88 -0
- package/skills/cometchat-android-v5-sdk/references/docs-map.md +91 -0
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +51 -137
- package/skills/cometchat-android-v6-calls/SKILL.md +128 -413
- package/skills/cometchat-android-v6-compose-components/SKILL.md +84 -194
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +66 -411
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +154 -237
- package/skills/cometchat-android-v6-core/SKILL.md +236 -672
- package/skills/cometchat-android-v6-core/references/anti-patterns.md +31 -0
- package/skills/cometchat-android-v6-core/references/component-props.md +168 -0
- package/skills/cometchat-android-v6-core/references/docs-map.md +153 -0
- package/skills/cometchat-android-v6-core/references/layout.md +112 -0
- package/skills/cometchat-android-v6-core/references/lifecycle.md +75 -0
- package/skills/cometchat-android-v6-core/references/setup-credentials.md +105 -0
- package/skills/cometchat-android-v6-core/references/troubleshooting.md +36 -0
- package/skills/cometchat-android-v6-events/SKILL.md +46 -184
- package/skills/cometchat-android-v6-extensions/SKILL.md +39 -179
- package/skills/cometchat-android-v6-features/SKILL.md +74 -143
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +75 -193
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +67 -419
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +77 -223
- package/skills/cometchat-android-v6-migration/SKILL.md +67 -378
- package/skills/cometchat-android-v6-production/SKILL.md +40 -179
- package/skills/cometchat-android-v6-push/SKILL.md +39 -289
- package/skills/cometchat-android-v6-testing/SKILL.md +50 -265
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +70 -254
- package/skills/cometchat-angular-v5-calls/SKILL.md +193 -0
- package/skills/cometchat-angular-v5-components/SKILL.md +131 -0
- package/skills/cometchat-angular-v5-components/references/catalog.md +111 -0
- package/skills/cometchat-angular-v5-components/references/host-composed.md +46 -0
- package/skills/cometchat-angular-v5-core/SKILL.md +300 -0
- package/skills/cometchat-angular-v5-core/references/anti-patterns.md +49 -0
- package/skills/cometchat-angular-v5-core/references/component-props.md +55 -0
- package/skills/cometchat-angular-v5-core/references/dependencies.md +66 -0
- package/skills/cometchat-angular-v5-core/references/docs-map.md +132 -0
- package/skills/cometchat-angular-v5-core/references/layout.md +64 -0
- package/skills/cometchat-angular-v5-core/references/lifecycle.md +202 -0
- package/skills/cometchat-angular-v5-core/references/setup-credentials.md +137 -0
- package/skills/cometchat-angular-v5-core/references/theming.md +70 -0
- package/skills/cometchat-angular-v5-core/references/troubleshooting.md +27 -0
- package/skills/cometchat-angular-v5-customization/SKILL.md +94 -0
- package/skills/cometchat-angular-v5-features/SKILL.md +107 -0
- package/skills/cometchat-angular-v5-features/references/custom-messages.md +133 -0
- package/skills/cometchat-angular-v5-features/references/formatters.md +28 -0
- package/skills/cometchat-angular-v5-features/references/host-composed-extensions.md +85 -0
- package/skills/cometchat-angular-v5-migration/SKILL.md +40 -0
- package/skills/cometchat-angular-v5-migration/references/migration-guide.md +165 -0
- package/skills/cometchat-angular-v5-patterns/SKILL.md +107 -0
- package/skills/cometchat-angular-v5-placement/SKILL.md +133 -0
- package/skills/cometchat-angular-v5-placement/references/combined-app.md +174 -0
- package/skills/cometchat-angular-v5-placement/references/core-surface.md +199 -0
- package/skills/cometchat-angular-v5-production/SKILL.md +101 -0
- package/skills/cometchat-angular-v5-push/SKILL.md +61 -0
- package/skills/cometchat-angular-v5-testing/SKILL.md +112 -0
- package/skills/cometchat-angular-v5-troubleshooting/SKILL.md +96 -0
- package/skills/cometchat-flutter-v5-sdk/SKILL.md +188 -0
- package/skills/cometchat-flutter-v5-sdk/references/doc-corrections.md +55 -0
- package/skills/cometchat-flutter-v5-sdk/references/docs-map.md +211 -0
- package/skills/cometchat-flutter-v5-sdk/references/platform-notes.md +48 -0
- package/skills/cometchat-flutter-v5-sdk/references/transcription.md +87 -0
- package/skills/cometchat-flutter-v6-calls/SKILL.md +75 -389
- package/skills/cometchat-flutter-v6-components/SKILL.md +88 -361
- package/skills/cometchat-flutter-v6-core/SKILL.md +154 -593
- package/skills/cometchat-flutter-v6-core/references/anti-patterns.md +55 -0
- package/skills/cometchat-flutter-v6-core/references/docs-map.md +143 -0
- package/skills/cometchat-flutter-v6-core/references/layout.md +45 -0
- package/skills/cometchat-flutter-v6-core/references/lifecycle.md +87 -0
- package/skills/cometchat-flutter-v6-core/references/setup-credentials.md +84 -0
- package/skills/cometchat-flutter-v6-core/references/troubleshooting.md +26 -0
- package/skills/cometchat-flutter-v6-customization/SKILL.md +70 -712
- package/skills/cometchat-flutter-v6-events/SKILL.md +79 -174
- package/skills/cometchat-flutter-v6-features/SKILL.md +55 -394
- package/skills/cometchat-flutter-v6-migration/SKILL.md +68 -367
- package/skills/cometchat-flutter-v6-migration/references/migration-guide.md +131 -0
- package/skills/cometchat-flutter-v6-patterns/SKILL.md +61 -0
- package/skills/cometchat-flutter-v6-placement/SKILL.md +94 -381
- package/skills/cometchat-flutter-v6-production/SKILL.md +58 -615
- package/skills/cometchat-flutter-v6-push/SKILL.md +46 -455
- package/skills/cometchat-flutter-v6-testing/SKILL.md +68 -299
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +54 -878
- package/skills/cometchat-ios-calls/SKILL.md +112 -563
- package/skills/cometchat-ios-components/SKILL.md +44 -834
- package/skills/cometchat-ios-core/SKILL.md +181 -1068
- package/skills/cometchat-ios-core/references/anti-patterns.md +80 -0
- package/skills/cometchat-ios-core/references/docs-map.md +123 -0
- package/skills/cometchat-ios-core/references/install.md +23 -0
- package/skills/cometchat-ios-core/references/layout.md +186 -0
- package/skills/cometchat-ios-core/references/setup-credentials.md +197 -0
- package/skills/cometchat-ios-core/references/swiftui.md +91 -0
- package/skills/cometchat-ios-core/references/troubleshooting.md +100 -0
- package/skills/cometchat-ios-customization/SKILL.md +33 -968
- package/skills/cometchat-ios-features/SKILL.md +29 -738
- package/skills/cometchat-ios-migration/SKILL.md +39 -0
- package/skills/cometchat-ios-placement/SKILL.md +51 -729
- package/skills/cometchat-ios-push/SKILL.md +24 -602
- package/skills/cometchat-ios-v5-sdk/SKILL.md +161 -0
- package/skills/cometchat-ios-v5-sdk/references/docs-map.md +326 -0
- package/skills/cometchat-js-v5-sdk/SKILL.md +95 -0
- package/skills/cometchat-js-v5-sdk/references/docs-map.md +114 -0
- package/skills/cometchat-onboarding/SKILL.md +89 -0
- package/skills/cometchat-onboarding/references/archetypes.md +51 -0
- package/skills/cometchat-onboarding/references/calling-first.md +77 -0
- package/skills/cometchat-onboarding/references/not-in-this-pack.md +8 -0
- package/skills/cometchat-onboarding/references/plan-artifact.md +133 -0
- package/skills/cometchat-onboarding/references/platforms.md +90 -0
- package/skills/cometchat-react-native-bare-patterns/SKILL.md +120 -0
- package/skills/cometchat-react-native-calls/SKILL.md +200 -0
- package/skills/cometchat-react-native-components/SKILL.md +142 -0
- package/skills/cometchat-react-native-core/SKILL.md +313 -0
- package/skills/cometchat-react-native-core/references/anti-patterns.md +79 -0
- package/skills/cometchat-react-native-core/references/component-props.md +105 -0
- package/skills/cometchat-react-native-core/references/dependencies.md +62 -0
- package/skills/cometchat-react-native-core/references/docs-map.md +126 -0
- package/skills/cometchat-react-native-core/references/layout.md +61 -0
- package/skills/cometchat-react-native-core/references/lifecycle.md +64 -0
- package/skills/cometchat-react-native-core/references/setup-credentials.md +39 -0
- package/skills/cometchat-react-native-customization/SKILL.md +198 -0
- package/skills/cometchat-react-native-expo-patterns/SKILL.md +116 -0
- package/skills/cometchat-react-native-features/SKILL.md +122 -0
- package/skills/cometchat-react-native-migration/SKILL.md +103 -0
- package/skills/cometchat-react-native-placement/SKILL.md +158 -0
- package/skills/cometchat-react-native-production/SKILL.md +78 -0
- package/skills/cometchat-react-native-push/SKILL.md +88 -0
- package/skills/cometchat-react-native-sdk/SKILL.md +126 -0
- package/skills/cometchat-react-native-sdk/references/method-map.md +239 -0
- package/skills/cometchat-react-native-sdk/references/page-map.md +96 -0
- package/skills/cometchat-react-native-testing/SKILL.md +94 -0
- package/skills/cometchat-react-native-troubleshooting/SKILL.md +116 -0
- package/skills/cometchat-react-native-v5-sdk/SKILL.md +150 -0
- package/skills/cometchat-react-native-v5-sdk/references/docs-map.md +127 -0
- package/skills/cometchat-react-native-v5-sdk/references/ringing-voip.md +369 -0
- package/skills/cometchat-react-v7-calls/SKILL.md +75 -0
- package/skills/cometchat-react-v7-components/SKILL.md +72 -0
- package/skills/cometchat-react-v7-core/SKILL.md +101 -0
- package/skills/cometchat-react-v7-core/references/anti-patterns.md +19 -0
- package/skills/cometchat-react-v7-core/references/component-props.md +82 -0
- package/skills/cometchat-react-v7-core/references/dependencies.md +23 -0
- package/skills/cometchat-react-v7-core/references/docs-map.md +117 -0
- package/skills/cometchat-react-v7-core/references/i18n-rtl-a11y.md +22 -0
- package/skills/cometchat-react-v7-core/references/layout.md +158 -0
- package/skills/cometchat-react-v7-core/references/lifecycle.md +74 -0
- package/skills/cometchat-react-v7-core/references/setup-credentials.md +58 -0
- package/skills/cometchat-react-v7-core/references/ssr.md +11 -0
- package/skills/cometchat-react-v7-core/references/theming.md +52 -0
- package/skills/cometchat-react-v7-core/references/troubleshooting.md +28 -0
- package/skills/cometchat-react-v7-customization/SKILL.md +84 -0
- package/skills/cometchat-react-v7-features/SKILL.md +92 -0
- package/skills/cometchat-react-v7-migration/SKILL.md +39 -0
- package/skills/cometchat-react-v7-migration/references/migration-guide.md +119 -0
- package/skills/cometchat-react-v7-patterns/SKILL.md +43 -0
- package/skills/cometchat-react-v7-placement/SKILL.md +106 -0
- package/skills/cometchat-react-v7-placement/references/recipes.md +354 -0
- package/skills/cometchat-react-v7-push/SKILL.md +53 -0
- package/test-suite/README.md +70 -0
- package/test-suite/catalogs/android-calls-v5.json +830 -0
- package/test-suite/catalogs/android-calls-v5.symbols.txt +499 -0
- package/test-suite/catalogs/android-v6.json +1646 -0
- package/test-suite/catalogs/android-v6.symbols.txt +298 -0
- package/test-suite/catalogs/angular-v5.json +7587 -0
- package/test-suite/catalogs/flutter-calls-v5.json +196 -0
- package/test-suite/catalogs/flutter-calls-v5.symbols.txt +59 -0
- package/test-suite/catalogs/flutter-v6.json +651 -0
- package/test-suite/catalogs/ios-calls-v5.json +158 -0
- package/test-suite/catalogs/ios-calls-v5.symbols.txt +70 -0
- package/test-suite/catalogs/ios-v5.json +1383 -0
- package/test-suite/catalogs/ios-v5.symbols.txt +699 -0
- package/test-suite/catalogs/rn-calls-v5.json +134 -0
- package/test-suite/catalogs/rn-sdk-v4.json +672 -0
- package/test-suite/catalogs/rn-v5.json +449 -0
- package/test-suite/catalogs/sdk-android-v5.json +514 -0
- package/test-suite/catalogs/sdk-android-v5.symbols.txt +254 -0
- package/test-suite/catalogs/sdk-jsv4.json +800 -0
- package/test-suite/catalogs/web-calls-v5.json +195 -0
- package/test-suite/catalogs/web-v7.json +1243 -0
- package/test-suite/scripts/build-registry.mjs +113 -0
- package/test-suite/scripts/catalog-refresh-dart.mjs +151 -0
- package/test-suite/scripts/catalog-refresh.mjs +100 -0
- package/test-suite/scripts/lint-skills.mjs +909 -0
- package/test-suite/scripts/measure-tokens.mjs +169 -0
- package/test-suite/scripts/typecheck-fences-dart.mjs +437 -0
- package/test-suite/scripts/typecheck-fences-kotlin.mjs +269 -0
- package/test-suite/scripts/typecheck-fences.mjs +206 -0
- package/test-suite/scripts/verify-catalog.mjs +242 -0
- package/test-suite/scripts/verify-contract-fences.mjs +94 -0
- package/test-suite/scripts/verify-detection.mjs +178 -0
- package/test-suite/scripts/verify-docs-base.mjs +91 -0
- package/test-suite/scripts/verify-family-agnostic.mjs +130 -0
- package/test-suite/scripts/verify-golden-path.mjs +138 -0
- package/test-suite/scripts/verify-oracle-components.mjs +133 -0
- package/test-suite/scripts/verify-template-bindings.mjs +148 -0
- package/test-suite/typecheck/angular-v5/package.json +21 -0
- package/test-suite/typecheck/angular-v5/tsconfig.json +21 -0
- package/test-suite/typecheck/flutter-v6/analysis_options.yaml +25 -0
- package/test-suite/typecheck/flutter-v6/pubspec.yaml +21 -0
- package/test-suite/typecheck/web-v7/package.json +18 -0
- package/test-suite/typecheck/web-v7/tsconfig.json +19 -0
- package/bin/install.js +0 -1003
- package/skills/.claude-plugin/marketplace.json +0 -86
- package/skills/cometchat/references/asking-questions.md +0 -48
- package/skills/cometchat-a11y/SKILL.md +0 -477
- package/skills/cometchat-android-v5/SKILL.md +0 -121
- package/skills/cometchat-android-v5-calls/SKILL.md +0 -429
- package/skills/cometchat-android-v5-calls/references/README.md +0 -53
- package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +0 -197
- package/skills/cometchat-android-v5-calls/references/audio-controls.md +0 -91
- package/skills/cometchat-android-v5-calls/references/background-handling.md +0 -168
- package/skills/cometchat-android-v5-calls/references/call-layouts.md +0 -131
- package/skills/cometchat-android-v5-calls/references/call-logs.md +0 -113
- package/skills/cometchat-android-v5-calls/references/call-session.md +0 -274
- package/skills/cometchat-android-v5-calls/references/custom-ui.md +0 -150
- package/skills/cometchat-android-v5-calls/references/event-listeners.md +0 -123
- package/skills/cometchat-android-v5-calls/references/group-calls.md +0 -205
- package/skills/cometchat-android-v5-calls/references/idle-timeout.md +0 -117
- package/skills/cometchat-android-v5-calls/references/in-call-chat.md +0 -134
- package/skills/cometchat-android-v5-calls/references/join-session.md +0 -120
- package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +0 -222
- package/skills/cometchat-android-v5-calls/references/participant-management.md +0 -110
- package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +0 -106
- package/skills/cometchat-android-v5-calls/references/raise-hand.md +0 -248
- package/skills/cometchat-android-v5-calls/references/recording.md +0 -101
- package/skills/cometchat-android-v5-calls/references/ringing-integration.md +0 -152
- package/skills/cometchat-android-v5-calls/references/screen-sharing.md +0 -78
- package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +0 -215
- package/skills/cometchat-android-v5-calls/references/session-settings.md +0 -121
- package/skills/cometchat-android-v5-calls/references/setup.md +0 -137
- package/skills/cometchat-android-v5-calls/references/share-invite.md +0 -156
- package/skills/cometchat-android-v5-calls/references/video-controls.md +0 -87
- package/skills/cometchat-android-v5-calls/references/voip-calling.md +0 -526
- package/skills/cometchat-android-v5-components/SKILL.md +0 -431
- package/skills/cometchat-android-v5-core/SKILL.md +0 -486
- package/skills/cometchat-android-v5-customization/SKILL.md +0 -469
- package/skills/cometchat-android-v5-extensions/SKILL.md +0 -127
- package/skills/cometchat-android-v5-features/SKILL.md +0 -131
- package/skills/cometchat-android-v5-placement/SKILL.md +0 -277
- package/skills/cometchat-android-v5-production/SKILL.md +0 -95
- package/skills/cometchat-android-v5-push/SKILL.md +0 -619
- package/skills/cometchat-android-v5-testing/SKILL.md +0 -188
- package/skills/cometchat-android-v5-theming/SKILL.md +0 -167
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +0 -74
- package/skills/cometchat-android-v6/SKILL.md +0 -108
- package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +0 -97
- package/skills/cometchat-android-v6-calls/references/advanced-features.md +0 -87
- package/skills/cometchat-android-v6-calls/references/call-layouts.md +0 -100
- package/skills/cometchat-android-v6-calls/references/call-session.md +0 -163
- package/skills/cometchat-android-v6-calls/references/device-management.md +0 -172
- package/skills/cometchat-android-v6-calls/references/group-calls.md +0 -191
- package/skills/cometchat-android-v6-calls/references/idle-timeout.md +0 -110
- package/skills/cometchat-android-v6-calls/references/in-call-chat.md +0 -141
- package/skills/cometchat-android-v6-calls/references/raise-hand.md +0 -188
- package/skills/cometchat-android-v6-calls/references/ringing-integration.md +0 -176
- package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +0 -127
- package/skills/cometchat-android-v6-calls/references/share-invite.md +0 -105
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +0 -250
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +0 -233
- package/skills/cometchat-angular-calls/SKILL.md +0 -380
- package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +0 -96
- package/skills/cometchat-angular-calls/references/call-layouts.md +0 -123
- package/skills/cometchat-angular-calls/references/call-session.md +0 -167
- package/skills/cometchat-angular-calls/references/custom-ui.md +0 -239
- package/skills/cometchat-angular-calls/references/device-management.md +0 -154
- package/skills/cometchat-angular-calls/references/group-calls.md +0 -433
- package/skills/cometchat-angular-calls/references/idle-timeout.md +0 -161
- package/skills/cometchat-angular-calls/references/in-call-chat.md +0 -148
- package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +0 -205
- package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +0 -53
- package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +0 -184
- package/skills/cometchat-angular-calls/references/picture-in-picture.md +0 -285
- package/skills/cometchat-angular-calls/references/raise-hand.md +0 -172
- package/skills/cometchat-angular-calls/references/recording-screen-share.md +0 -260
- package/skills/cometchat-angular-calls/references/ringing-integration.md +0 -133
- package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +0 -100
- package/skills/cometchat-angular-calls/references/share-invite.md +0 -122
- package/skills/cometchat-angular-calls/references/virtual-background.md +0 -29
- package/skills/cometchat-angular-components/SKILL.md +0 -235
- package/skills/cometchat-angular-core/SKILL.md +0 -386
- package/skills/cometchat-angular-customization/SKILL.md +0 -616
- package/skills/cometchat-angular-features/SKILL.md +0 -329
- package/skills/cometchat-angular-patterns/SKILL.md +0 -256
- package/skills/cometchat-angular-placement/SKILL.md +0 -314
- package/skills/cometchat-angular-production/SKILL.md +0 -564
- package/skills/cometchat-angular-push/SKILL.md +0 -389
- package/skills/cometchat-angular-testing/SKILL.md +0 -605
- package/skills/cometchat-angular-theming/SKILL.md +0 -290
- package/skills/cometchat-angular-troubleshooting/SKILL.md +0 -364
- package/skills/cometchat-astro-patterns/SKILL.md +0 -708
- package/skills/cometchat-calls/SKILL.md +0 -364
- package/skills/cometchat-calls/references/use-case-broadcast.md +0 -199
- package/skills/cometchat-calls/references/use-case-marketplace.md +0 -157
- package/skills/cometchat-calls/references/use-case-support.md +0 -189
- package/skills/cometchat-calls/references/use-case-team.md +0 -180
- package/skills/cometchat-calls/references/use-case-telehealth.md +0 -153
- package/skills/cometchat-components/SKILL.md +0 -1142
- package/skills/cometchat-core/SKILL.md +0 -1048
- package/skills/cometchat-customization/SKILL.md +0 -580
- package/skills/cometchat-customization/references/component-catalog.md +0 -236
- package/skills/cometchat-features/SKILL.md +0 -861
- package/skills/cometchat-flutter-v5/SKILL.md +0 -173
- package/skills/cometchat-flutter-v5-calls/SKILL.md +0 -455
- package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +0 -193
- package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +0 -103
- package/skills/cometchat-flutter-v5-calls/references/call-session.md +0 -285
- package/skills/cometchat-flutter-v5-calls/references/device-management.md +0 -124
- package/skills/cometchat-flutter-v5-calls/references/group-calls.md +0 -181
- package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +0 -99
- package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +0 -135
- package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +0 -210
- package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +0 -255
- package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +0 -196
- package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +0 -101
- package/skills/cometchat-flutter-v5-calls/references/share-invite.md +0 -148
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +0 -118
- package/skills/cometchat-flutter-v5-core/SKILL.md +0 -239
- package/skills/cometchat-flutter-v5-customization/SKILL.md +0 -358
- package/skills/cometchat-flutter-v5-events/SKILL.md +0 -156
- package/skills/cometchat-flutter-v5-messages/SKILL.md +0 -259
- package/skills/cometchat-flutter-v5-production/SKILL.md +0 -216
- package/skills/cometchat-flutter-v5-push/SKILL.md +0 -285
- package/skills/cometchat-flutter-v5-testing/SKILL.md +0 -401
- package/skills/cometchat-flutter-v5-theming/SKILL.md +0 -161
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +0 -130
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +0 -152
- package/skills/cometchat-flutter-v6/SKILL.md +0 -446
- package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +0 -136
- package/skills/cometchat-flutter-v6-calls/references/advanced-features.md +0 -89
- package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +0 -105
- package/skills/cometchat-flutter-v6-calls/references/call-session.md +0 -229
- package/skills/cometchat-flutter-v6-calls/references/device-management.md +0 -105
- package/skills/cometchat-flutter-v6-calls/references/group-calls.md +0 -190
- package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +0 -88
- package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +0 -125
- package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +0 -275
- package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +0 -171
- package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +0 -93
- package/skills/cometchat-flutter-v6-calls/references/share-invite.md +0 -102
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +0 -238
- package/skills/cometchat-flutter-v6-messages/SKILL.md +0 -384
- package/skills/cometchat-flutter-v6-theming/SKILL.md +0 -293
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +0 -224
- package/skills/cometchat-i18n/SKILL.md +0 -419
- package/skills/cometchat-ios/SKILL.md +0 -325
- package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +0 -181
- package/skills/cometchat-ios-calls/references/audio-modes-and-controls.md +0 -45
- package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +0 -188
- package/skills/cometchat-ios-calls/references/call-layouts.md +0 -76
- package/skills/cometchat-ios-calls/references/call-session.md +0 -218
- package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +0 -357
- package/skills/cometchat-ios-calls/references/custom-ui.md +0 -322
- package/skills/cometchat-ios-calls/references/device-management.md +0 -171
- package/skills/cometchat-ios-calls/references/group-calls.md +0 -359
- package/skills/cometchat-ios-calls/references/idle-timeout.md +0 -184
- package/skills/cometchat-ios-calls/references/in-call-chat.md +0 -179
- package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +0 -196
- package/skills/cometchat-ios-calls/references/picture-in-picture.md +0 -246
- package/skills/cometchat-ios-calls/references/raise-hand.md +0 -26
- package/skills/cometchat-ios-calls/references/recording-screen-share.md +0 -252
- package/skills/cometchat-ios-calls/references/ringing-integration.md +0 -143
- package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +0 -267
- package/skills/cometchat-ios-calls/references/share-invite.md +0 -148
- package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +0 -246
- package/skills/cometchat-ios-calls/references/voip-cert-setup.md +0 -166
- package/skills/cometchat-ios-production/SKILL.md +0 -738
- package/skills/cometchat-ios-testing/SKILL.md +0 -376
- package/skills/cometchat-ios-theming/SKILL.md +0 -667
- package/skills/cometchat-ios-troubleshooting/SKILL.md +0 -1003
- package/skills/cometchat-native-bare-patterns/SKILL.md +0 -550
- package/skills/cometchat-native-calls/SKILL.md +0 -671
- package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +0 -203
- package/skills/cometchat-native-calls/references/call-layouts.md +0 -125
- package/skills/cometchat-native-calls/references/call-session.md +0 -182
- package/skills/cometchat-native-calls/references/custom-ui.md +0 -254
- package/skills/cometchat-native-calls/references/device-management.md +0 -158
- package/skills/cometchat-native-calls/references/expo-vs-bare.md +0 -179
- package/skills/cometchat-native-calls/references/group-calls.md +0 -296
- package/skills/cometchat-native-calls/references/idle-timeout.md +0 -128
- package/skills/cometchat-native-calls/references/in-call-chat.md +0 -145
- package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +0 -72
- package/skills/cometchat-native-calls/references/picture-in-picture.md +0 -276
- package/skills/cometchat-native-calls/references/raise-hand.md +0 -205
- package/skills/cometchat-native-calls/references/recording-screen-share.md +0 -169
- package/skills/cometchat-native-calls/references/ringing-integration.md +0 -118
- package/skills/cometchat-native-calls/references/server-push-bridge.md +0 -135
- package/skills/cometchat-native-calls/references/server-push-payloads.md +0 -193
- package/skills/cometchat-native-calls/references/share-invite.md +0 -146
- package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +0 -319
- package/skills/cometchat-native-components/SKILL.md +0 -628
- package/skills/cometchat-native-core/SKILL.md +0 -679
- package/skills/cometchat-native-customization/SKILL.md +0 -716
- package/skills/cometchat-native-expo-patterns/SKILL.md +0 -552
- package/skills/cometchat-native-features/SKILL.md +0 -638
- package/skills/cometchat-native-placement/SKILL.md +0 -509
- package/skills/cometchat-native-production/SKILL.md +0 -700
- package/skills/cometchat-native-push/SKILL.md +0 -594
- package/skills/cometchat-native-testing/SKILL.md +0 -582
- package/skills/cometchat-native-theming/SKILL.md +0 -681
- package/skills/cometchat-native-troubleshooting/SKILL.md +0 -501
- package/skills/cometchat-nextjs-patterns/SKILL.md +0 -899
- package/skills/cometchat-placement/SKILL.md +0 -1360
- package/skills/cometchat-production/SKILL.md +0 -1027
- package/skills/cometchat-react-calls/SKILL.md +0 -752
- package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +0 -146
- package/skills/cometchat-react-calls/references/call-layouts.md +0 -160
- package/skills/cometchat-react-calls/references/call-session.md +0 -235
- package/skills/cometchat-react-calls/references/custom-ui.md +0 -247
- package/skills/cometchat-react-calls/references/device-management.md +0 -210
- package/skills/cometchat-react-calls/references/group-calls.md +0 -257
- package/skills/cometchat-react-calls/references/idle-timeout.md +0 -188
- package/skills/cometchat-react-calls/references/in-call-chat.md +0 -212
- package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +0 -170
- package/skills/cometchat-react-calls/references/picture-in-picture.md +0 -245
- package/skills/cometchat-react-calls/references/raise-hand.md +0 -238
- package/skills/cometchat-react-calls/references/recording-screen-share.md +0 -144
- package/skills/cometchat-react-calls/references/ringing-integration.md +0 -255
- package/skills/cometchat-react-calls/references/server-web-push-vapid.md +0 -241
- package/skills/cometchat-react-calls/references/share-invite.md +0 -175
- package/skills/cometchat-react-calls/references/testing-calls-on-web.md +0 -216
- package/skills/cometchat-react-calls/references/virtual-background.md +0 -32
- package/skills/cometchat-react-calls/references/voip-and-web-push.md +0 -165
- package/skills/cometchat-react-patterns/SKILL.md +0 -628
- package/skills/cometchat-react-push/SKILL.md +0 -634
- package/skills/cometchat-react-router-patterns/SKILL.md +0 -758
- package/skills/cometchat-react-testing/SKILL.md +0 -413
- package/skills/cometchat-theming/SKILL.md +0 -498
- package/skills/cometchat-troubleshooting/SKILL.md +0 -294
|
@@ -1,634 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: cometchat-react-push
|
|
3
|
-
description: Push notifications for CometChat React UI Kit v6 in Vite / Next.js / React Router / Astro projects. Recommended path is CometChat-native web push via Firebase Cloud Messaging for Web — `CometChatNotifications.registerPushToken(token, PushPlatforms.FCM_WEB)` + a dashboard FCM provider, so CometChat's own backend delivers new-message pushes with NO self-hosted push server. Also documents an optional advanced self-hosted Web Push fallback (Service Worker + Push API + VAPID + message-sent webhook) for projects that can't use Firebase. Covers 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; @cometchat/chat-sdk-javascript ^4.1.10 (ships CometChatNotifications.registerPushToken + PushPlatforms.FCM_WEB); firebase modular SDK for FCM_WEB; Web Push API (Chrome 50+, Firefox 44+, Edge 17+, Safari 16+ desktop, Safari 16.4+ iOS PWA-only); HTTPS required (or localhost)"
|
|
6
|
-
metadata:
|
|
7
|
-
author: "CometChat"
|
|
8
|
-
version: "4.1.0"
|
|
9
|
-
tags: "cometchat react web push notifications fcm-web firebase cometchatnotifications registerpushtoken service-worker vapid push-api notification-api ios-safari-pwa nextjs astro react-router"
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Purpose
|
|
13
|
-
|
|
14
|
-
Web push for CometChat chat — new-message notifications when the user's tab is backgrounded or closed.
|
|
15
|
-
|
|
16
|
-
**The web DOES have CometChat-native push.** The JS Chat SDK ships a first-class web-push registration API: `CometChatNotifications.registerPushToken(token, PushPlatforms.FCM_WEB)`. Paired with a Firebase Cloud Messaging (FCM) provider configured in the CometChat dashboard, **CometChat's own backend delivers the push on every new message** — no self-hosted push server, no `web-push` lib, no VAPID server of your own, and no message-sent webhook for the basic case. This is the recommended path (§1).
|
|
17
|
-
|
|
18
|
-
A self-hosted Web Push path (your own VAPID keys + push server + CometChat webhook) is documented as an advanced fallback (§7) for projects that can't or won't use Firebase. Don't reach for it unless you have to.
|
|
19
|
-
|
|
20
|
-
**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 push notifies on new messages — different payload + UX. Many apps need both.
|
|
21
|
-
|
|
22
|
-
**Read these other skills first:**
|
|
23
|
-
- `cometchat-core` — provider pattern, login order
|
|
24
|
-
- `cometchat-{react,nextjs,react-router,astro}-patterns` — framework-specific Service Worker registration
|
|
25
|
-
- `cometchat-react-calls/references/voip-and-web-push.md` — calls-specific Web Push (overlap with this; both can coexist)
|
|
26
|
-
- `cometchat-production` — server-minted auth tokens
|
|
27
|
-
|
|
28
|
-
**Ground truth (verified against the JS Chat SDK source):** **Official docs:** https://www.cometchat.com/docs/notifications/overview · **Docs MCP:** `claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp` (or fetch the URL directly without MCP).
|
|
29
|
-
- `CometChatNotifications.registerPushToken(pushToken: string, platform: PushPlatforms, providerId?: string): Promise<string>` — `chat-sdk-javascript/src/Notifications/CometChatNotifications.ts:616`
|
|
30
|
-
- `CometChatNotifications.unregisterPushToken(): Promise<string>` — `chat-sdk-javascript/src/Notifications/CometChatNotifications.ts:649`
|
|
31
|
-
- `enum PushPlatforms { FCM_WEB = 'fcm_web' }` — `chat-sdk-javascript/src/Notifications/constants/CometChatNotificationsConstants.ts:46-47`
|
|
32
|
-
- The web kit pins `@cometchat/chat-sdk-javascript ^4.1.10`, which has this API.
|
|
33
|
-
- There is NO `PNPlatform` and NO `PushNotificationOptions` symbol — the real names are `PushPlatforms` and `CometChatNotifications`.
|
|
34
|
-
- Firebase Cloud Messaging for Web — https://firebase.google.com/docs/cloud-messaging/js/client
|
|
35
|
-
- Web Push spec / VAPID / Push API (fallback path only) — RFC 8030, RFC 8292, https://developer.mozilla.org/en-US/docs/Web/API/Push_API
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## 1. Recommended: CometChat-native web push (FCM_WEB)
|
|
40
|
-
|
|
41
|
-
CometChat delivers web push through **Firebase Cloud Messaging for Web**. You register the FCM device token with CometChat via the Chat SDK; CometChat's backend then sends pushes on new messages through your dashboard-configured FCM provider. No push server of yours.
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
Browser (your React app)
|
|
45
|
-
├── firebase/messaging — getToken() → FCM web token
|
|
46
|
-
├── firebase-messaging-sw.js — receives background pushes (onBackgroundMessage)
|
|
47
|
-
└── CometChatNotifications.registerPushToken(token, FCM_WEB) — hands token to CometChat
|
|
48
|
-
|
|
49
|
-
CometChat backend
|
|
50
|
-
└── FCM provider (dashboard) → sends push to the token on every new message
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 1.1 Firebase setup (one-time)
|
|
54
|
-
|
|
55
|
-
1. Create a Firebase project, enable **Cloud Messaging**.
|
|
56
|
-
2. Add a Web app; copy its web SDK config (`apiKey`, `projectId`, `messagingSenderId`, `appId`, …).
|
|
57
|
-
3. Under **Project Settings → Cloud Messaging → Web configuration**, generate a **Web Push certificate**. This key pair is Firebase's own VAPID key — it is consumed by `getToken({ vapidKey })`. It is NOT a self-hosted VAPID server; you don't run any server for it.
|
|
58
|
-
|
|
59
|
-
### 1.2 Install + initialize Firebase
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
npm install firebase
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
// cometchat/firebase.ts
|
|
67
|
-
import { initializeApp } from "firebase/app";
|
|
68
|
-
|
|
69
|
-
export const firebaseApp = initializeApp({
|
|
70
|
-
apiKey: import.meta.env.VITE_FIREBASE_API_KEY, // adjust prefix per framework
|
|
71
|
-
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
|
|
72
|
-
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
|
|
73
|
-
messagingSenderId: import.meta.env.VITE_FIREBASE_SENDER_ID,
|
|
74
|
-
appId: import.meta.env.VITE_FIREBASE_APP_ID,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export const FIREBASE_WEB_PUSH_CERT_KEY = import.meta.env.VITE_FIREBASE_VAPID_KEY; // Web Push certificate key
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### 1.3 Service worker — `public/firebase-messaging-sw.js`
|
|
81
|
-
|
|
82
|
-
The file MUST live at the origin root (`/firebase-messaging-sw.js`) — `getToken` looks for it by default, or pass an explicit `serviceWorkerRegistration`.
|
|
83
|
-
|
|
84
|
-
> **Coexistence check first (P0-10).** If `detect` reported `coexistence.existing_firebase: true` or listed an existing service worker, the project already runs Firebase and/or a SW. Do NOT blindly overwrite: (a) reuse the project's existing Firebase config/app instead of a second `initializeApp` — duplicate apps fight over the FCM token; (b) if a service worker already exists at the origin root (e.g. a PWA/Workbox `sw.js`), **merge** the messaging handlers (`importScripts` + `firebase.initializeApp` + `onBackgroundMessage`) into it rather than replacing it, or register CometChat's worker at a distinct scope and pass it as `serviceWorkerRegistration` to `getToken`. Overwriting the app's worker silently kills its offline/caching logic.
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
// public/firebase-messaging-sw.js
|
|
88
|
-
importScripts("https://www.gstatic.com/firebasejs/10.12.0/firebase-app-compat.js");
|
|
89
|
-
importScripts("https://www.gstatic.com/firebasejs/10.12.0/firebase-messaging-compat.js");
|
|
90
|
-
|
|
91
|
-
firebase.initializeApp({
|
|
92
|
-
apiKey: "…",
|
|
93
|
-
projectId: "…",
|
|
94
|
-
messagingSenderId: "…",
|
|
95
|
-
appId: "…",
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const messaging = firebase.messaging();
|
|
99
|
-
|
|
100
|
-
// Background pushes (tab closed / not focused)
|
|
101
|
-
messaging.onBackgroundMessage((payload) => {
|
|
102
|
-
const { title, body } = payload.notification ?? {};
|
|
103
|
-
self.registration.showNotification(title ?? "New message", {
|
|
104
|
-
body: body ?? "",
|
|
105
|
-
icon: "/icons/chat.png",
|
|
106
|
-
tag: payload.data?.conversationId ? `chat-${payload.data.conversationId}` : undefined,
|
|
107
|
-
data: payload.data ?? {},
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
self.addEventListener("notificationclick", (event) => {
|
|
112
|
-
event.notification.close();
|
|
113
|
-
const data = event.notification.data ?? {};
|
|
114
|
-
const targetUrl = data.receiverType === "group"
|
|
115
|
-
? `/messages?group=${data.conversationId}`
|
|
116
|
-
: `/messages?user=${data.senderUid ?? data.conversationId}`;
|
|
117
|
-
event.waitUntil(
|
|
118
|
-
clients.matchAll({ type: "window", includeUncontrolled: true }).then((wins) => {
|
|
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
|
-
return clients.openWindow(targetUrl);
|
|
127
|
-
}),
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### 1.4 Register the FCM token with CometChat (after login)
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
// cometchat/registerFcmWebPush.ts
|
|
136
|
-
import { getMessaging, getToken, onMessage } from "firebase/messaging";
|
|
137
|
-
import { CometChatNotifications } from "@cometchat/chat-sdk-javascript";
|
|
138
|
-
import { firebaseApp, FIREBASE_WEB_PUSH_CERT_KEY } from "./firebase";
|
|
139
|
-
|
|
140
|
-
export async function registerFcmWebPush(): Promise<void> {
|
|
141
|
-
if (!("serviceWorker" in navigator) || !("Notification" in window)) return;
|
|
142
|
-
|
|
143
|
-
// Permission MUST be requested in response to a user gesture (see §2 rule).
|
|
144
|
-
const permission = await Notification.requestPermission();
|
|
145
|
-
if (permission !== "granted") return;
|
|
146
|
-
|
|
147
|
-
// Register the FCM service worker.
|
|
148
|
-
const swReg = await navigator.serviceWorker.register("/firebase-messaging-sw.js");
|
|
149
|
-
|
|
150
|
-
const messaging = getMessaging(firebaseApp);
|
|
151
|
-
const fcmToken = await getToken(messaging, {
|
|
152
|
-
vapidKey: FIREBASE_WEB_PUSH_CERT_KEY, // Firebase Web Push certificate — NOT a self-hosted VAPID server
|
|
153
|
-
serviceWorkerRegistration: swReg,
|
|
154
|
-
});
|
|
155
|
-
if (!fcmToken) return;
|
|
156
|
-
|
|
157
|
-
// Hand the token to CometChat. Its backend now delivers pushes on new messages.
|
|
158
|
-
await CometChatNotifications.registerPushToken(
|
|
159
|
-
fcmToken,
|
|
160
|
-
CometChatNotifications.PushPlatforms.FCM_WEB,
|
|
161
|
-
/* providerId */ undefined, // omit for "default", or pass your dashboard FCM provider id
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
// Foreground messages (tab focused) don't fire the SW — show them yourself if desired.
|
|
165
|
-
onMessage(messaging, (payload) => {
|
|
166
|
-
if (document.visibilityState === "visible") {
|
|
167
|
-
// e.g. toast / in-app banner instead of an OS notification
|
|
168
|
-
window.dispatchEvent(new CustomEvent("cometchat:foreground-push", { detail: payload }));
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Call it from your provider AFTER `CometChatUIKit.login(...)` resolves:
|
|
175
|
-
|
|
176
|
-
```tsx
|
|
177
|
-
// CometChatProvider.tsx
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
if (!user) return;
|
|
180
|
-
registerFcmWebPush().catch((err) => {
|
|
181
|
-
console.warn("FCM web push registration failed:", err); // never block chat — push is opt-in
|
|
182
|
-
});
|
|
183
|
-
}, [user]);
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### 1.5 Dashboard FCM provider (manual, one-time)
|
|
187
|
-
|
|
188
|
-
In the CometChat dashboard: **Notifications → Push Notifications → Add FCM provider**. Upload the Firebase service-account JSON (or legacy server key) for the same Firebase project. CometChat now sends new-message pushes to every registered `FCM_WEB` token — **no webhook of yours**.
|
|
189
|
-
|
|
190
|
-
### 1.6 Logout — unregister the token
|
|
191
|
-
|
|
192
|
-
```ts
|
|
193
|
-
import { CometChatNotifications } from "@cometchat/chat-sdk-javascript";
|
|
194
|
-
|
|
195
|
-
// Call BEFORE CometChat.logout(), while the auth token is still valid.
|
|
196
|
-
await CometChatNotifications.unregisterPushToken(); // CometChatNotifications.ts:649
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
> **Hard rule — register only AFTER login.** `registerPushToken` operates on the current logged-in user's auth token. Calling it before `CometChatUIKit.login(...)` resolves will fail or attach the token to nobody. Wire it inside the auth-state effect, never on page load.
|
|
200
|
-
|
|
201
|
-
> **Hard rule — `firebase-messaging-sw.js` must be at the origin root.** Place it in `public/` so it serves from `/firebase-messaging-sw.js`. In Next.js it cannot live under `app/`. See §8 for per-framework placement.
|
|
202
|
-
|
|
203
|
-
> **Hard rule — iOS still needs PWA install.** FCM web push on iOS 16.4+ only works for a Home-Screen-installed PWA, exactly like the fallback path. See §9.
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## 2. The permission-prompt rule (applies to both paths)
|
|
208
|
-
|
|
209
|
-
Chrome / Firefox / Safari all require `Notification.requestPermission()` to run in response to a **user gesture** (a click). Calling it from a top-level `useEffect` on page load is rejected. Best pattern: an "Enable notifications" button the user clicks once, which then calls `registerFcmWebPush()` (or the fallback `registerWebPushForChat()`).
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## 3. Alternative / advanced: self-hosted Web Push (no Firebase)
|
|
214
|
-
|
|
215
|
-
> Use this path **only** if you cannot or will not use Firebase (§1). It is more work — you run your own VAPID keys, a push server, and a CometChat message-sent webhook. CometChat's backend does NOT deliver the push for you on this path; your server does. For most apps, prefer §1.
|
|
216
|
-
|
|
217
|
-
### 3.1 Architecture
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
Browser (your React app)
|
|
221
|
-
├── Service Worker — long-lived; receives push events
|
|
222
|
-
├── Push subscription — issued by browser, sent to your server
|
|
223
|
-
└── Notification UI — fired by SW on push event
|
|
224
|
-
|
|
225
|
-
CometChat backend
|
|
226
|
-
└── Webhook → your push server when a message is sent
|
|
227
|
-
|
|
228
|
-
Your push server (Node, Cloudflare Worker, Lambda, etc.)
|
|
229
|
-
├── Stores push subscriptions per UID
|
|
230
|
-
├── Receives CometChat webhook
|
|
231
|
-
└── Sends push payload via web-push lib → browser
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
Three pieces, all yours: client SW, push server, webhook integration.
|
|
235
|
-
|
|
236
|
-
### 3.2 Generate VAPID keys (server-side, one-time)
|
|
237
|
-
|
|
238
|
-
VAPID = Voluntary Application Server Identification — proves to the browser that the push originated from an authorized server.
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
npx web-push generate-vapid-keys
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
Output:
|
|
245
|
-
```
|
|
246
|
-
=======================================
|
|
247
|
-
Public Key: BLBz-...
|
|
248
|
-
Private Key: 9tT...
|
|
249
|
-
=======================================
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
Public key → client (env var). Private key → push server only (never ship to client).
|
|
253
|
-
|
|
254
|
-
### 3.3 Service Worker
|
|
255
|
-
|
|
256
|
-
#### `public/sw.js` (Vite / CRA / React Router) or `app/sw.js` (Next.js / Astro)
|
|
257
|
-
|
|
258
|
-
```js
|
|
259
|
-
// Fired when a push payload arrives
|
|
260
|
-
self.addEventListener("push", (event) => {
|
|
261
|
-
if (!event.data) return;
|
|
262
|
-
|
|
263
|
-
let payload;
|
|
264
|
-
try {
|
|
265
|
-
payload = event.data.json();
|
|
266
|
-
} catch {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (payload.type !== "new_message") return;
|
|
271
|
-
|
|
272
|
-
event.waitUntil(
|
|
273
|
-
self.registration.showNotification(payload.senderName, {
|
|
274
|
-
body: payload.preview, // truncated message
|
|
275
|
-
icon: payload.senderAvatar ?? "/icons/chat.png",
|
|
276
|
-
tag: `chat-${payload.conversationId}`, // dedupe — replace prior unread for same conversation
|
|
277
|
-
badge: "/icons/badge.png",
|
|
278
|
-
data: {
|
|
279
|
-
conversationId: payload.conversationId,
|
|
280
|
-
senderUid: payload.senderUid,
|
|
281
|
-
receiverType: payload.receiverType, // "user" or "group"
|
|
282
|
-
},
|
|
283
|
-
}),
|
|
284
|
-
);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
// Fired when user clicks the notification
|
|
288
|
-
self.addEventListener("notificationclick", (event) => {
|
|
289
|
-
event.notification.close();
|
|
290
|
-
|
|
291
|
-
const data = event.notification.data;
|
|
292
|
-
const targetUrl = data.receiverType === "group"
|
|
293
|
-
? `/messages?group=${data.conversationId}`
|
|
294
|
-
: `/messages?user=${data.senderUid}`;
|
|
295
|
-
|
|
296
|
-
event.waitUntil(
|
|
297
|
-
clients.matchAll({ type: "window", includeUncontrolled: true }).then((wins) => {
|
|
298
|
-
// Focus existing tab if open
|
|
299
|
-
for (const w of wins) {
|
|
300
|
-
if (w.url.includes(self.registration.scope)) {
|
|
301
|
-
w.focus();
|
|
302
|
-
w.postMessage({ type: "open_conversation", ...data });
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
// Otherwise open a new tab
|
|
307
|
-
return clients.openWindow(targetUrl);
|
|
308
|
-
}),
|
|
309
|
-
);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
// Optional: fired when a notification is dismissed without click
|
|
313
|
-
self.addEventListener("notificationclose", (event) => {
|
|
314
|
-
// Send a "dismissed" beacon to your server if you track this
|
|
315
|
-
});
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### 3.4 Client-side registration (self-hosted)
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
// cometchat/registerWebPush.ts
|
|
322
|
-
const VAPID_PUBLIC = import.meta.env.VITE_VAPID_PUBLIC_KEY; // adjust prefix per framework
|
|
323
|
-
|
|
324
|
-
export async function registerWebPushForChat(uid: string): Promise<void> {
|
|
325
|
-
if (!("serviceWorker" in navigator) || !("PushManager" in window)) return;
|
|
326
|
-
|
|
327
|
-
// Register the SW (one-time per origin)
|
|
328
|
-
const reg = await navigator.serviceWorker.register("/sw.js");
|
|
329
|
-
|
|
330
|
-
// Wait for SW activation
|
|
331
|
-
await navigator.serviceWorker.ready;
|
|
332
|
-
|
|
333
|
-
// Ask permission — must be in response to a user gesture (click)
|
|
334
|
-
const permission = await Notification.requestPermission();
|
|
335
|
-
if (permission !== "granted") return;
|
|
336
|
-
|
|
337
|
-
// Get or create subscription
|
|
338
|
-
let subscription = await reg.pushManager.getSubscription();
|
|
339
|
-
if (!subscription) {
|
|
340
|
-
subscription = await reg.pushManager.subscribe({
|
|
341
|
-
userVisibleOnly: true, // required by Chrome
|
|
342
|
-
applicationServerKey: urlBase64ToUint8Array(VAPID_PUBLIC),
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Send subscription to YOUR push server, keyed by uid
|
|
347
|
-
await fetch("/api/push/subscribe", {
|
|
348
|
-
method: "POST",
|
|
349
|
-
headers: { "Content-Type": "application/json" },
|
|
350
|
-
body: JSON.stringify({ uid, subscription }),
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function urlBase64ToUint8Array(base64: string): Uint8Array {
|
|
355
|
-
const padding = "=".repeat((4 - (base64.length % 4)) % 4);
|
|
356
|
-
const raw = atob((base64 + padding).replace(/-/g, "+").replace(/_/g, "/"));
|
|
357
|
-
return Uint8Array.from(raw, (c) => c.charCodeAt(0));
|
|
358
|
-
}
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
Call this from your CometChatProvider AFTER login resolves:
|
|
362
|
-
|
|
363
|
-
```tsx
|
|
364
|
-
// CometChatProvider.tsx
|
|
365
|
-
useEffect(() => {
|
|
366
|
-
if (!user) return;
|
|
367
|
-
registerWebPushForChat(user.uid).catch((err) => {
|
|
368
|
-
// surface to UI but don't block chat — push is opt-in
|
|
369
|
-
console.warn("Web Push registration failed:", err);
|
|
370
|
-
});
|
|
371
|
-
}, [user]);
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
The permission-prompt rule (§2) applies here too — request permission from a user gesture, not page load.
|
|
375
|
-
|
|
376
|
-
### 3.5 Listen for SW messages in the React app
|
|
377
|
-
|
|
378
|
-
```tsx
|
|
379
|
-
// CometChatProvider.tsx
|
|
380
|
-
useEffect(() => {
|
|
381
|
-
if (!("serviceWorker" in navigator)) return;
|
|
382
|
-
|
|
383
|
-
const handler = (event: MessageEvent) => {
|
|
384
|
-
if (event.data?.type === "open_conversation") {
|
|
385
|
-
navigate(`/messages?${event.data.receiverType}=${event.data.conversationId}`);
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
navigator.serviceWorker.addEventListener("message", handler);
|
|
389
|
-
return () => navigator.serviceWorker.removeEventListener("message", handler);
|
|
390
|
-
}, [navigate]);
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
When the SW posts `open_conversation`, the React app navigates to the right thread.
|
|
394
|
-
|
|
395
|
-
### 3.6 Server-side push send
|
|
396
|
-
|
|
397
|
-
Your push server runs on Node.js / Cloudflare Worker / Lambda / Vercel Functions. The shape:
|
|
398
|
-
|
|
399
|
-
```ts
|
|
400
|
-
// server/push.ts
|
|
401
|
-
import express from "express";
|
|
402
|
-
import webpush from "web-push";
|
|
403
|
-
import { z } from "zod";
|
|
404
|
-
|
|
405
|
-
webpush.setVapidDetails(
|
|
406
|
-
"mailto:notifications@yourapp.com",
|
|
407
|
-
process.env.VAPID_PUBLIC!,
|
|
408
|
-
process.env.VAPID_PRIVATE!,
|
|
409
|
-
);
|
|
410
|
-
|
|
411
|
-
const app = express();
|
|
412
|
-
app.use(express.json());
|
|
413
|
-
|
|
414
|
-
// 1. Client registers a subscription
|
|
415
|
-
app.post("/api/push/subscribe", async (req, res) => {
|
|
416
|
-
const { uid, subscription } = req.body; // validate with zod in production
|
|
417
|
-
await db.savePushSubscription(uid, subscription);
|
|
418
|
-
res.status(204).send();
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
// 2. CometChat fires a webhook when a message is sent
|
|
422
|
-
app.post("/webhook/cometchat/message-sent", async (req, res) => {
|
|
423
|
-
const { receiver, sender, data } = req.body.data;
|
|
424
|
-
|
|
425
|
-
// Don't notify the sender — they sent the message
|
|
426
|
-
const subs = await db.getPushSubscriptions(receiver);
|
|
427
|
-
if (!subs.length) return res.status(204).send();
|
|
428
|
-
|
|
429
|
-
const payload = JSON.stringify({
|
|
430
|
-
type: "new_message",
|
|
431
|
-
conversationId: receiver,
|
|
432
|
-
senderUid: sender.uid,
|
|
433
|
-
senderName: sender.name,
|
|
434
|
-
senderAvatar: sender.avatar,
|
|
435
|
-
preview: truncate(data.text, 80),
|
|
436
|
-
receiverType: data.entityType, // "user" or "group"
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
// Send to all of receiver's subscriptions in parallel; clean up dead ones
|
|
440
|
-
await Promise.allSettled(
|
|
441
|
-
subs.map(async (sub) => {
|
|
442
|
-
try {
|
|
443
|
-
await webpush.sendNotification(sub, payload);
|
|
444
|
-
} catch (err: unknown) {
|
|
445
|
-
if ((err as { statusCode?: number }).statusCode === 410) {
|
|
446
|
-
await db.removePushSubscription(receiver, sub); // browser unsubscribed
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}),
|
|
450
|
-
);
|
|
451
|
-
|
|
452
|
-
res.status(204).send();
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
function truncate(s: string, n: number) {
|
|
456
|
-
return s.length <= n ? s : s.slice(0, n - 1) + "…";
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
app.listen(3000);
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
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.
|
|
463
|
-
|
|
464
|
-
### 3.7 CometChat webhook setup (manual)
|
|
465
|
-
|
|
466
|
-
In the CometChat dashboard:
|
|
467
|
-
|
|
468
|
-
1. Navigate to **Webhooks**.
|
|
469
|
-
2. Click **+ Webhook**.
|
|
470
|
-
3. URL: `https://your-push-server.example.com/webhook/cometchat/message-sent`
|
|
471
|
-
4. Trigger: **Message sent**
|
|
472
|
-
5. Verification: copy the signing secret to your push server's env (`COMETCHAT_WEBHOOK_SECRET`).
|
|
473
|
-
|
|
474
|
-
The webhook fires for EVERY message — your server filters out the sender, dedupes per conversation, and respects user notification preferences.
|
|
475
|
-
|
|
476
|
-
### 3.8 Webhook signature verification
|
|
477
|
-
|
|
478
|
-
```ts
|
|
479
|
-
import crypto from "crypto";
|
|
480
|
-
|
|
481
|
-
app.use("/webhook/cometchat", (req, res, next) => {
|
|
482
|
-
const signature = req.header("x-cometchat-signature");
|
|
483
|
-
const expected = crypto
|
|
484
|
-
.createHmac("sha256", process.env.COMETCHAT_WEBHOOK_SECRET!)
|
|
485
|
-
.update(JSON.stringify(req.body))
|
|
486
|
-
.digest("hex");
|
|
487
|
-
if (signature !== expected) return res.status(401).send({ error: "invalid signature" });
|
|
488
|
-
next();
|
|
489
|
-
});
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
Without this, anyone with your endpoint URL can flood your users with fake notifications.
|
|
493
|
-
|
|
494
|
-
---
|
|
495
|
-
|
|
496
|
-
## 4. Browser support matrix + iOS PWA caveat (both paths)
|
|
497
|
-
|
|
498
|
-
| Browser | Web Push | Notification while closed | Notes |
|
|
499
|
-
|---|---|---|---|
|
|
500
|
-
| Chrome desktop | ✓ | ✓ if Chrome process alive | Service Worker terminates after ~30s idle |
|
|
501
|
-
| Edge desktop | ✓ | ✓ | Same as Chrome |
|
|
502
|
-
| Firefox desktop | ✓ | ✓ | Slightly more SW survival |
|
|
503
|
-
| Safari 16+ desktop | ✓ | ✓ if Safari running | macOS 13+ |
|
|
504
|
-
| Safari 16.4+ iOS | ✓ | **Only when added to Home Screen as PWA** | Critical caveat |
|
|
505
|
-
| Chrome mobile | ✓ | ✓ | Aggressive throttling on Android |
|
|
506
|
-
| Edge mobile | ✓ | ✓ | Same as Chrome mobile |
|
|
507
|
-
|
|
508
|
-
**iOS PWA-only requirement (applies to FCM_WEB too):** 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 push. This is platform-level and applies equally to the FCM_WEB path (§1) and the self-hosted path (§3). To unlock iOS web push:
|
|
509
|
-
|
|
510
|
-
1. App must have a `manifest.json` (PWA manifest)
|
|
511
|
-
2. User must use Safari → Share → "Add to Home Screen"
|
|
512
|
-
3. Subsequent push subscriptions and notifications work as expected
|
|
513
|
-
|
|
514
|
-
This is a real production constraint. The skill detects whether the project ships a `manifest.json` and warns if not.
|
|
515
|
-
|
|
516
|
-
---
|
|
517
|
-
|
|
518
|
-
## 5. Framework-specific service worker placement (both paths)
|
|
519
|
-
|
|
520
|
-
The FCM service worker (`firebase-messaging-sw.js`, §1) and the self-hosted SW (`sw.js`, §3) follow the same placement rules.
|
|
521
|
-
|
|
522
|
-
### Vite / React (CRA)
|
|
523
|
-
|
|
524
|
-
`public/firebase-messaging-sw.js` (or `public/sw.js`) is served from the origin root. `register("/firebase-messaging-sw.js")` works directly.
|
|
525
|
-
|
|
526
|
-
### Next.js (App Router)
|
|
527
|
-
|
|
528
|
-
Service Workers + Next.js have a known gotcha: the SW can't be inside `app/` because Next handles those routes. Place it in `public/` and serve from the origin root. Register from a `"use client"` component that runs after hydration.
|
|
529
|
-
|
|
530
|
-
### Next.js (Pages Router)
|
|
531
|
-
|
|
532
|
-
Same — `public/`.
|
|
533
|
-
|
|
534
|
-
### React Router
|
|
535
|
-
|
|
536
|
-
`public/` works. If using SSR (loaders), the SW registration code must be guarded by `typeof window !== "undefined"`.
|
|
537
|
-
|
|
538
|
-
### Astro
|
|
539
|
-
|
|
540
|
-
Place the SW at `public/`. Register from a `client:only="react"` island.
|
|
541
|
-
|
|
542
|
-
The framework-specific patterns skills cover the SSR guards in detail.
|
|
543
|
-
|
|
544
|
-
---
|
|
545
|
-
|
|
546
|
-
## 6. HTTPS requirement (both paths)
|
|
547
|
-
|
|
548
|
-
Service Workers + Push API + FCM all require HTTPS (or `localhost` for dev). The skill detects the dev server protocol and warns:
|
|
549
|
-
|
|
550
|
-
```
|
|
551
|
-
⚠️ Web push requires HTTPS or localhost. Your dev server is running on http://192.168.x.x.
|
|
552
|
-
Push subscriptions will fail. Either:
|
|
553
|
-
- Use http://localhost (Chrome/Firefox/Safari all allow Push API on localhost), or
|
|
554
|
-
- Set up HTTPS dev (mkcert, ngrok, or Vite's --https flag)
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
For production, the Vercel / Netlify / Cloudflare default deploys are HTTPS — no extra work.
|
|
558
|
-
|
|
559
|
-
---
|
|
560
|
-
|
|
561
|
-
## 7. Anti-patterns
|
|
562
|
-
|
|
563
|
-
1. **Believing "the web has no CometChat push."** It does — `CometChatNotifications.registerPushToken(token, PushPlatforms.FCM_WEB)` + a dashboard FCM provider (§1). Don't hand-roll a push server unless you've ruled out Firebase.
|
|
564
|
-
2. **Inventing SDK symbols.** There is no `PNPlatform`, no `PushNotificationOptions`. The real names are `CometChatNotifications` and `PushPlatforms` (only member: `FCM_WEB`).
|
|
565
|
-
3. **Calling `registerPushToken` before login.** It binds to the current logged-in user's auth token — call it only after `CometChatUIKit.login(...)` resolves.
|
|
566
|
-
4. **Calling `Notification.requestPermission()` on page load.** Browsers reject this. Wire to a user-clicked "Enable notifications" button (§2).
|
|
567
|
-
5. **Self-hosted path: sending the Auth Key in push payloads.** Payloads are visible in the SW; never include credentials. Use the user's UID as a key into your server's session store.
|
|
568
|
-
6. **Self-hosted path: missing webhook signature verification.** Without HMAC verification, anyone with the URL can spoof notifications.
|
|
569
|
-
7. **Showing notifications even when the chat tab is open.** Check `clients.matchAll()` (self-hosted) or `document.visibilityState` in `onMessage` (FCM) and skip if the user already has the chat focused.
|
|
570
|
-
8. **Skipping the iOS PWA warning.** iOS users will silently get nothing. Tell them to "Add to Home Screen."
|
|
571
|
-
9. **Forgetting cleanup on logout.** FCM path: call `CometChatNotifications.unregisterPushToken()` (§1.6). Self-hosted path: `subscription.unsubscribe()` + DELETE the server record (§8). Otherwise the previous user keeps getting the new user's messages.
|
|
572
|
-
|
|
573
|
-
---
|
|
574
|
-
|
|
575
|
-
## 8. Self-hosted logout cleanup
|
|
576
|
-
|
|
577
|
-
(FCM_WEB logout uses `CometChatNotifications.unregisterPushToken()` — see §1.6. This is the self-hosted equivalent.)
|
|
578
|
-
|
|
579
|
-
```ts
|
|
580
|
-
async function unsubscribeWebPush(uid: string): Promise<void> {
|
|
581
|
-
const reg = await navigator.serviceWorker.getRegistration();
|
|
582
|
-
if (!reg) return;
|
|
583
|
-
const subscription = await reg.pushManager.getSubscription();
|
|
584
|
-
if (!subscription) return;
|
|
585
|
-
|
|
586
|
-
await fetch("/api/push/unsubscribe", {
|
|
587
|
-
method: "POST",
|
|
588
|
-
headers: { "Content-Type": "application/json" },
|
|
589
|
-
body: JSON.stringify({ uid, subscription }),
|
|
590
|
-
});
|
|
591
|
-
await subscription.unsubscribe();
|
|
592
|
-
}
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
Call this from your logout flow before `CometChat.logout()`.
|
|
596
|
-
|
|
597
|
-
---
|
|
598
|
-
|
|
599
|
-
## 9. Verification checklist
|
|
600
|
-
|
|
601
|
-
**Recommended FCM_WEB path (§1):**
|
|
602
|
-
- [ ] `firebase` installed; `firebaseApp` initialized with the web SDK config
|
|
603
|
-
- [ ] Firebase Web Push certificate generated and wired as `getToken({ vapidKey })`
|
|
604
|
-
- [ ] `public/firebase-messaging-sw.js` at origin root, handles `onBackgroundMessage` + `notificationclick`
|
|
605
|
-
- [ ] `Notification.requestPermission()` triggered from a user gesture, not page load (§2)
|
|
606
|
-
- [ ] `CometChatNotifications.registerPushToken(token, CometChatNotifications.PushPlatforms.FCM_WEB)` called AFTER `CometChatUIKit.login(...)` resolves
|
|
607
|
-
- [ ] FCM provider configured in the CometChat dashboard (Notifications → Push)
|
|
608
|
-
- [ ] Foreground `onMessage` does NOT pop an OS notification when the tab is focused
|
|
609
|
-
- [ ] Logout flow calls `CometChatNotifications.unregisterPushToken()` before `CometChat.logout()`
|
|
610
|
-
- [ ] No phantom symbols (`PNPlatform` / `PushNotificationOptions`) anywhere
|
|
611
|
-
|
|
612
|
-
**Common to both paths:**
|
|
613
|
-
- [ ] HTTPS or localhost only (warned otherwise)
|
|
614
|
-
- [ ] `manifest.json` shipped if iOS users are expected (PWA caveat, §4)
|
|
615
|
-
- [ ] Notifications dedupe per conversation via `tag` field
|
|
616
|
-
|
|
617
|
-
**Self-hosted fallback path (§3) only:**
|
|
618
|
-
- [ ] `public/sw.js` exists and listens for `push` + `notificationclick` events
|
|
619
|
-
- [ ] VAPID public key in client env vars; private key in server env, NOT client
|
|
620
|
-
- [ ] Subscription POSTed to your push server, keyed by CometChat UID
|
|
621
|
-
- [ ] CometChat dashboard webhook configured for `Message sent` events
|
|
622
|
-
- [ ] Webhook signature verification on the push server (HMAC SHA256)
|
|
623
|
-
- [ ] Logout flow calls `subscription.unsubscribe()` and deletes server record
|
|
624
|
-
- [ ] Server cleanup of dead subscriptions on 410 response
|
|
625
|
-
|
|
626
|
-
---
|
|
627
|
-
|
|
628
|
-
## 10. Pointers
|
|
629
|
-
|
|
630
|
-
- `cometchat-react-calls/references/voip-and-web-push.md` — Web Push for incoming calls (overlap; both can coexist on the same SW)
|
|
631
|
-
- `cometchat-{react,nextjs,react-router,astro}-patterns` — framework-specific SSR handling
|
|
632
|
-
- `cometchat-production` — auth tokens, security
|
|
633
|
-
- `cometchat-troubleshooting` — web push debugging (chrome://serviceworker-internals, Firefox about:debugging)
|
|
634
|
-
- Firebase Cloud Messaging for Web — https://firebase.google.com/docs/cloud-messaging/js/client
|