@cometchat/skills 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/bin/install.js +298 -41
  2. package/package.json +1 -1
  3. package/skills/cometchat/SKILL.md +146 -27
  4. package/skills/cometchat-a11y/SKILL.md +476 -0
  5. package/skills/cometchat-android-v5/SKILL.md +1 -1
  6. package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
  7. package/skills/cometchat-android-v5-calls/references/README.md +53 -0
  8. package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
  9. package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
  10. package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
  11. package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
  12. package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
  13. package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
  14. package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
  15. package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
  16. package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
  17. package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
  18. package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
  19. package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
  20. package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
  21. package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
  22. package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
  23. package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
  24. package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
  25. package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
  26. package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
  27. package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
  28. package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
  29. package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
  30. package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
  31. package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
  32. package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
  33. package/skills/cometchat-android-v5-components/SKILL.md +1 -1
  34. package/skills/cometchat-android-v5-core/SKILL.md +1 -1
  35. package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
  36. package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
  37. package/skills/cometchat-android-v5-features/SKILL.md +1 -1
  38. package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
  39. package/skills/cometchat-android-v5-production/SKILL.md +1 -1
  40. package/skills/cometchat-android-v5-push/SKILL.md +1 -1
  41. package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
  42. package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
  43. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
  44. package/skills/cometchat-android-v6/SKILL.md +1 -1
  45. package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
  46. package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
  47. package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
  48. package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
  49. package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
  50. package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
  51. package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
  52. package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
  53. package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
  54. package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
  55. package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
  56. package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
  57. package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
  58. package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
  59. package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
  60. package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
  61. package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
  62. package/skills/cometchat-android-v6-core/SKILL.md +1 -1
  63. package/skills/cometchat-android-v6-events/SKILL.md +1 -1
  64. package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
  65. package/skills/cometchat-android-v6-features/SKILL.md +1 -1
  66. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
  67. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
  68. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
  69. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
  70. package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
  71. package/skills/cometchat-android-v6-production/SKILL.md +1 -1
  72. package/skills/cometchat-android-v6-push/SKILL.md +1 -1
  73. package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
  74. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
  75. package/skills/cometchat-angular-calls/SKILL.md +511 -0
  76. package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
  77. package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
  78. package/skills/cometchat-angular-calls/references/call-session.md +167 -0
  79. package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
  80. package/skills/cometchat-angular-calls/references/device-management.md +135 -0
  81. package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
  82. package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
  83. package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
  84. package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
  85. package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
  86. package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
  87. package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
  88. package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
  89. package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
  90. package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
  91. package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
  92. package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
  93. package/skills/cometchat-angular-components/SKILL.md +1 -1
  94. package/skills/cometchat-angular-core/SKILL.md +1 -1
  95. package/skills/cometchat-angular-customization/SKILL.md +1 -1
  96. package/skills/cometchat-angular-features/SKILL.md +1 -1
  97. package/skills/cometchat-angular-patterns/SKILL.md +1 -1
  98. package/skills/cometchat-angular-placement/SKILL.md +1 -1
  99. package/skills/cometchat-angular-production/SKILL.md +1 -1
  100. package/skills/cometchat-angular-push/SKILL.md +403 -0
  101. package/skills/cometchat-angular-testing/SKILL.md +333 -0
  102. package/skills/cometchat-angular-theming/SKILL.md +1 -1
  103. package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
  104. package/skills/cometchat-astro-patterns/SKILL.md +1 -1
  105. package/skills/cometchat-calls/SKILL.md +358 -0
  106. package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
  107. package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
  108. package/skills/cometchat-calls/references/use-case-support.md +190 -0
  109. package/skills/cometchat-calls/references/use-case-team.md +169 -0
  110. package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
  111. package/skills/cometchat-components/SKILL.md +1 -1
  112. package/skills/cometchat-core/SKILL.md +1 -1
  113. package/skills/cometchat-customization/SKILL.md +2 -2
  114. package/skills/cometchat-features/SKILL.md +2 -2
  115. package/skills/cometchat-flutter-v5/SKILL.md +1 -1
  116. package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
  117. package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
  118. package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
  119. package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
  120. package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
  121. package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
  122. package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
  123. package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
  124. package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
  125. package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
  126. package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
  127. package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
  128. package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
  129. package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
  130. package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
  131. package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
  132. package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
  133. package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
  134. package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
  135. package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
  136. package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
  137. package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
  138. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
  139. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
  140. package/skills/cometchat-flutter-v6/SKILL.md +1 -1
  141. package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
  142. package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
  143. package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
  144. package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
  145. package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
  146. package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
  147. package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
  148. package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
  149. package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
  150. package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
  151. package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
  152. package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
  153. package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
  154. package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
  155. package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
  156. package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
  157. package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
  158. package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
  159. package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
  160. package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
  161. package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
  162. package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
  163. package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
  164. package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
  165. package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
  166. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
  167. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
  168. package/skills/cometchat-i18n/SKILL.md +358 -0
  169. package/skills/cometchat-ios/SKILL.md +5 -5
  170. package/skills/cometchat-ios-calls/SKILL.md +409 -0
  171. package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
  172. package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
  173. package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
  174. package/skills/cometchat-ios-calls/references/call-session.md +221 -0
  175. package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
  176. package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
  177. package/skills/cometchat-ios-calls/references/device-management.md +171 -0
  178. package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
  179. package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
  180. package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
  181. package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
  182. package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
  183. package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
  184. package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
  185. package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
  186. package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
  187. package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
  188. package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
  189. package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
  190. package/skills/cometchat-ios-components/SKILL.md +1 -1
  191. package/skills/cometchat-ios-core/SKILL.md +1 -1
  192. package/skills/cometchat-ios-customization/SKILL.md +1 -1
  193. package/skills/cometchat-ios-features/SKILL.md +1 -1
  194. package/skills/cometchat-ios-placement/SKILL.md +1 -1
  195. package/skills/cometchat-ios-production/SKILL.md +1 -1
  196. package/skills/cometchat-ios-push/SKILL.md +1 -1
  197. package/skills/cometchat-ios-testing/SKILL.md +371 -0
  198. package/skills/cometchat-ios-theming/SKILL.md +1 -1
  199. package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
  200. package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
  201. package/skills/cometchat-native-calls/SKILL.md +599 -0
  202. package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
  203. package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
  204. package/skills/cometchat-native-calls/references/call-session.md +182 -0
  205. package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
  206. package/skills/cometchat-native-calls/references/device-management.md +135 -0
  207. package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
  208. package/skills/cometchat-native-calls/references/group-calls.md +291 -0
  209. package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
  210. package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
  211. package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
  212. package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
  213. package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
  214. package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
  215. package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
  216. package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
  217. package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
  218. package/skills/cometchat-native-calls/references/share-invite.md +144 -0
  219. package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
  220. package/skills/cometchat-native-components/SKILL.md +1 -1
  221. package/skills/cometchat-native-core/SKILL.md +1 -1
  222. package/skills/cometchat-native-customization/SKILL.md +1 -1
  223. package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
  224. package/skills/cometchat-native-features/SKILL.md +1 -1
  225. package/skills/cometchat-native-placement/SKILL.md +1 -1
  226. package/skills/cometchat-native-production/SKILL.md +1 -1
  227. package/skills/cometchat-native-push/SKILL.md +1 -1
  228. package/skills/cometchat-native-testing/SKILL.md +1 -1
  229. package/skills/cometchat-native-theming/SKILL.md +1 -1
  230. package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
  231. package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
  232. package/skills/cometchat-placement/SKILL.md +1 -1
  233. package/skills/cometchat-production/SKILL.md +1 -1
  234. package/skills/cometchat-react-calls/SKILL.md +539 -0
  235. package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
  236. package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
  237. package/skills/cometchat-react-calls/references/call-session.md +235 -0
  238. package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
  239. package/skills/cometchat-react-calls/references/device-management.md +206 -0
  240. package/skills/cometchat-react-calls/references/group-calls.md +262 -0
  241. package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
  242. package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
  243. package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
  244. package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
  245. package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
  246. package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
  247. package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
  248. package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
  249. package/skills/cometchat-react-calls/references/share-invite.md +176 -0
  250. package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
  251. package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
  252. package/skills/cometchat-react-patterns/SKILL.md +1 -1
  253. package/skills/cometchat-react-push/SKILL.md +448 -0
  254. package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
  255. package/skills/cometchat-react-testing/SKILL.md +404 -0
  256. package/skills/cometchat-theming/SKILL.md +3 -3
  257. package/skills/cometchat-troubleshooting/SKILL.md +2 -2
@@ -0,0 +1,189 @@
1
+ # AVAudioSession routing for iOS calls
2
+
3
+ The most-overlooked piece of iOS calls. Without correct `AVAudioSession` configuration, calls sound like the user is talking through an earpiece even with the speaker on, or background music doesn't resume after hangup.
4
+
5
+ ---
6
+
7
+ ## The four states that matter
8
+
9
+ | State | When |
10
+ |---|---|
11
+ | Inactive | App not in a call |
12
+ | Active + .playAndRecord, .voiceChat | Active call (voice or video) |
13
+ | Active + .playAndRecord, .videoChat | Active video call (slightly different routing — closer to face) |
14
+ | Inactive + .notifyOthersOnDeactivation | Just hung up — tells music apps to resume |
15
+
16
+ ---
17
+
18
+ ## On call start
19
+
20
+ ```swift
21
+ import AVFoundation
22
+
23
+ func configureForCall(isVideo: Bool) throws {
24
+ let session = AVAudioSession.sharedInstance()
25
+
26
+ try session.setCategory(
27
+ .playAndRecord,
28
+ mode: isVideo ? .videoChat : .voiceChat,
29
+ options: [.allowBluetooth, .allowBluetoothA2DP, .defaultToSpeaker]
30
+ )
31
+
32
+ try session.setActive(true)
33
+ }
34
+ ```
35
+
36
+ `mode: .voiceChat` enables echo cancellation and noise suppression optimized for voice calls. `mode: .videoChat` does the same but defaults to a slightly louder speaker volume (designed for handsfree use).
37
+
38
+ `.allowBluetooth` allows AirPods, hearing aids. `.allowBluetoothA2DP` allows Bluetooth speakers. `.defaultToSpeaker` makes voice calls speakerphone by default — without it, calls route to the earpiece, which feels wrong for a video call.
39
+
40
+ ---
41
+
42
+ ## On hangup — the canonical bug fix
43
+
44
+ ```swift
45
+ func endCall() {
46
+ // CometChatCalls.endSession() does NOT exist on iOS — use leaveSession on CallSession.shared
47
+ CometChatCallsSDK.CallSession.shared.leaveSession()
48
+
49
+ do {
50
+ try AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
51
+ } catch {
52
+ // Best-effort — don't block hangup on this
53
+ print("Failed to deactivate audio session: \(error)")
54
+ }
55
+ }
56
+ ```
57
+
58
+ `.notifyOthersOnDeactivation` is the magic. Without it:
59
+
60
+ - Music app was paused by the call → stays paused
61
+ - Other apps' audio was ducked → stays ducked
62
+ - The user thinks the music app is broken
63
+
64
+ With it, the system tells other audio sessions "the call's done, resume what you were doing."
65
+
66
+ ---
67
+
68
+ ## Switching speaker on/off mid-call
69
+
70
+ ```swift
71
+ func toggleSpeaker(on: Bool) throws {
72
+ let session = AVAudioSession.sharedInstance()
73
+ try session.overrideOutputAudioPort(on ? .speaker : .none)
74
+ }
75
+ ```
76
+
77
+ `.none` doesn't mean "no audio" — it means "use the system's default routing for this category" (which for `.playAndRecord` + `.voiceChat` is the receiver/earpiece).
78
+
79
+ ---
80
+
81
+ ## Detecting Bluetooth + AirPods + hearing aids
82
+
83
+ ```swift
84
+ func currentAudioRoute() -> String {
85
+ let route = AVAudioSession.sharedInstance().currentRoute
86
+ let outputs = route.outputs.map { $0.portType.rawValue }
87
+ // Common values: "Speaker", "Receiver", "BluetoothA2DPOutput", "BluetoothHFP", "BuiltInReceiver"
88
+ return outputs.first ?? "unknown"
89
+ }
90
+
91
+ func observeRouteChanges() {
92
+ NotificationCenter.default.addObserver(
93
+ forName: AVAudioSession.routeChangeNotification,
94
+ object: nil,
95
+ queue: .main
96
+ ) { notification in
97
+ // User plugged in headphones / unplugged AirPods
98
+ print("Route changed: \(self.currentAudioRoute())")
99
+ }
100
+ }
101
+ ```
102
+
103
+ For UI: show a "Speaker / AirPods / Bluetooth" indicator in the call control panel based on `currentAudioRoute()`.
104
+
105
+ ---
106
+
107
+ ## CallKit + AVAudioSession — they fight if you don't coordinate
108
+
109
+ CallKit's `provider(_:didActivate:)` callback fires when CallKit takes over the audio session (typically when the user answers from the lock screen). If you call `setActive(true)` yourself in the answer handler, CallKit might do it again and you get warnings.
110
+
111
+ **Pattern:**
112
+
113
+ ```swift
114
+ extension CallManager: CXProviderDelegate {
115
+ func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
116
+ // CallKit just activated the session — do post-activation work
117
+ // (e.g. start the WebRTC session)
118
+ if let pendingSessionId = self.pendingActivation {
119
+ startCometChatCallsSession(sessionID: pendingSessionId)
120
+ self.pendingActivation = nil
121
+ }
122
+ }
123
+
124
+ func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
125
+ // CallKit deactivated — your cleanup runs in CXEndCallAction
126
+ }
127
+
128
+ func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
129
+ // Configure category but DO NOT set active
130
+ try? AVAudioSession.sharedInstance().setCategory(
131
+ .playAndRecord, mode: .voiceChat,
132
+ options: [.allowBluetooth, .defaultToSpeaker]
133
+ )
134
+
135
+ // Store sessionId; defer joinSession to didActivate
136
+ self.pendingActivation = pendingSessionIds[action.callUUID]
137
+ action.fulfill()
138
+ }
139
+ }
140
+ ```
141
+
142
+ CallKit calls `setActive(true)` for you when it's done with its lock-screen UI. You call `joinSession` from `didActivate`.
143
+
144
+ For non-CallKit-driven calls (outgoing from inside the app), you do `setActive(true)` yourself.
145
+
146
+ ---
147
+
148
+ ## Common failure modes
149
+
150
+ | Symptom | Cause | Fix |
151
+ |---|---|---|
152
+ | Music doesn't resume after call | Missing `.notifyOthersOnDeactivation` | Add to `setActive(false, ...)` call |
153
+ | Voice call sounds quiet, like through phone receiver | Missing `.defaultToSpeaker` option | Add to `setCategory` options |
154
+ | Bluetooth headphones not used during call | Missing `.allowBluetooth` option | Add to `setCategory` options |
155
+ | CXAnswerCallAction races with `setActive(true)` | Manual `setActive(true)` in answer handler | Defer `joinSession` to `didActivate` |
156
+ | Echo / feedback during voice call | Wrong `mode` (e.g. `.default` instead of `.voiceChat`) | Use `.voiceChat` or `.videoChat` |
157
+ | Call audio works in foreground but cuts in background | UIBackgroundModes missing `audio` | Add `audio` to `Info.plist` UIBackgroundModes |
158
+
159
+ ---
160
+
161
+ ## Audio session interruptions
162
+
163
+ Phone calls (the actual phone, not your VoIP) can interrupt your call:
164
+
165
+ ```swift
166
+ NotificationCenter.default.addObserver(
167
+ forName: AVAudioSession.interruptionNotification,
168
+ object: AVAudioSession.sharedInstance(),
169
+ queue: .main
170
+ ) { notification in
171
+ guard let userInfo = notification.userInfo,
172
+ let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt,
173
+ let type = AVAudioSession.InterruptionType(rawValue: typeValue) else { return }
174
+
175
+ switch type {
176
+ case .began:
177
+ // Phone call started — pause our call's audio (CallKit may auto-handle this for you)
178
+ CometChatCalls.muteAudio(true)
179
+ case .ended:
180
+ // Phone call ended — resume
181
+ CometChatCalls.muteAudio(false)
182
+ try? AVAudioSession.sharedInstance().setActive(true)
183
+ @unknown default:
184
+ break
185
+ }
186
+ }
187
+ ```
188
+
189
+ If you've integrated CallKit fully, iOS handles most of this — your VoIP call shows up as a "second call" in the system UI and the user can choose which to keep.
@@ -0,0 +1,136 @@
1
+ # Call layouts on iOS
2
+
3
+ Same three layouts (TILE/SIDEBAR/SPOTLIGHT). iOS-specific: `UISegmentedControl` is the native pattern for the switcher; layout selection persists across the app via `UserDefaults`.
4
+
5
+ **Canonical docs:** https://www.cometchat.com/docs/calls/ios/call-layouts
6
+ **Read first:** `cometchat-react-calls/references/call-layouts.md` — layout matrix.
7
+
8
+ ---
9
+
10
+ ## SDK API
11
+
12
+ ```swift
13
+ import CometChatCallsSDK
14
+
15
+ let settings = CallSettingsBuilder()
16
+ .setSessionType(.video)
17
+ .setLayout(.tile) // .tile | .sidebar | .spotlight
18
+ .setHideChangeLayoutButton(false)
19
+ .build()
20
+
21
+ // Mid-call switch
22
+ CometChatCalls.setLayout(.spotlight)
23
+
24
+ // Listen
25
+ class CallEvents: CometChatCallsEventsListener {
26
+ func onCallLayoutChanged(layout: CallLayout) {
27
+ DispatchQueue.main.async {
28
+ // Update UI
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ---
35
+
36
+ ## SwiftUI switcher
37
+
38
+ ```swift
39
+ import SwiftUI
40
+
41
+ enum CallLayoutPicker: String, CaseIterable, Identifiable {
42
+ case tile = "Tile"
43
+ case sidebar = "Sidebar"
44
+ case spotlight = "Spotlight"
45
+ var id: String { rawValue }
46
+
47
+ var sdkLayout: CallLayout {
48
+ switch self {
49
+ case .tile: return .tile
50
+ case .sidebar: return .sidebar
51
+ case .spotlight: return .spotlight
52
+ }
53
+ }
54
+ }
55
+
56
+ struct LayoutSwitcher: View {
57
+ @State private var selection: CallLayoutPicker = .tile
58
+
59
+ var body: some View {
60
+ Picker("Layout", selection: $selection) {
61
+ ForEach(CallLayoutPicker.allCases) { opt in
62
+ Text(opt.rawValue).tag(opt)
63
+ }
64
+ }
65
+ .pickerStyle(.segmented)
66
+ .accessibilityLabel("Call layout")
67
+ .onChange(of: selection) { _, new in
68
+ CometChatCalls.setLayout(new.sdkLayout)
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ `Picker(.segmented)` renders as `UISegmentedControl`, which is the iOS-native expected pattern for radio-group selection.
75
+
76
+ ---
77
+
78
+ ## Persisting the user's preference
79
+
80
+ ```swift
81
+ extension UserDefaults {
82
+ var preferredCallLayout: CallLayout {
83
+ get {
84
+ switch string(forKey: "preferredCallLayout") {
85
+ case "sidebar": return .sidebar
86
+ case "spotlight": return .spotlight
87
+ default: return .tile
88
+ }
89
+ }
90
+ set {
91
+ let str: String = {
92
+ switch newValue {
93
+ case .tile: return "tile"
94
+ case .sidebar: return "sidebar"
95
+ case .spotlight: return "spotlight"
96
+ @unknown default: return "tile"
97
+ }
98
+ }()
99
+ set(str, forKey: "preferredCallLayout")
100
+ }
101
+ }
102
+ }
103
+
104
+ // In your CallViewController:
105
+ let settings = CallSettingsBuilder()
106
+ .setLayout(UserDefaults.standard.preferredCallLayout)
107
+ .build()
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Anti-patterns
113
+
114
+ Web sister rules apply, plus iOS-specific:
115
+
116
+ 1. **`Picker(.menu)` instead of `.segmented`.** Wrong UX — menu hides the options, segmented shows them. For 3 options, segmented is the iOS norm.
117
+ 2. **`onChange` on background queue.** Crash. SwiftUI's `onChange` is on main but if you bridge through Combine make sure to `.receive(on: DispatchQueue.main)`.
118
+ 3. **Forgetting to `.accessibilityLabel`.** VoiceOver announces "Picker" with no context.
119
+
120
+ ---
121
+
122
+ ## Verification checklist
123
+
124
+ - [ ] Initial layout via `setLayout` on builder
125
+ - [ ] SwiftUI `Picker(.segmented)` for switcher
126
+ - [ ] Layout listener implemented in `CometChatCallsEventsListener`
127
+ - [ ] User preference persisted via `UserDefaults` if desired
128
+ - [ ] Real-device smoke: switcher cycles all 3, persists across calls
129
+
130
+ ---
131
+
132
+ ## Pointers
133
+
134
+ - `cometchat-react-calls/references/call-layouts.md` — sister
135
+ - `cometchat-ios-calls` SKILL.md
136
+ - Canonical docs: https://www.cometchat.com/docs/calls/ios/call-layouts
@@ -0,0 +1,221 @@
1
+ # Call session — joinSession with no ringing (iOS)
2
+
3
+ Server-generated sessionId, both parties enter it. Customer-validated against `~/Downloads/calls-sdk/calls-sdk-ios-5/sample-apps/cometchat-calls-sample-app-ios/CometChatCallsSample/CallView.swift`.
4
+
5
+ **Read first:** `cometchat-react-calls/references/call-session.md` — cross-platform architecture (sessionId strategies, server-side authorization). Then come back here for the iOS shape.
6
+
7
+ **Known issue:** iOS V5 native (`CometChatCallsSDK`) is currently blocked upstream by a Cloudsmith 404 on the WebRTC binary. See `docs/known-issues-v4.2.0.md`. This file describes the correct shape for when the binary becomes available; the canonical pattern itself is sound.
8
+
9
+ ---
10
+
11
+ ## Hard rules (iOS-specific overrides on top of the cross-platform rules)
12
+
13
+ 1. **Use the `joinSession(sessionID:callSetting:container:onSuccess:onError:)` convenience method.** It handles token generation internally — you do NOT need to call `generateToken` separately. Matches the upstream sample exactly.
14
+ 2. **`SessionSettingsBuilder()` is the canonical settings shape** (chained `.setTitle().startVideoPaused(false).startAudioMuted(false).build()`). NOT `SessionSettings(sessionType:layout:)` — that initializer is the chat-side type.
15
+ 3. **`SessionStatusListener` protocol on a Coordinator object**, registered against `CometChatCallsSDK.CallSession.shared.addSessionStatusListener(...)`. NOT raw `CometChatCalls.addEventListener(.sessionLeft)` — that does not exist on iOS.
16
+ 4. **`onSessionLeft`, `onConnectionClosed`, `onSessionTimedOut` all trigger UI dismiss.** All three are real termination paths; ignoring any of them leaves the call view stranded.
17
+ 5. **For standalone session-only integrations, the Chat SDK is OPTIONAL.** The upstream iOS sample never imports `CometChatSDK` (the chat SDK). Keep `CometChat.init` / `CometChat.login` only for additive (chat + calls) integrations.
18
+ 6. **`AVAudioSession` activated with `.playAndRecord` + `.voiceChat`** — `.playback` mode captures NO mic input.
19
+
20
+ ---
21
+
22
+ ## SwiftUI + UIViewRepresentable (canonical shape)
23
+
24
+ ```swift
25
+ import SwiftUI
26
+ import CometChatCallsSDK
27
+
28
+ struct CallView: View {
29
+ let sessionID: String
30
+ @Environment(\.dismiss) private var dismiss
31
+ @State private var errorMessage: String?
32
+
33
+ var body: some View {
34
+ ZStack {
35
+ Color.black.ignoresSafeArea()
36
+ CallContainerView(
37
+ sessionID: sessionID,
38
+ onEnd: { dismiss() },
39
+ onError: { msg in errorMessage = msg }
40
+ )
41
+ }
42
+ .alert("Call Error", isPresented: .init(
43
+ get: { errorMessage != nil },
44
+ set: { if !$0 { errorMessage = nil; dismiss() } }
45
+ )) {
46
+ Button("OK") { errorMessage = nil; dismiss() }
47
+ } message: {
48
+ Text(errorMessage ?? "")
49
+ }
50
+ }
51
+ }
52
+
53
+ // MARK: - UIKit container bridging the Calls SDK
54
+
55
+ struct CallContainerView: UIViewRepresentable {
56
+ let sessionID: String
57
+ let onEnd: () -> Void
58
+ let onError: (String) -> Void
59
+
60
+ func makeUIView(context: Context) -> UIView {
61
+ let container = UIView()
62
+ container.backgroundColor = .black
63
+ startSession(container: container, coordinator: context.coordinator)
64
+ return container
65
+ }
66
+
67
+ func updateUIView(_ uiView: UIView, context: Context) {}
68
+
69
+ func makeCoordinator() -> Coordinator {
70
+ Coordinator(onEnd: onEnd)
71
+ }
72
+
73
+ private func startSession(container: UIView, coordinator: Coordinator) {
74
+ let settings = SessionSettingsBuilder()
75
+ .setTitle("CometChat Meeting")
76
+ .startVideoPaused(false)
77
+ .startAudioMuted(false)
78
+ .build()
79
+
80
+ // The convenience joinSession(sessionID:) generates the token internally.
81
+ // No separate generateToken call needed.
82
+ CometChatCalls.joinSession(
83
+ sessionID: sessionID,
84
+ callSetting: settings,
85
+ container: container
86
+ ) { success in
87
+ let session = CometChatCallsSDK.CallSession.shared
88
+ session.addSessionStatusListener(coordinator)
89
+ session.addButtonClickListener(coordinator)
90
+ } onError: { error in
91
+ DispatchQueue.main.async {
92
+ onError(error?.errorDescription ?? "Failed to join call")
93
+ }
94
+ }
95
+ }
96
+
97
+ class Coordinator: NSObject, SessionStatusListener, ButtonClickListener {
98
+ let onEnd: () -> Void
99
+
100
+ init(onEnd: @escaping () -> Void) {
101
+ self.onEnd = onEnd
102
+ }
103
+
104
+ // --- SessionStatusListener ---
105
+ func onSessionJoined() {}
106
+
107
+ func onSessionLeft() {
108
+ DispatchQueue.main.async { self.onEnd() }
109
+ }
110
+
111
+ func onConnectionClosed() {
112
+ DispatchQueue.main.async { self.onEnd() }
113
+ }
114
+
115
+ func onSessionTimedOut() {
116
+ DispatchQueue.main.async { self.onEnd() }
117
+ }
118
+
119
+ func onConnectionLost() {}
120
+ func onConnectionRestored() {}
121
+
122
+ // --- ButtonClickListener ---
123
+ func onLeaveSessionButtonClicked() {
124
+ CometChatCallsSDK.CallSession.shared.leaveSession()
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ **Why this shape:**
131
+
132
+ - **`UIViewRepresentable` bridging a `UIView` container**, not a raw SwiftUI view — the SDK draws into a `UIView` it owns and lays out internally. SwiftUI can't host that directly.
133
+ - **`joinSession(sessionID:callSetting:container:)` convenience** — generates the call token internally. No need for `CometChatCalls.generateToken(forSession:)` then `joinSession(callToken:)` two-step. The sample uses this and so should every customer.
134
+ - **`SessionSettingsBuilder().build()`** — chained builder ending in `.build()`. The non-builder `SessionSettings(sessionType:layout:)` is the chat-side type and rejects at runtime.
135
+ - **`Coordinator` implements `SessionStatusListener` AND `ButtonClickListener`** — register both against `CallSession.shared` AFTER `onSuccess` fires. Don't register against `CometChatCalls` — that's not where the events live.
136
+
137
+ ---
138
+
139
+ ## Required iOS configuration
140
+
141
+ `Info.plist`:
142
+ ```xml
143
+ <key>NSCameraUsageDescription</key>
144
+ <string>Camera is needed for video calls</string>
145
+ <key>NSMicrophoneUsageDescription</key>
146
+ <string>Microphone is needed for calls</string>
147
+ <key>UIBackgroundModes</key>
148
+ <array>
149
+ <string>audio</string>
150
+ <string>voip</string>
151
+ </array>
152
+ ```
153
+
154
+ `AVAudioSession` setup (call once at app launch):
155
+ ```swift
156
+ import AVFoundation
157
+
158
+ let session = AVAudioSession.sharedInstance()
159
+ try? session.setCategory(.playAndRecord, mode: .voiceChat, options: [.allowBluetooth, .defaultToSpeaker])
160
+ try? session.setActive(true)
161
+ ```
162
+
163
+ See `references/avaudiosession-routing.md` for full audio routing including AirPods / CarPlay handoff.
164
+
165
+ ---
166
+
167
+ ## Universal Link routing
168
+
169
+ `SceneDelegate.scene(_:continue:)`:
170
+ ```swift
171
+ func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
172
+ guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
173
+ let url = userActivity.webpageURL,
174
+ url.pathComponents.count >= 3,
175
+ url.pathComponents[1] == "meet" else { return }
176
+ let sessionID = url.pathComponents[2]
177
+ router.routeToCallView(sessionID: sessionID)
178
+ }
179
+ ```
180
+
181
+ Configure `applinks:yourapp.com` per `references/share-invite.md`.
182
+
183
+ ---
184
+
185
+ ## Anti-patterns
186
+
187
+ 1. **Calling `CometChatCalls.generateToken(forSession:)` then `joinSession(callToken:)`.** Two-step doesn't match the sample — the sample uses the single-call `joinSession(sessionID:)` convenience. Prior versions of this skill cited the two-step; it works but is not the canonical iOS shape.
188
+ 2. **`SessionSettings(sessionType:layout:)` initializer.** Wrong type — that's the chat-side entity. Use `SessionSettingsBuilder()...build()`.
189
+ 3. **`CometChatCalls.addEventListener(.sessionLeft)`** — iOS uses the protocol-based `SessionStatusListener`, not a string-keyed listener API.
190
+ 4. **Skipping `onConnectionClosed` and `onSessionTimedOut` callbacks.** User's call ends via either of these (network drop, server timeout) → call view stays mounted forever.
191
+ 5. **Calling `joinSession` from `viewDidAppear`.** Re-runs on every navigation push. Use `viewDidLoad` + a `joined` flag, OR use `UIViewRepresentable` + Coordinator (the sample's pattern).
192
+ 6. **`AVAudioSession.setCategory(.playback)`.** Mic input doesn't capture. Use `.playAndRecord` + `.voiceChat` mode.
193
+ 7. **`async/await` on `joinSession`.** It returns void with completion handlers — `try await` does nothing.
194
+ 8. **Initializing Chat SDK for a session-only integration.** Wastes time and adds two extra failure modes. Drop `CometChat.init` / `CometChat.login` entirely for standalone session apps.
195
+
196
+ ---
197
+
198
+ ## Verification checklist
199
+
200
+ - [ ] `joinSession(sessionID:callSetting:container:)` used (single-call), NOT `generateToken` + `joinSession(callToken:)` two-step
201
+ - [ ] Settings built via `SessionSettingsBuilder()`, not `SessionSettings(sessionType:layout:)`
202
+ - [ ] `SessionStatusListener` protocol implemented on a Coordinator class
203
+ - [ ] Coordinator registered via `CallSession.shared.addSessionStatusListener(...)` AFTER `onSuccess`
204
+ - [ ] `onSessionLeft`, `onConnectionClosed`, `onSessionTimedOut` ALL trigger dismiss
205
+ - [ ] `Info.plist` has `NSCameraUsageDescription`, `NSMicrophoneUsageDescription`, `UIBackgroundModes: audio, voip`
206
+ - [ ] `AVAudioSession.setCategory(.playAndRecord, mode: .voiceChat, ...)`
207
+ - [ ] Universal Link routing wired in SceneDelegate
208
+ - [ ] **Standalone session-only:** no `CometChatSDK` (chat SDK) import — Calls SDK alone
209
+ - [ ] **Additive (chat + calls):** dual-SDK contract preserved
210
+ - [ ] Real-device smoke: tap meeting link in Messages → app opens at `/meet/:sessionID` → joins
211
+
212
+ ---
213
+
214
+ ## Pointers
215
+
216
+ - `cometchat-react-calls/references/call-session.md` — cross-platform architecture
217
+ - `cometchat-ios-calls/SKILL.md` — iOS seven hard rules
218
+ - `cometchat-ios-calls/references/share-invite.md` — Universal Link config
219
+ - `cometchat-ios-calls/references/avaudiosession-routing.md` — audio session routing
220
+ - Upstream iOS sample — `~/Downloads/calls-sdk/calls-sdk-ios-5/sample-apps/cometchat-calls-sample-app-ios/CometChatCallsSample/CallView.swift`
221
+ - Canonical docs: https://www.cometchat.com/docs/calls/ios/join-session