@cometchat/skills 4.0.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.
- package/README.md +42 -2
- package/bin/install.js +448 -57
- package/package.json +1 -1
- package/skills/cometchat/SKILL.md +337 -80
- package/skills/cometchat-a11y/SKILL.md +476 -0
- package/skills/cometchat-android-v5/SKILL.md +1 -1
- package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
- package/skills/cometchat-android-v5-calls/references/README.md +53 -0
- package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
- package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
- package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
- package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
- package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
- package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
- package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
- package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
- package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
- package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
- package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
- package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
- package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
- package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
- package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
- package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
- package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
- package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
- package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
- package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
- package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
- package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
- package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
- package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
- package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
- package/skills/cometchat-android-v5-components/SKILL.md +1 -1
- package/skills/cometchat-android-v5-core/SKILL.md +1 -1
- package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v5-features/SKILL.md +1 -1
- package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v5-production/SKILL.md +1 -1
- package/skills/cometchat-android-v5-push/SKILL.md +1 -1
- package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-android-v6/SKILL.md +1 -1
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
- package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
- package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
- package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
- package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
- package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
- package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
- package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
- package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
- package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
- package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
- package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
- package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-core/SKILL.md +1 -1
- package/skills/cometchat-android-v6-events/SKILL.md +1 -1
- package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v6-features/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
- package/skills/cometchat-android-v6-production/SKILL.md +1 -1
- package/skills/cometchat-android-v6-push/SKILL.md +1 -1
- package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-angular-calls/SKILL.md +511 -0
- package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
- package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
- package/skills/cometchat-angular-calls/references/call-session.md +167 -0
- package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
- package/skills/cometchat-angular-calls/references/device-management.md +135 -0
- package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
- package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
- package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
- package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
- package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
- package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
- package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
- package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
- package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
- package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
- package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
- package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
- package/skills/cometchat-angular-components/SKILL.md +1 -1
- package/skills/cometchat-angular-core/SKILL.md +1 -1
- package/skills/cometchat-angular-customization/SKILL.md +1 -1
- package/skills/cometchat-angular-features/SKILL.md +1 -1
- package/skills/cometchat-angular-patterns/SKILL.md +1 -1
- package/skills/cometchat-angular-placement/SKILL.md +1 -1
- package/skills/cometchat-angular-production/SKILL.md +1 -1
- package/skills/cometchat-angular-push/SKILL.md +403 -0
- package/skills/cometchat-angular-testing/SKILL.md +333 -0
- package/skills/cometchat-angular-theming/SKILL.md +1 -1
- package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-astro-patterns/SKILL.md +1 -1
- package/skills/cometchat-calls/SKILL.md +358 -0
- package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
- package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
- package/skills/cometchat-calls/references/use-case-support.md +190 -0
- package/skills/cometchat-calls/references/use-case-team.md +169 -0
- package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
- package/skills/cometchat-components/SKILL.md +1 -1
- package/skills/cometchat-core/SKILL.md +1 -1
- package/skills/cometchat-customization/SKILL.md +2 -2
- package/skills/cometchat-features/SKILL.md +2 -2
- package/skills/cometchat-flutter-v5/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
- package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
- package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
- package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
- package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
- package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
- package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
- package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
- package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
- package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
- package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
- package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
- package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
- package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
- package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
- package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
- package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
- package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
- package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
- package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
- package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
- package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
- package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
- package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
- package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
- package/skills/cometchat-i18n/SKILL.md +358 -0
- package/skills/cometchat-ios/SKILL.md +5 -5
- package/skills/cometchat-ios-calls/SKILL.md +409 -0
- package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
- package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
- package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
- package/skills/cometchat-ios-calls/references/call-session.md +221 -0
- package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
- package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
- package/skills/cometchat-ios-calls/references/device-management.md +171 -0
- package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
- package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
- package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
- package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
- package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
- package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
- package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
- package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
- package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
- package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
- package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
- package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
- package/skills/cometchat-ios-components/SKILL.md +1 -1
- package/skills/cometchat-ios-core/SKILL.md +1 -1
- package/skills/cometchat-ios-customization/SKILL.md +1 -1
- package/skills/cometchat-ios-features/SKILL.md +1 -1
- package/skills/cometchat-ios-placement/SKILL.md +1 -1
- package/skills/cometchat-ios-production/SKILL.md +1 -1
- package/skills/cometchat-ios-push/SKILL.md +1 -1
- package/skills/cometchat-ios-testing/SKILL.md +371 -0
- package/skills/cometchat-ios-theming/SKILL.md +1 -1
- package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
- package/skills/cometchat-native-calls/SKILL.md +599 -0
- package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
- package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
- package/skills/cometchat-native-calls/references/call-session.md +182 -0
- package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
- package/skills/cometchat-native-calls/references/device-management.md +135 -0
- package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
- package/skills/cometchat-native-calls/references/group-calls.md +291 -0
- package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
- package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
- package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
- package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
- package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
- package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
- package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
- package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
- package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
- package/skills/cometchat-native-calls/references/share-invite.md +144 -0
- package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
- package/skills/cometchat-native-components/SKILL.md +1 -1
- package/skills/cometchat-native-core/SKILL.md +1 -1
- package/skills/cometchat-native-customization/SKILL.md +1 -1
- package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
- package/skills/cometchat-native-features/SKILL.md +1 -1
- package/skills/cometchat-native-placement/SKILL.md +1 -1
- package/skills/cometchat-native-production/SKILL.md +1 -1
- package/skills/cometchat-native-push/SKILL.md +1 -1
- package/skills/cometchat-native-testing/SKILL.md +1 -1
- package/skills/cometchat-native-theming/SKILL.md +1 -1
- package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
- package/skills/cometchat-placement/SKILL.md +29 -1
- package/skills/cometchat-production/SKILL.md +1 -1
- package/skills/cometchat-react-calls/SKILL.md +539 -0
- package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
- package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
- package/skills/cometchat-react-calls/references/call-session.md +235 -0
- package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
- package/skills/cometchat-react-calls/references/device-management.md +206 -0
- package/skills/cometchat-react-calls/references/group-calls.md +262 -0
- package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
- package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
- package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
- package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
- package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
- package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
- package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
- package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
- package/skills/cometchat-react-calls/references/share-invite.md +176 -0
- package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
- package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
- package/skills/cometchat-react-patterns/SKILL.md +56 -8
- package/skills/cometchat-react-push/SKILL.md +448 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
- package/skills/cometchat-react-testing/SKILL.md +404 -0
- package/skills/cometchat-theming/SKILL.md +3 -3
- package/skills/cometchat-troubleshooting/SKILL.md +2 -2
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Lazy loading + calls in Angular — pitfalls
|
|
2
|
+
|
|
3
|
+
Calls have a tighter relationship with bootstrap than chat does. Lazy-loading the calls module breaks several invariants.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The core problem
|
|
8
|
+
|
|
9
|
+
`APP_INITIALIZER` runs at app bootstrap, before any router activates. The Calls SDK init must complete BEFORE incoming calls can fire — otherwise the listener doesn't exist when the first call rings.
|
|
10
|
+
|
|
11
|
+
If you lazy-load the calls module:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// app-routing.module.ts
|
|
15
|
+
{ path: "calls", loadChildren: () => import("./calls/calls.module").then(m => m.CallsModule) }
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then `CallInitService` (which lives in `CallsModule`) doesn't exist at bootstrap. APP_INITIALIZER can't reference it. Two failure modes:
|
|
19
|
+
|
|
20
|
+
1. **Init never runs** — until the user navigates to `/calls`, the SDK is uninitialized. Incoming calls miss.
|
|
21
|
+
2. **Race condition** — user navigates to `/calls`, the lazy module loads, init runs, but a call had been incoming during the navigation gap. That call is lost.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Fix: split the service from the component
|
|
26
|
+
|
|
27
|
+
Keep `CallInitService` in `AppModule` (eager). Keep the call UI components in `CallsModule` (lazy).
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// app.module.ts (eager)
|
|
31
|
+
@NgModule({
|
|
32
|
+
providers: [
|
|
33
|
+
CallInitService, // EAGER — service is at bootstrap
|
|
34
|
+
{
|
|
35
|
+
provide: APP_INITIALIZER,
|
|
36
|
+
useFactory: (svc: CallInitService) => () => svc.init(),
|
|
37
|
+
deps: [CallInitService],
|
|
38
|
+
multi: true,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
export class AppModule {}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// calls/calls.module.ts (lazy)
|
|
47
|
+
@NgModule({
|
|
48
|
+
declarations: [
|
|
49
|
+
OngoingCallComponent,
|
|
50
|
+
CallLogsComponent,
|
|
51
|
+
CallButtonComponent,
|
|
52
|
+
],
|
|
53
|
+
imports: [
|
|
54
|
+
RouterModule.forChild([
|
|
55
|
+
{ path: "ongoing/:id", component: OngoingCallComponent, canDeactivate: [CallDeactivateGuard] },
|
|
56
|
+
{ path: "logs", component: CallLogsComponent },
|
|
57
|
+
]),
|
|
58
|
+
],
|
|
59
|
+
})
|
|
60
|
+
export class CallsModule {}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The components reference `CallInitService` via DI; Angular finds it from the parent injector (AppModule).
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Pitfall 2: `<cometchat-incoming-call>` in a lazy module
|
|
68
|
+
|
|
69
|
+
Incoming calls must ring on every screen — not just `/calls`. Mounting `<cometchat-incoming-call>` inside `CallsModule`'s components means:
|
|
70
|
+
|
|
71
|
+
- User on `/dashboard` → no incoming-call listener → calls miss
|
|
72
|
+
- User navigates to `/calls/logs` → listener mounts → calls now ring
|
|
73
|
+
- User navigates back to `/dashboard` → listener unmounts → calls miss again
|
|
74
|
+
|
|
75
|
+
**Fix:** mount `<cometchat-incoming-call>` in `AppComponent`'s template (the root of the application, NOT in any feature module):
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<!-- app.component.html -->
|
|
79
|
+
<cometchat-incoming-call></cometchat-incoming-call>
|
|
80
|
+
<router-outlet></router-outlet>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`AppModule` must import enough of `@cometchat/chat-uikit-angular` to render this selector — usually `CometChatUIKitModule.forRoot({...})`. Schemas option `CUSTOM_ELEMENTS_SCHEMA` works too.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Pitfall 3: standalone components + lazy-loaded calls
|
|
88
|
+
|
|
89
|
+
Angular 14+ standalone components don't have a parent `NgModule`. The DI tree is different — APP_INITIALIZER lives at the bootstrap providers level:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
// main.ts
|
|
93
|
+
bootstrapApplication(AppComponent, {
|
|
94
|
+
providers: [
|
|
95
|
+
CallInitService, // root-provided — visible everywhere
|
|
96
|
+
{
|
|
97
|
+
provide: APP_INITIALIZER,
|
|
98
|
+
useFactory: (svc: CallInitService) => () => svc.init(),
|
|
99
|
+
deps: [CallInitService],
|
|
100
|
+
multi: true,
|
|
101
|
+
},
|
|
102
|
+
provideRouter([
|
|
103
|
+
// Lazy-loaded standalone routes
|
|
104
|
+
{ path: "calls/ongoing/:id", loadComponent: () => import("./calls/ongoing-call.component").then(m => m.OngoingCallComponent) },
|
|
105
|
+
]),
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The lazy `loadComponent` works fine because `CallInitService` is at the root.
|
|
111
|
+
|
|
112
|
+
`<cometchat-incoming-call>` is a standalone component too:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
// app.component.ts
|
|
116
|
+
import { CometChatIncomingCallComponent } from "@cometchat/chat-uikit-angular";
|
|
117
|
+
|
|
118
|
+
@Component({
|
|
119
|
+
standalone: true,
|
|
120
|
+
selector: "app-root",
|
|
121
|
+
imports: [RouterOutlet, CometChatIncomingCallComponent],
|
|
122
|
+
template: `
|
|
123
|
+
<cometchat-incoming-call></cometchat-incoming-call>
|
|
124
|
+
<router-outlet></router-outlet>
|
|
125
|
+
`,
|
|
126
|
+
})
|
|
127
|
+
export class AppComponent {}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
(Verify the export name in your installed `@cometchat/chat-uikit-angular` version — may differ between minor releases.)
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Pitfall 4: SSR (Angular Universal)
|
|
135
|
+
|
|
136
|
+
The Calls SDK uses browser-only APIs (`getUserMedia`, `RTCPeerConnection`). If your app uses Angular Universal, the calls service must NOT initialize on the server:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
140
|
+
import { Inject, PLATFORM_ID } from "@angular/core";
|
|
141
|
+
|
|
142
|
+
@Injectable({ providedIn: "root" })
|
|
143
|
+
export class CallInitService {
|
|
144
|
+
constructor(@Inject(PLATFORM_ID) private platformId: object) {}
|
|
145
|
+
|
|
146
|
+
async init(): Promise<void> {
|
|
147
|
+
if (!isPlatformBrowser(this.platformId)) return; // skip on server
|
|
148
|
+
// ... actual init
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Without this guard, the SSR build crashes with `ReferenceError: window is not defined` at boot.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Pitfall 5: Multiple `APP_INITIALIZER`s
|
|
158
|
+
|
|
159
|
+
If your project already uses `APP_INITIALIZER` for chat init, calls init goes alongside — not as a replacement:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
providers: [
|
|
163
|
+
ChatInitService,
|
|
164
|
+
CallInitService,
|
|
165
|
+
{
|
|
166
|
+
provide: APP_INITIALIZER,
|
|
167
|
+
useFactory: (chat: ChatInitService) => () => chat.init(),
|
|
168
|
+
deps: [ChatInitService],
|
|
169
|
+
multi: true, // ← multi: true is critical
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
provide: APP_INITIALIZER,
|
|
173
|
+
useFactory: (calls: CallInitService) => () => calls.init(),
|
|
174
|
+
deps: [CallInitService],
|
|
175
|
+
multi: true,
|
|
176
|
+
},
|
|
177
|
+
]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Both register; both run before bootstrap. They run in registration order — chat first, then calls (matches rule 1.1's chat-init-before-calls-init).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Pitfall 6: Forgetting the route deactivate guard for ongoing calls
|
|
185
|
+
|
|
186
|
+
Without `CanDeactivate`, the user can route away mid-call and the call screen unmounts but the SDK session keeps running. Camera light stays on (rule 1.5 violation).
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
// calls-routing.module.ts
|
|
190
|
+
{ path: "ongoing/:id", component: OngoingCallComponent, canDeactivate: [CallDeactivateGuard] }
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The guard is in `references/custom-ui.md`.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Summary
|
|
198
|
+
|
|
199
|
+
| Place | What goes here |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `AppModule` (eager) | `CallInitService`, `APP_INITIALIZER`, `<cometchat-incoming-call>` |
|
|
202
|
+
| `CallsModule` (lazy) | UI components (OngoingCall, CallLogs, CallButton), feature routes |
|
|
203
|
+
| App root template | `<cometchat-incoming-call>` mounted above `<router-outlet>` |
|
|
204
|
+
| Routes | `canDeactivate` guard on the ongoing-call route |
|
|
205
|
+
| SSR | `isPlatformBrowser` check inside init service |
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Calls SDK v4 → v5 migration (Angular)
|
|
2
|
+
|
|
3
|
+
Angular ships the same `@cometchat/calls-sdk-javascript` as React/Vue, so the migration steps are identical. Angular-specific deltas: NgZone wrapping for the new event listeners.
|
|
4
|
+
|
|
5
|
+
**Read first:** `cometchat-react-calls/references/migration-v4-to-v5.md` — full step-by-step (init, login, settings, events, methods).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Step 1 — Bump the package
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @cometchat/calls-sdk-javascript@5
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Angular-specific delta: NgZone for new event listeners
|
|
18
|
+
|
|
19
|
+
When migrating from `OngoingCallListener` to `addEventListener`, Angular needs `NgZone.run` to update OnPush components — listeners fire outside Angular's zone:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
@Injectable({ providedIn: "root" })
|
|
23
|
+
export class CallEventService {
|
|
24
|
+
constructor(private zone: NgZone) {
|
|
25
|
+
// v4 — listener was inside CometChatCalls.OngoingCallListener; if your
|
|
26
|
+
// current code already wraps callbacks with NgZone.run, keep that.
|
|
27
|
+
// v5 — addEventListener fires outside zone:
|
|
28
|
+
CometChatCalls.addEventListener("onSessionLeft", () => {
|
|
29
|
+
this.zone.run(() => this.onSessionLeft$.next());
|
|
30
|
+
});
|
|
31
|
+
CometChatCalls.addEventListener("onParticipantJoined", (p) => {
|
|
32
|
+
this.zone.run(() => this.participantJoined$.next(p));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If you skip the `NgZone.run` wrap, OnPush components don't re-render when call state changes.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Verification checklist
|
|
43
|
+
|
|
44
|
+
- [ ] All v5 event listeners wrapped in `NgZone.run`
|
|
45
|
+
- [ ] All sister checks from the canonical migration guide
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Pointers
|
|
50
|
+
|
|
51
|
+
- Canonical migration: `cometchat-react-calls/references/migration-v4-to-v5.md`
|
|
52
|
+
- Canonical Web Push event handling: `references/ngzone-and-async-callbacks.md`
|
|
53
|
+
- https://www.cometchat.com/docs/calls/javascript/migration-guide-v5
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# NgZone + async SDK callbacks — the Angular calls gotcha
|
|
2
|
+
|
|
3
|
+
Angular's change detection runs inside `NgZone`. Callbacks that fire *outside* NgZone don't trigger change detection — UI doesn't update. The Calls SDK fires lots of callbacks from native bridges (WebRTC, browser MediaStream events), and those bridges escape the zone.
|
|
4
|
+
|
|
5
|
+
If your custom call UI seems "frozen" — call ends but the screen stays — this is almost always the cause.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Symptom
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// OngoingCallComponent
|
|
13
|
+
ngOnInit() {
|
|
14
|
+
CometChatCalls.joinSession(token, settings, container); // v5 canonical (startSession is a deprecated shim)
|
|
15
|
+
|
|
16
|
+
// This callback is registered with the SDK, which is registered with WebRTC,
|
|
17
|
+
// which is a native browser API outside Angular's zone
|
|
18
|
+
callListener.onCallEnded = () => {
|
|
19
|
+
this.callEnded = true; // ← variable updates
|
|
20
|
+
this.cleanup(); // ← runs
|
|
21
|
+
// BUT: change detection doesn't fire. The template doesn't re-render.
|
|
22
|
+
// User sees: "End" button still showing, no "Call ended" message.
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Fix
|
|
30
|
+
|
|
31
|
+
Wrap the callback body in `NgZone.run`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { NgZone } from "@angular/core";
|
|
35
|
+
|
|
36
|
+
constructor(private zone: NgZone) {}
|
|
37
|
+
|
|
38
|
+
ngOnInit() {
|
|
39
|
+
// ...
|
|
40
|
+
callListener.onCallEnded = () => {
|
|
41
|
+
this.zone.run(() => {
|
|
42
|
+
this.callEnded = true;
|
|
43
|
+
this.cleanup();
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Now change detection runs after the variable updates; template re-renders.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Which callbacks need NgZone.run?
|
|
54
|
+
|
|
55
|
+
All Calls SDK event listeners. The kit's own components handle this internally; custom code that subscribes to the SDK directly does NOT.
|
|
56
|
+
|
|
57
|
+
Conservative rule: **wrap every callback that mutates UI state** in `zone.run`.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const listener = new CometChatCalls.OngoingCallListener({
|
|
61
|
+
onUserListUpdated: (userList) => {
|
|
62
|
+
this.zone.run(() => { this.participants = userList; });
|
|
63
|
+
},
|
|
64
|
+
onCallEnded: () => {
|
|
65
|
+
this.zone.run(() => { this.callEnded = true; this.cleanup(); });
|
|
66
|
+
},
|
|
67
|
+
onError: (err) => {
|
|
68
|
+
this.zone.run(() => { this.errorMessage = err.message; });
|
|
69
|
+
},
|
|
70
|
+
onActiveSpeakerUpdated: (uid) => {
|
|
71
|
+
this.zone.run(() => { this.activeSpeakerUid = uid; });
|
|
72
|
+
},
|
|
73
|
+
onMediaDeviceListUpdated: (devices) => {
|
|
74
|
+
this.zone.run(() => { this.devices = devices; });
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If a callback only triggers a side effect (logging, analytics) without UI changes, NgZone.run is not strictly required — but harmless.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Alternative: ChangeDetectorRef.detectChanges
|
|
84
|
+
|
|
85
|
+
If you want to avoid NgZone for performance reasons (zone.run is cheap but adds overhead in hot paths), use `ChangeDetectorRef.detectChanges`:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { ChangeDetectorRef } from "@angular/core";
|
|
89
|
+
|
|
90
|
+
constructor(private cd: ChangeDetectorRef) {}
|
|
91
|
+
|
|
92
|
+
ngOnInit() {
|
|
93
|
+
callListener.onCallEnded = () => {
|
|
94
|
+
this.callEnded = true;
|
|
95
|
+
this.cleanup();
|
|
96
|
+
this.cd.detectChanges(); // run change detection just for this component subtree
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Pros: scoped to the component (NgZone is global).
|
|
102
|
+
Cons: if you have parent component bindings that depend on this state, they don't update. Use NgZone.run for cross-component state changes.
|
|
103
|
+
|
|
104
|
+
For 95% of cases, NgZone.run is the right answer.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Async/await inside callbacks
|
|
109
|
+
|
|
110
|
+
If your callback is `async`, wrap the whole function:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
callListener.onCallEnded = async () => {
|
|
114
|
+
await this.zone.run(async () => {
|
|
115
|
+
await this.savePostCallAnalytics();
|
|
116
|
+
this.callEnded = true;
|
|
117
|
+
this.cleanup();
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Or simpler — use a plain method and let zone.js patch async automatically:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
callListener.onCallEnded = () => {
|
|
126
|
+
this.zone.run(() => this.handleCallEnded());
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
private async handleCallEnded() {
|
|
130
|
+
await this.savePostCallAnalytics();
|
|
131
|
+
this.callEnded = true;
|
|
132
|
+
this.cleanup();
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Inside `handleCallEnded`, change detection fires automatically because zone.js patches `await`.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## How to detect this bug
|
|
141
|
+
|
|
142
|
+
Add a debug log inside the callback. If the log fires but the UI doesn't update, you're outside zone:
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
callListener.onCallEnded = () => {
|
|
146
|
+
console.log("[debug] onCallEnded fired", new Date().toISOString());
|
|
147
|
+
this.callEnded = true;
|
|
148
|
+
};
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
If "fired" appears in console but the template still shows the call as active, wrap in zone.run.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## OnPush change detection
|
|
156
|
+
|
|
157
|
+
If your component uses `ChangeDetectionStrategy.OnPush`, NgZone.run alone isn't enough — OnPush only re-renders on `@Input` changes or explicit markForCheck. Combine:
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef } from "@angular/core";
|
|
161
|
+
|
|
162
|
+
@Component({
|
|
163
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
164
|
+
})
|
|
165
|
+
export class OngoingCallComponent {
|
|
166
|
+
constructor(private zone: NgZone, private cd: ChangeDetectorRef) {}
|
|
167
|
+
|
|
168
|
+
ngOnInit() {
|
|
169
|
+
callListener.onCallEnded = () => {
|
|
170
|
+
this.zone.run(() => {
|
|
171
|
+
this.callEnded = true;
|
|
172
|
+
this.cd.markForCheck();
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## When the kit fires NgZone-correctly
|
|
182
|
+
|
|
183
|
+
The CometChat Angular UI Kit (`@cometchat/chat-uikit-angular`) handles this internally. If you only use `<cometchat-incoming-call>`, `<cometchat-ongoing-call>`, etc. — no manual NgZone needed. The bug only bites when you write custom subscriptions to `CometChatCalls.*` callbacks.
|