@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.
Files changed (258) hide show
  1. package/README.md +42 -2
  2. package/bin/install.js +448 -57
  3. package/package.json +1 -1
  4. package/skills/cometchat/SKILL.md +337 -80
  5. package/skills/cometchat-a11y/SKILL.md +476 -0
  6. package/skills/cometchat-android-v5/SKILL.md +1 -1
  7. package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
  8. package/skills/cometchat-android-v5-calls/references/README.md +53 -0
  9. package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
  10. package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
  11. package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
  12. package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
  13. package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
  14. package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
  15. package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
  16. package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
  17. package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
  18. package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
  19. package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
  20. package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
  21. package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
  22. package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
  23. package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
  24. package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
  25. package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
  26. package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
  27. package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
  28. package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
  29. package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
  30. package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
  31. package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
  32. package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
  33. package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
  34. package/skills/cometchat-android-v5-components/SKILL.md +1 -1
  35. package/skills/cometchat-android-v5-core/SKILL.md +1 -1
  36. package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
  37. package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
  38. package/skills/cometchat-android-v5-features/SKILL.md +1 -1
  39. package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
  40. package/skills/cometchat-android-v5-production/SKILL.md +1 -1
  41. package/skills/cometchat-android-v5-push/SKILL.md +1 -1
  42. package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
  43. package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
  44. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
  45. package/skills/cometchat-android-v6/SKILL.md +1 -1
  46. package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
  47. package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
  48. package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
  49. package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
  50. package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
  51. package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
  52. package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
  53. package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
  54. package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
  55. package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
  56. package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
  57. package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
  58. package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
  59. package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
  60. package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
  61. package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
  62. package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
  63. package/skills/cometchat-android-v6-core/SKILL.md +1 -1
  64. package/skills/cometchat-android-v6-events/SKILL.md +1 -1
  65. package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
  66. package/skills/cometchat-android-v6-features/SKILL.md +1 -1
  67. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
  68. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
  69. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
  70. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
  71. package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
  72. package/skills/cometchat-android-v6-production/SKILL.md +1 -1
  73. package/skills/cometchat-android-v6-push/SKILL.md +1 -1
  74. package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
  75. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
  76. package/skills/cometchat-angular-calls/SKILL.md +511 -0
  77. package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
  78. package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
  79. package/skills/cometchat-angular-calls/references/call-session.md +167 -0
  80. package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
  81. package/skills/cometchat-angular-calls/references/device-management.md +135 -0
  82. package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
  83. package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
  84. package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
  85. package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
  86. package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
  87. package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
  88. package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
  89. package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
  90. package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
  91. package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
  92. package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
  93. package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
  94. package/skills/cometchat-angular-components/SKILL.md +1 -1
  95. package/skills/cometchat-angular-core/SKILL.md +1 -1
  96. package/skills/cometchat-angular-customization/SKILL.md +1 -1
  97. package/skills/cometchat-angular-features/SKILL.md +1 -1
  98. package/skills/cometchat-angular-patterns/SKILL.md +1 -1
  99. package/skills/cometchat-angular-placement/SKILL.md +1 -1
  100. package/skills/cometchat-angular-production/SKILL.md +1 -1
  101. package/skills/cometchat-angular-push/SKILL.md +403 -0
  102. package/skills/cometchat-angular-testing/SKILL.md +333 -0
  103. package/skills/cometchat-angular-theming/SKILL.md +1 -1
  104. package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
  105. package/skills/cometchat-astro-patterns/SKILL.md +1 -1
  106. package/skills/cometchat-calls/SKILL.md +358 -0
  107. package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
  108. package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
  109. package/skills/cometchat-calls/references/use-case-support.md +190 -0
  110. package/skills/cometchat-calls/references/use-case-team.md +169 -0
  111. package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
  112. package/skills/cometchat-components/SKILL.md +1 -1
  113. package/skills/cometchat-core/SKILL.md +1 -1
  114. package/skills/cometchat-customization/SKILL.md +2 -2
  115. package/skills/cometchat-features/SKILL.md +2 -2
  116. package/skills/cometchat-flutter-v5/SKILL.md +1 -1
  117. package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
  118. package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
  119. package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
  120. package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
  121. package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
  122. package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
  123. package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
  124. package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
  125. package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
  126. package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
  127. package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
  128. package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
  129. package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
  130. package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
  131. package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
  132. package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
  133. package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
  134. package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
  135. package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
  136. package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
  137. package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
  138. package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
  139. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
  140. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
  141. package/skills/cometchat-flutter-v6/SKILL.md +1 -1
  142. package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
  143. package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
  144. package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
  145. package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
  146. package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
  147. package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
  148. package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
  149. package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
  150. package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
  151. package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
  152. package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
  153. package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
  154. package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
  155. package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
  156. package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
  157. package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
  158. package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
  159. package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
  160. package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
  161. package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
  162. package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
  163. package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
  164. package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
  165. package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
  166. package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
  167. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
  168. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
  169. package/skills/cometchat-i18n/SKILL.md +358 -0
  170. package/skills/cometchat-ios/SKILL.md +5 -5
  171. package/skills/cometchat-ios-calls/SKILL.md +409 -0
  172. package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
  173. package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
  174. package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
  175. package/skills/cometchat-ios-calls/references/call-session.md +221 -0
  176. package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
  177. package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
  178. package/skills/cometchat-ios-calls/references/device-management.md +171 -0
  179. package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
  180. package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
  181. package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
  182. package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
  183. package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
  184. package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
  185. package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
  186. package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
  187. package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
  188. package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
  189. package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
  190. package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
  191. package/skills/cometchat-ios-components/SKILL.md +1 -1
  192. package/skills/cometchat-ios-core/SKILL.md +1 -1
  193. package/skills/cometchat-ios-customization/SKILL.md +1 -1
  194. package/skills/cometchat-ios-features/SKILL.md +1 -1
  195. package/skills/cometchat-ios-placement/SKILL.md +1 -1
  196. package/skills/cometchat-ios-production/SKILL.md +1 -1
  197. package/skills/cometchat-ios-push/SKILL.md +1 -1
  198. package/skills/cometchat-ios-testing/SKILL.md +371 -0
  199. package/skills/cometchat-ios-theming/SKILL.md +1 -1
  200. package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
  201. package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
  202. package/skills/cometchat-native-calls/SKILL.md +599 -0
  203. package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
  204. package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
  205. package/skills/cometchat-native-calls/references/call-session.md +182 -0
  206. package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
  207. package/skills/cometchat-native-calls/references/device-management.md +135 -0
  208. package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
  209. package/skills/cometchat-native-calls/references/group-calls.md +291 -0
  210. package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
  211. package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
  212. package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
  213. package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
  214. package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
  215. package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
  216. package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
  217. package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
  218. package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
  219. package/skills/cometchat-native-calls/references/share-invite.md +144 -0
  220. package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
  221. package/skills/cometchat-native-components/SKILL.md +1 -1
  222. package/skills/cometchat-native-core/SKILL.md +1 -1
  223. package/skills/cometchat-native-customization/SKILL.md +1 -1
  224. package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
  225. package/skills/cometchat-native-features/SKILL.md +1 -1
  226. package/skills/cometchat-native-placement/SKILL.md +1 -1
  227. package/skills/cometchat-native-production/SKILL.md +1 -1
  228. package/skills/cometchat-native-push/SKILL.md +1 -1
  229. package/skills/cometchat-native-testing/SKILL.md +1 -1
  230. package/skills/cometchat-native-theming/SKILL.md +1 -1
  231. package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
  232. package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
  233. package/skills/cometchat-placement/SKILL.md +29 -1
  234. package/skills/cometchat-production/SKILL.md +1 -1
  235. package/skills/cometchat-react-calls/SKILL.md +539 -0
  236. package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
  237. package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
  238. package/skills/cometchat-react-calls/references/call-session.md +235 -0
  239. package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
  240. package/skills/cometchat-react-calls/references/device-management.md +206 -0
  241. package/skills/cometchat-react-calls/references/group-calls.md +262 -0
  242. package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
  243. package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
  244. package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
  245. package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
  246. package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
  247. package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
  248. package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
  249. package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
  250. package/skills/cometchat-react-calls/references/share-invite.md +176 -0
  251. package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
  252. package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
  253. package/skills/cometchat-react-patterns/SKILL.md +56 -8
  254. package/skills/cometchat-react-push/SKILL.md +448 -0
  255. package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
  256. package/skills/cometchat-react-testing/SKILL.md +404 -0
  257. package/skills/cometchat-theming/SKILL.md +3 -3
  258. package/skills/cometchat-troubleshooting/SKILL.md +2 -2
@@ -0,0 +1,171 @@
1
+ # Device management on iOS
2
+
3
+ iOS handles audio routing at the system level via `AVAudioSession.sharedInstance().availableInputs`. The Calls SDK exposes camera switching (`switchCamera`) but defers audio device selection to the OS — the user picks via the system's audio route picker (`AVRoutePickerView`) or Control Center.
4
+
5
+ **Canonical docs:** https://www.cometchat.com/docs/calls/ios/device-management
6
+ **Read first:** `references/avaudiosession-routing.md` — AVAudioSession setup + Bluetooth/AirPods routing rules.
7
+
8
+ ---
9
+
10
+ ## Camera switching (front / back / external)
11
+
12
+ ```swift
13
+ import CometChatCallsSDK
14
+
15
+ CometChatCalls.switchCamera()
16
+ ```
17
+
18
+ That's the SDK's primary camera control — toggles front/back. For iPad with attached external cameras (Studio Display, Continuity Camera), the user picks via the system Camera control center.
19
+
20
+ ---
21
+
22
+ ## Audio inputs (mic / Bluetooth / AirPods)
23
+
24
+ System-driven via `AVAudioSession`. The user picks from Control Center → Audio destination, or via your in-app `AVRoutePickerView`:
25
+
26
+ ```swift
27
+ import AVKit
28
+
29
+ class CallControlsView: UIView {
30
+ private let routePicker = AVRoutePickerView()
31
+
32
+ init() {
33
+ super.init(frame: .zero)
34
+ routePicker.translatesAutoresizingMaskIntoConstraints = false
35
+ routePicker.activeTintColor = .systemBlue
36
+ addSubview(routePicker)
37
+ NSLayoutConstraint.activate([
38
+ routePicker.widthAnchor.constraint(equalToConstant: 44),
39
+ routePicker.heightAnchor.constraint(equalToConstant: 44),
40
+ ])
41
+ }
42
+ required init?(coder: NSCoder) { fatalError() }
43
+ }
44
+ ```
45
+
46
+ `AVRoutePickerView` is the canonical iOS audio-route picker. Tapping shows the system sheet with all available outputs (Built-in Speaker, AirPods, CarPlay, Bluetooth speakers, etc.). System-styled; matches user expectations.
47
+
48
+ ---
49
+
50
+ ## Speakerphone toggle
51
+
52
+ Most calls want a quick speaker on/off without going through the route picker:
53
+
54
+ ```swift
55
+ import AVFoundation
56
+
57
+ func toggleSpeaker(on: Bool) {
58
+ do {
59
+ let session = AVAudioSession.sharedInstance()
60
+ if on {
61
+ try session.overrideOutputAudioPort(.speaker)
62
+ } else {
63
+ try session.overrideOutputAudioPort(.none) // restore default routing
64
+ }
65
+ } catch {
66
+ print("Failed to switch speaker: \(error)")
67
+ }
68
+ }
69
+ ```
70
+
71
+ `.none` means "use the system default for current category" (typically receiver/earpiece for `playAndRecord` + `voiceChat`). NOT "no audio."
72
+
73
+ ---
74
+
75
+ ## SwiftUI integration
76
+
77
+ ```swift
78
+ struct CallControls: View {
79
+ @State private var speakerOn = false
80
+
81
+ var body: some View {
82
+ HStack(spacing: 16) {
83
+ // Speaker toggle
84
+ Button(action: {
85
+ speakerOn.toggle()
86
+ toggleSpeaker(on: speakerOn)
87
+ }) {
88
+ Image(systemName: speakerOn ? "speaker.wave.3.fill" : "speaker.fill")
89
+ }
90
+
91
+ // Camera flip
92
+ Button(action: { CometChatCalls.switchCamera() }) {
93
+ Image(systemName: "camera.rotate")
94
+ }
95
+
96
+ // System route picker (Bluetooth / AirPods)
97
+ AVRoutePickerViewWrapper()
98
+ .frame(width: 44, height: 44)
99
+ }
100
+ }
101
+ }
102
+
103
+ struct AVRoutePickerViewWrapper: UIViewRepresentable {
104
+ func makeUIView(context: Context) -> AVRoutePickerView {
105
+ let view = AVRoutePickerView()
106
+ view.activeTintColor = .systemBlue
107
+ return view
108
+ }
109
+ func updateUIView(_ view: AVRoutePickerView, context: Context) {}
110
+ }
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Listen for route changes
116
+
117
+ ```swift
118
+ NotificationCenter.default.addObserver(
119
+ forName: AVAudioSession.routeChangeNotification,
120
+ object: AVAudioSession.sharedInstance(),
121
+ queue: .main
122
+ ) { notification in
123
+ guard let userInfo = notification.userInfo,
124
+ let reasonValue = userInfo[AVAudioSessionRouteChangeReasonKey] as? UInt,
125
+ let reason = AVAudioSession.RouteChangeReason(rawValue: reasonValue) else { return }
126
+
127
+ switch reason {
128
+ case .newDeviceAvailable:
129
+ // AirPods connected, headphones plugged
130
+ print("New audio device available")
131
+ case .oldDeviceUnavailable:
132
+ // Headphones unplugged
133
+ print("Audio device unavailable")
134
+ default:
135
+ break
136
+ }
137
+ }
138
+ ```
139
+
140
+ The two reason codes that matter for UI: `.newDeviceAvailable` (show "AirPods connected" toast) and `.oldDeviceUnavailable` (audio routes back to speaker; might want to update UI button state).
141
+
142
+ ---
143
+
144
+ ## Anti-patterns
145
+
146
+ 1. **Building a custom audio route picker** instead of using `AVRoutePickerView`. iOS users expect the system picker; custom feels off-brand.
147
+ 2. **Setting `overrideOutputAudioPort(.speaker)` from background.** AVAudioSession changes only work when session is active. Wrap in `setActive(true)` first.
148
+ 3. **Forgetting to listen for `routeChangeNotification`.** UI gets out of sync when user changes route via Control Center.
149
+ 4. **Calling `setActive(true)` repeatedly during a call.** AVAudioSession is sticky once activated; redundant calls produce warnings in console.
150
+ 5. **Not handling `.failed` errors from `overrideOutputAudioPort`.** Some Bluetooth devices reject the override; silently swallow OR show a toast.
151
+
152
+ ---
153
+
154
+ ## Verification checklist
155
+
156
+ - [ ] `AVRoutePickerView` rendered in call controls
157
+ - [ ] Speaker toggle uses `overrideOutputAudioPort` correctly
158
+ - [ ] `.routeChangeNotification` observer set up
159
+ - [ ] All AVAudioSession calls on main queue
160
+ - [ ] Real-device smoke: AirPods connect mid-call → toast shown, audio routes
161
+ - [ ] Real-device smoke: Speaker toggle works
162
+ - [ ] Real-device smoke: Camera flip works (front/back)
163
+
164
+ ---
165
+
166
+ ## Pointers
167
+
168
+ - `cometchat-react-calls/references/device-management.md` — web sister reference (different mechanism but UX shape)
169
+ - `cometchat-ios-calls` SKILL.md — the seven hard rules
170
+ - `references/avaudiosession-routing.md` — AVAudioSession setup details
171
+ - Canonical docs: https://www.cometchat.com/docs/calls/ios/device-management
@@ -0,0 +1,396 @@
1
+ # Group calls (meetings) on iOS
2
+
3
+ iOS group calls combine the `CometChatCallsSDK` group APIs with iOS-platform patterns: `UICollectionView` for scalable rosters, KVO/Combine for active-speaker observation, CallKit for OS-level multi-party reporting. For SDK-level semantics (capacity, bandwidth, moderator actions) read `cometchat-native-calls/references/group-calls.md` first — same SDK, identical contracts.
4
+
5
+ ---
6
+
7
+ ## Signaling architecture — meeting-message broadcast, NOT call ringing
8
+
9
+ **Critical to read first.** Group calls do NOT use the Ringing channel (`CometChat.initiateCall` → `onIncomingCallReceived`). That channel is **1:1 user calls only**. The kit broadcasts a **custom message of type `"meeting"`** to the group; receivers see a "Join meeting" card in their `CometChatMessageList` (kit) or need an explicit `MessageListener.onCustomMessageReceived` (custom UI).
10
+
11
+ This applies identically on iOS as on web/RN/Android/Flutter — the same Chat SDK semantic is in play. The kit's `CometChatUI` group surface auto-renders meeting cards; custom Swift/SwiftUI call surfaces need the explicit listener.
12
+
13
+ ```swift
14
+ import CometChatSDK
15
+
16
+ let listener = MessageListener()
17
+ listener.onCustomMessageReceived = { customMessage in
18
+ guard customMessage.category == .custom else { return }
19
+ guard customMessage.type == "meeting" else { return }
20
+
21
+ let customData = customMessage.customData as? [String: Any] ?? [:]
22
+ let sessionID = (customData["sessionId"] as? String) ?? customMessage.receiverUid
23
+ let callTypeRaw = (customData["callType"] as? String) ?? "video"
24
+ let callType: CallType = callTypeRaw == "audio" ? .audio : .video
25
+ let fromUid = customMessage.sender.uid
26
+ let groupGuid = customMessage.receiverUid
27
+
28
+ DispatchQueue.main.async {
29
+ // Present your custom "incoming meeting" UI:
30
+ // - banner / toast with "Join" CTA
31
+ // - or full-screen incoming-meeting view controller
32
+ // Tapping Join → navigate to OngoingCallViewController(sessionID:)
33
+ }
34
+ }
35
+ CometChat.addMessageListener("APP_ROOT_GROUP_MEETING_LISTENER", listener)
36
+ ```
37
+
38
+ | Channel | 1:1 user calls | Group calls |
39
+ |---|---|---|
40
+ | Signaling API (caller) | `CometChat.initiateCall(call:)` | `CometChat.sendCustomMessage(customMessage:)` with type="meeting" |
41
+ | Receiver event | `CallListener.onIncomingCallReceived` | `MessageListener.onCustomMessageReceived` (category=.custom + type="meeting") |
42
+ | Session ID | server-generated unique per call | group's GUID (persistent) |
43
+ | CallKit ring | yes — report via `CXProvider.reportNewIncomingCall` | no — meeting message lands in chat; manual CallKit interception only |
44
+ | Auto-cancel timeout | yes (45s default) | no — meeting persists in chat history |
45
+
46
+ ### CallKit and group calls
47
+
48
+ Because group meeting events come through the message channel (not the call channel), CallKit does NOT auto-ring for incoming group meetings the way it does for 1:1 calls. If you want CallKit-style ringing for groups, you must:
49
+
50
+ 1. Configure your push provider to deliver the meeting message as a VoIP push (PushKit), not a regular APNs push.
51
+ 2. Intercept the VoIP push in `PKPushRegistryDelegate`, parse the meeting payload, and call `CXProvider.reportNewIncomingCall(...)` with a synthesized `CallKit` UUID and metadata.
52
+
53
+ The CometChat dashboard's PushKit provider doesn't auto-route meeting messages to VoIP push by default — you'd need a server-side webhook that re-routes meeting messages. Not built-in.
54
+
55
+ ---
56
+
57
+ ## Initiating a group call
58
+
59
+ ```swift
60
+ import CometChatSDK
61
+
62
+ func initiateGroupCall(guid: String, isVideo: Bool) async throws -> Call {
63
+ let group = try await fetchGroup(guid)
64
+ let callType: CallType = isVideo ? .video : .voice
65
+ let call = Call(receiverUid: group.guid, receiverType: .group, callType: callType)
66
+
67
+ return try await withCheckedThrowingContinuation { cont in
68
+ CometChat.initiateCall(call: call,
69
+ onSuccess: { initiated in cont.resume(returning: initiated) },
70
+ onError: { error in cont.resume(throwing: error) })
71
+ }
72
+ }
73
+ ```
74
+
75
+ Receiver type is `.group` — anyone in the group can `acceptCall` until the call ends.
76
+
77
+ ---
78
+
79
+ ## Roster as `UICollectionView`
80
+
81
+ Multi-party rosters scale poorly with `UIStackView`. Use `UICollectionView` with a `UICollectionViewDiffableDataSource` for smooth roster updates:
82
+
83
+ ```swift
84
+ import UIKit
85
+ import CometChatCallsSDK
86
+
87
+ final class ParticipantRosterController: NSObject, UICollectionViewDelegateFlowLayout {
88
+ enum Section { case main }
89
+ typealias DataSource = UICollectionViewDiffableDataSource<Section, Participant>
90
+ typealias Snapshot = NSDiffableDataSourceSnapshot<Section, Participant>
91
+
92
+ private let collectionView: UICollectionView
93
+ private lazy var dataSource = makeDataSource()
94
+ private var participants: [Participant] = []
95
+
96
+ init(collectionView: UICollectionView) {
97
+ self.collectionView = collectionView
98
+ super.init()
99
+ collectionView.delegate = self
100
+ }
101
+
102
+ func update(participants: [Participant]) {
103
+ self.participants = participants
104
+ var snapshot = Snapshot()
105
+ snapshot.appendSections([.main])
106
+ snapshot.appendItems(participants)
107
+ dataSource.apply(snapshot, animatingDifferences: true)
108
+ }
109
+
110
+ private func makeDataSource() -> DataSource {
111
+ let registration = UICollectionView.CellRegistration<ParticipantCell, Participant> { cell, _, p in
112
+ cell.configure(with: p)
113
+ }
114
+ return DataSource(collectionView: collectionView) { cv, indexPath, p in
115
+ cv.dequeueConfiguredReusableCell(using: registration, for: indexPath, item: p)
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ Diffable data source means roster updates animate cleanly without cell-recreation thrashing. Rule of thumb: 25-participant rosters render at 60fps on iPhone 12+.
122
+
123
+ ---
124
+
125
+ ## Active-speaker observation
126
+
127
+ `CometChatCallsSDK` exposes the active-speaker callback via `CometChatCallsEventsListener`. Wrap it for SwiftUI/Combine:
128
+
129
+ ```swift
130
+ final class CallStateObserver: ObservableObject {
131
+ @Published var activeSpeakerUid: String?
132
+ @Published var participants: [Participant] = []
133
+
134
+ private var debounceTimer: Timer?
135
+
136
+ func onActiveSpeakerUpdated(_ uid: String) {
137
+ debounceTimer?.invalidate()
138
+ debounceTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false) { [weak self] _ in
139
+ DispatchQueue.main.async {
140
+ self?.activeSpeakerUid = uid
141
+ }
142
+ }
143
+ }
144
+
145
+ func onUserListUpdated(_ users: [Participant]) {
146
+ DispatchQueue.main.async {
147
+ self.participants = users
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ 500ms debounce — same rule as RN/Angular. Without it, the spotlight tile jitters.
154
+
155
+ `@Published` works in both SwiftUI (via `@StateObject`) and UIKit (via Combine subscriptions). Pick one path; don't mix.
156
+
157
+ ---
158
+
159
+ ## SwiftUI spotlight layout
160
+
161
+ ```swift
162
+ struct GroupCallView: View {
163
+ @StateObject private var state = CallStateObserver()
164
+
165
+ var body: some View {
166
+ VStack(spacing: 8) {
167
+ if let speaker = activeSpeaker {
168
+ ParticipantTile(participant: speaker)
169
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
170
+ }
171
+
172
+ ScrollView(.horizontal, showsIndicators: false) {
173
+ HStack(spacing: 8) {
174
+ ForEach(others) { p in
175
+ ParticipantTile(participant: p)
176
+ .frame(width: 100, height: 130)
177
+ }
178
+ }
179
+ .padding(.horizontal)
180
+ }
181
+ .frame(height: 140)
182
+ }
183
+ }
184
+
185
+ private var activeSpeaker: Participant? {
186
+ if let uid = state.activeSpeakerUid {
187
+ return state.participants.first { $0.uid == uid }
188
+ }
189
+ return state.participants.first
190
+ }
191
+
192
+ private var others: [Participant] {
193
+ let speaker = activeSpeaker
194
+ return state.participants.filter { $0.uid != speaker?.uid && $0.uid != localUid }
195
+ }
196
+
197
+ private var localUid: String { CometChat.getLoggedInUser()?.uid ?? "" }
198
+ }
199
+ ```
200
+
201
+ The `Identifiable` conformance on `Participant` (with `id = uid`) is what makes `ForEach` reuse cells across roster updates. Without it, every update destroys + recreates every tile — same bug as RN/Angular.
202
+
203
+ ---
204
+
205
+ ## Moderator actions — UIKit Action Sheet
206
+
207
+ ```swift
208
+ extension GroupCallViewController {
209
+ @objc func participantTapped(_ sender: UITapGestureRecognizer) {
210
+ guard let cell = sender.view as? ParticipantCell,
211
+ let participant = cell.participant else { return }
212
+ guard canModerate else { return } // gate
213
+
214
+ let alert = UIAlertController(title: participant.name, message: nil, preferredStyle: .actionSheet)
215
+ alert.addAction(UIAlertAction(title: "Mute", style: .default) { _ in
216
+ Task { try? await CometChatCalls.muteUser(uid: participant.uid) }
217
+ })
218
+ alert.addAction(UIAlertAction(title: "Remove from call", style: .destructive) { _ in
219
+ Task { try? await CometChatCalls.removeUser(uid: participant.uid) }
220
+ })
221
+ alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
222
+
223
+ if let popover = alert.popoverPresentationController {
224
+ popover.sourceView = cell
225
+ popover.sourceRect = cell.bounds
226
+ }
227
+ present(alert, animated: true)
228
+ }
229
+
230
+ private var canModerate: Bool {
231
+ return group?.scope == "admin" || group?.scope == "moderator"
232
+ }
233
+ }
234
+ ```
235
+
236
+ `popoverPresentationController` is required on iPad — without it, action sheets crash on iPad.
237
+
238
+ ---
239
+
240
+ ## Capacity error handling
241
+
242
+ ```swift
243
+ final class GroupCallViewController: UIViewController {
244
+ func setupCallListener() {
245
+ let listener = CometChatCallsEventsListener()
246
+ listener.onError = { [weak self] error in
247
+ DispatchQueue.main.async {
248
+ switch error.code {
249
+ case "ERR_CALL_FULL":
250
+ self?.showAlert(title: "Call is full",
251
+ message: "This meeting has reached its participant limit.")
252
+ case "ERR_NOT_GROUP_MEMBER":
253
+ self?.showAlert(title: "Not a member",
254
+ message: "You're not a member of this group.")
255
+ default:
256
+ self?.showAlert(title: "Call error", message: error.message)
257
+ }
258
+ }
259
+ }
260
+ // ...
261
+ }
262
+
263
+ private func showAlert(title: String, message: String) {
264
+ let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
265
+ alert.addAction(UIAlertAction(title: "OK", style: .default))
266
+ present(alert, animated: true)
267
+ }
268
+ }
269
+ ```
270
+
271
+ `DispatchQueue.main.async` wraps the UI update — listener fires on a background queue.
272
+
273
+ ---
274
+
275
+ ## CallKit and group calls
276
+
277
+ CallKit was designed for 1:1 — its `CXCallUpdate` model has a single `remoteHandle`. Group calls don't fit cleanly. Two practical patterns:
278
+
279
+ ### A — Report group calls as a single "meeting" call
280
+
281
+ ```swift
282
+ let update = CXCallUpdate()
283
+ update.remoteHandle = CXHandle(type: .generic, value: group.guid)
284
+ update.localizedCallerName = "Meeting: \(group.name)"
285
+ update.hasVideo = isVideo
286
+ update.supportsHolding = false
287
+ update.supportsGrouping = false // CallKit "group" means call merging, not multi-party
288
+ update.supportsUngrouping = false
289
+ provider.reportNewIncomingCall(with: callUUID, update: update) { _ in }
290
+ ```
291
+
292
+ The user sees "Incoming meeting call from <Group Name>" in CallKit's lock-screen UI. No participant detail — that's in your app's UI after they accept.
293
+
294
+ ### B — Skip CallKit for group calls
295
+
296
+ Some apps treat group calls as a foreground-only experience and skip CallKit reporting entirely. Trade-off: no lock-screen ring → users miss meeting invitations. Only viable if your audience is reliably foregrounded (corporate apps with predictable usage).
297
+
298
+ The skill defaults to pattern A.
299
+
300
+ ---
301
+
302
+ ## Battery + low-power mode
303
+
304
+ iOS broadcasts `NSProcessInfoPowerStateDidChangeNotification` when the user enables Low Power Mode. Auto-downgrade video:
305
+
306
+ ```swift
307
+ NotificationCenter.default.addObserver(
308
+ self,
309
+ selector: #selector(powerStateChanged),
310
+ name: NSNotification.Name.NSProcessInfoPowerStateDidChange,
311
+ object: nil)
312
+
313
+ @objc func powerStateChanged() {
314
+ if ProcessInfo.processInfo.isLowPowerModeEnabled && callActive {
315
+ Task {
316
+ await CometChatCalls.pauseVideo(true)
317
+ DispatchQueue.main.async {
318
+ self.showBanner("Video paused — Low Power Mode")
319
+ }
320
+ }
321
+ }
322
+ }
323
+ ```
324
+
325
+ Same pattern for `UIDevice.current.batteryLevel` (`isBatteryMonitoringEnabled = true` first), but Low Power Mode is the more reliable signal.
326
+
327
+ ---
328
+
329
+ ## Joining an in-progress call
330
+
331
+ ```swift
332
+ func checkActiveGroupCall(guid: String) async -> Call? {
333
+ guard let active = try? await fetchActiveCall() else { return nil }
334
+ guard active.receiverType == .group, active.receiverUid == guid else { return nil }
335
+ return active
336
+ }
337
+ ```
338
+
339
+ Render a "Join meeting" button on the group screen if there's an active call:
340
+
341
+ ```swift
342
+ struct GroupDetailView: View {
343
+ @State private var activeCall: Call?
344
+
345
+ var body: some View {
346
+ VStack {
347
+ if let call = activeCall {
348
+ Button("Join meeting") {
349
+ Task { await join(call: call) }
350
+ }
351
+ .buttonStyle(.borderedProminent)
352
+ }
353
+ // ... rest of group detail
354
+ }
355
+ .task {
356
+ activeCall = await checkActiveGroupCall(guid: group.guid)
357
+ }
358
+ }
359
+ }
360
+ ```
361
+
362
+ ---
363
+
364
+ ## Anti-patterns
365
+
366
+ 1. **Roster updates without `Identifiable` (or `IndexPath` reuse identifier)**. Cells thrash on every update; video tracks die with them.
367
+ 2. **No active-speaker debounce.** Spotlight tile jitters at 5+ Hz.
368
+ 3. **`UIAlertController` action sheet on iPad without `popoverPresentationController`.** Crash.
369
+ 4. **Moderator buttons rendered without scope check.** Backend rejects but UI is misleading.
370
+ 5. **No `DispatchQueue.main.async` wrapping** SDK callbacks. UI updates skipped.
371
+ 6. **Skipping CallKit for group calls without a lock-screen ring fallback.** Missed meetings.
372
+ 7. **CallKit `supportsGrouping = true`.** That's CallKit's call-merging feature; doesn't mean multi-party. Set to false.
373
+
374
+ ---
375
+
376
+ ## Verification checklist
377
+
378
+ - [ ] `Participant` conforms to `Identifiable` with `id = uid`
379
+ - [ ] `UICollectionViewDiffableDataSource` for UIKit OR `ForEach` with stable IDs for SwiftUI
380
+ - [ ] Active-speaker debounced ≥500ms via Timer or Combine `.debounce`
381
+ - [ ] All SDK callbacks dispatched to `DispatchQueue.main.async`
382
+ - [ ] Moderator buttons gated on `group.scope == "admin" || == "moderator"`
383
+ - [ ] iPad action sheets configure `popoverPresentationController`
384
+ - [ ] `ERR_CALL_FULL` and `ERR_NOT_GROUP_MEMBER` produce user-facing alerts
385
+ - [ ] Low Power Mode observer auto-pauses video
386
+ - [ ] CallKit pattern: meeting reported as `localizedCallerName: "Meeting: <Group Name>"` (or skipped intentionally)
387
+ - [ ] Active-call check on group screen entry; "Join meeting" button rendered when active
388
+
389
+ ---
390
+
391
+ ## Pointers
392
+
393
+ - `cometchat-native-calls/references/group-calls.md` — sister reference (SDK semantics, capacity, bandwidth scaling)
394
+ - `references/callkit-and-pushkit.md` — CallKit reporting pattern; group-call adaptation above
395
+ - `references/custom-ui.md` — UICollectionView roster integration with WebRTC views
396
+ - `cometchat-ios-calls` SKILL.md — base hard rules