@stream-io/video-react-native-sdk 1.30.5 → 1.31.1-beta.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 (248) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/android/src/main/AndroidManifest.xml +8 -1
  3. package/android/src/main/AndroidManifestNew.xml +11 -0
  4. package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +127 -5
  5. package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +70 -6
  6. package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +6 -4
  7. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +83 -0
  8. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +149 -0
  9. package/android/src/main/java/com/streamvideo/reactnative/screenshare/ScreenAudioCapture.kt +111 -0
  10. package/dist/commonjs/components/Call/CallControls/ScreenShareToggleButton.js +3 -2
  11. package/dist/commonjs/components/Call/CallControls/ScreenShareToggleButton.js.map +1 -1
  12. package/dist/commonjs/hooks/index.js +11 -0
  13. package/dist/commonjs/hooks/index.js.map +1 -1
  14. package/dist/commonjs/hooks/push/index.js +0 -2
  15. package/dist/commonjs/hooks/push/index.js.map +1 -1
  16. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +144 -0
  17. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  18. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  19. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  20. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +64 -97
  21. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  22. package/dist/commonjs/hooks/useScreenShareAudioMixing.js +126 -0
  23. package/dist/commonjs/hooks/useScreenShareAudioMixing.js.map +1 -0
  24. package/dist/commonjs/hooks/useScreenShareButton.js +57 -3
  25. package/dist/commonjs/hooks/useScreenShareButton.js.map +1 -1
  26. package/dist/commonjs/index.js +1 -0
  27. package/dist/commonjs/index.js.map +1 -1
  28. package/dist/commonjs/modules/ScreenShareAudioManager.js +54 -0
  29. package/dist/commonjs/modules/ScreenShareAudioManager.js.map +1 -0
  30. package/dist/commonjs/modules/call-manager/CallManager.js +26 -0
  31. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  32. package/dist/commonjs/providers/StreamCall/index.js +16 -6
  33. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  34. package/dist/commonjs/utils/StreamVideoRN/index.js +35 -21
  35. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  36. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +68 -0
  37. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +1 -0
  38. package/dist/commonjs/utils/internal/callingx/callingx.js +150 -0
  39. package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -0
  40. package/dist/commonjs/utils/internal/registerSDKGlobals.js +53 -3
  41. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  42. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +48 -0
  43. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +1 -0
  44. package/dist/commonjs/utils/push/android.js +135 -202
  45. package/dist/commonjs/utils/push/android.js.map +1 -1
  46. package/dist/commonjs/utils/push/internal/ios.js +17 -34
  47. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  48. package/dist/commonjs/utils/push/internal/rxSubjects.js +1 -45
  49. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  50. package/dist/commonjs/utils/push/internal/utils.js +71 -53
  51. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  52. package/dist/commonjs/utils/push/ios.js.map +1 -1
  53. package/dist/commonjs/utils/push/libs/callingx.js +75 -0
  54. package/dist/commonjs/utils/push/libs/callingx.js.map +1 -0
  55. package/dist/commonjs/utils/push/libs/index.js +8 -19
  56. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  57. package/dist/commonjs/utils/push/libs/notifee/index.js +0 -19
  58. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  59. package/dist/commonjs/utils/push/setupCallingExpEvents.js +105 -0
  60. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -0
  61. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +7 -6
  62. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  63. package/dist/commonjs/version.js +1 -1
  64. package/dist/commonjs/version.js.map +1 -1
  65. package/dist/module/components/Call/CallControls/ScreenShareToggleButton.js +3 -2
  66. package/dist/module/components/Call/CallControls/ScreenShareToggleButton.js.map +1 -1
  67. package/dist/module/hooks/index.js +1 -0
  68. package/dist/module/hooks/index.js.map +1 -1
  69. package/dist/module/hooks/push/index.js +0 -2
  70. package/dist/module/hooks/push/index.js.map +1 -1
  71. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +137 -0
  72. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  73. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  74. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  75. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +66 -99
  76. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  77. package/dist/module/hooks/useScreenShareAudioMixing.js +119 -0
  78. package/dist/module/hooks/useScreenShareAudioMixing.js.map +1 -0
  79. package/dist/module/hooks/useScreenShareButton.js +57 -3
  80. package/dist/module/hooks/useScreenShareButton.js.map +1 -1
  81. package/dist/module/index.js +1 -0
  82. package/dist/module/index.js.map +1 -1
  83. package/dist/module/modules/ScreenShareAudioManager.js +47 -0
  84. package/dist/module/modules/ScreenShareAudioManager.js.map +1 -0
  85. package/dist/module/modules/call-manager/CallManager.js +26 -0
  86. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  87. package/dist/module/providers/StreamCall/index.js +16 -6
  88. package/dist/module/providers/StreamCall/index.js.map +1 -1
  89. package/dist/module/utils/StreamVideoRN/index.js +35 -21
  90. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  91. package/dist/module/utils/internal/callingx/audioSessionPromise.js +61 -0
  92. package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +1 -0
  93. package/dist/module/utils/internal/callingx/callingx.js +140 -0
  94. package/dist/module/utils/internal/callingx/callingx.js.map +1 -0
  95. package/dist/module/utils/internal/registerSDKGlobals.js +53 -3
  96. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  97. package/dist/module/utils/keepCallAliveHeadlessTask.js +42 -0
  98. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +1 -0
  99. package/dist/module/utils/push/android.js +137 -204
  100. package/dist/module/utils/push/android.js.map +1 -1
  101. package/dist/module/utils/push/internal/ios.js +17 -34
  102. package/dist/module/utils/push/internal/ios.js.map +1 -1
  103. package/dist/module/utils/push/internal/rxSubjects.js +0 -44
  104. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  105. package/dist/module/utils/push/internal/utils.js +67 -50
  106. package/dist/module/utils/push/internal/utils.js.map +1 -1
  107. package/dist/module/utils/push/ios.js.map +1 -1
  108. package/dist/module/utils/push/libs/callingx.js +67 -0
  109. package/dist/module/utils/push/libs/callingx.js.map +1 -0
  110. package/dist/module/utils/push/libs/index.js +1 -2
  111. package/dist/module/utils/push/libs/index.js.map +1 -1
  112. package/dist/module/utils/push/libs/notifee/index.js +0 -18
  113. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  114. package/dist/module/utils/push/setupCallingExpEvents.js +99 -0
  115. package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -0
  116. package/dist/module/utils/push/setupIosVoipPushEvents.js +7 -6
  117. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  118. package/dist/module/version.js +1 -1
  119. package/dist/module/version.js.map +1 -1
  120. package/dist/typescript/components/Call/CallControls/ScreenShareToggleButton.d.ts +6 -1
  121. package/dist/typescript/components/Call/CallControls/ScreenShareToggleButton.d.ts.map +1 -1
  122. package/dist/typescript/hooks/index.d.ts +1 -0
  123. package/dist/typescript/hooks/index.d.ts.map +1 -1
  124. package/dist/typescript/hooks/push/index.d.ts.map +1 -1
  125. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +5 -0
  126. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -0
  127. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  128. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  129. package/dist/typescript/hooks/useScreenShareAudioMixing.d.ts +14 -0
  130. package/dist/typescript/hooks/useScreenShareAudioMixing.d.ts.map +1 -0
  131. package/dist/typescript/hooks/useScreenShareButton.d.ts +39 -2
  132. package/dist/typescript/hooks/useScreenShareButton.d.ts.map +1 -1
  133. package/dist/typescript/index.d.ts +1 -0
  134. package/dist/typescript/index.d.ts.map +1 -1
  135. package/dist/typescript/modules/ScreenShareAudioManager.d.ts +28 -0
  136. package/dist/typescript/modules/ScreenShareAudioManager.d.ts.map +1 -0
  137. package/dist/typescript/modules/call-manager/CallManager.d.ts +5 -0
  138. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  139. package/dist/typescript/providers/StreamCall/index.d.ts.map +1 -1
  140. package/dist/typescript/utils/StreamVideoRN/index.d.ts +22 -2
  141. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  142. package/dist/typescript/utils/StreamVideoRN/types.d.ts +59 -25
  143. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  144. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +16 -0
  145. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +1 -0
  146. package/dist/typescript/utils/internal/callingx/callingx.d.ts +18 -0
  147. package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +1 -0
  148. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  149. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +10 -0
  150. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +1 -0
  151. package/dist/typescript/utils/push/android.d.ts +1 -2
  152. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  153. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  154. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +0 -33
  155. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  156. package/dist/typescript/utils/push/internal/utils.d.ts +14 -8
  157. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  158. package/dist/typescript/utils/push/ios.d.ts +1 -2
  159. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  160. package/dist/typescript/utils/push/libs/callingx.d.ts +9 -0
  161. package/dist/typescript/utils/push/libs/callingx.d.ts.map +1 -0
  162. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +16 -2
  163. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  164. package/dist/typescript/utils/push/libs/index.d.ts +1 -2
  165. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  166. package/dist/typescript/utils/push/libs/notifee/index.d.ts +0 -1
  167. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  168. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +8 -0
  169. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -0
  170. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  171. package/dist/typescript/version.d.ts +1 -1
  172. package/dist/typescript/version.d.ts.map +1 -1
  173. package/expo-config-plugin/dist/withAndroidManifest.js +1 -33
  174. package/expo-config-plugin/dist/withAndroidPermissions.js +2 -7
  175. package/expo-config-plugin/dist/withAppDelegate.js +19 -197
  176. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  177. package/expo-config-plugin/dist/withiOSInfoPlist.js +2 -3
  178. package/ios/StreamInCallManager.m +2 -0
  179. package/ios/StreamInCallManager.swift +19 -7
  180. package/ios/StreamVideoReactNative.h +7 -4
  181. package/ios/StreamVideoReactNative.m +282 -86
  182. package/package.json +13 -18
  183. package/src/components/Call/CallControls/ScreenShareToggleButton.tsx +11 -1
  184. package/src/hooks/index.ts +1 -0
  185. package/src/hooks/push/index.ts +0 -2
  186. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +189 -0
  187. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
  188. package/src/hooks/useAndroidKeepCallAliveEffect.ts +94 -120
  189. package/src/hooks/useScreenShareAudioMixing.ts +130 -0
  190. package/src/hooks/useScreenShareButton.ts +87 -2
  191. package/src/index.ts +1 -0
  192. package/src/modules/ScreenShareAudioManager.ts +49 -0
  193. package/src/modules/call-manager/CallManager.ts +36 -0
  194. package/src/modules/call-manager/native-module.d.ts +7 -0
  195. package/src/providers/StreamCall/index.tsx +17 -6
  196. package/src/utils/StreamVideoRN/index.ts +42 -30
  197. package/src/utils/StreamVideoRN/types.ts +61 -25
  198. package/src/utils/internal/callingx/audioSessionPromise.ts +65 -0
  199. package/src/utils/internal/callingx/callingx.ts +194 -0
  200. package/src/utils/internal/registerSDKGlobals.ts +52 -4
  201. package/src/utils/keepCallAliveHeadlessTask.ts +54 -0
  202. package/src/utils/push/android.ts +198 -311
  203. package/src/utils/push/internal/ios.ts +28 -44
  204. package/src/utils/push/internal/rxSubjects.ts +0 -61
  205. package/src/utils/push/internal/utils.ts +108 -64
  206. package/src/utils/push/ios.ts +1 -6
  207. package/src/utils/push/libs/callingx.ts +89 -0
  208. package/src/utils/push/libs/index.ts +1 -2
  209. package/src/utils/push/libs/notifee/index.ts +0 -27
  210. package/src/utils/push/setupCallingExpEvents.ts +135 -0
  211. package/src/utils/push/setupIosVoipPushEvents.ts +11 -7
  212. package/src/version.ts +1 -1
  213. package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +0 -95
  214. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -160
  215. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  216. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +0 -67
  217. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +0 -1
  218. package/dist/commonjs/utils/push/libs/callkeep.js +0 -17
  219. package/dist/commonjs/utils/push/libs/callkeep.js.map +0 -1
  220. package/dist/commonjs/utils/push/libs/voipPushNotification.js +0 -17
  221. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +0 -1
  222. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +0 -205
  223. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +0 -1
  224. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -153
  225. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  226. package/dist/module/hooks/push/useProcessPushCallEffect.js +0 -60
  227. package/dist/module/hooks/push/useProcessPushCallEffect.js.map +0 -1
  228. package/dist/module/utils/push/libs/callkeep.js +0 -11
  229. package/dist/module/utils/push/libs/callkeep.js.map +0 -1
  230. package/dist/module/utils/push/libs/voipPushNotification.js +0 -11
  231. package/dist/module/utils/push/libs/voipPushNotification.js.map +0 -1
  232. package/dist/module/utils/push/setupIosCallKeepEvents.js +0 -199
  233. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +0 -1
  234. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +0 -5
  235. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +0 -1
  236. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts +0 -8
  237. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts.map +0 -1
  238. package/dist/typescript/utils/push/libs/callkeep.d.ts +0 -3
  239. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +0 -1
  240. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +0 -3
  241. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +0 -1
  242. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +0 -6
  243. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +0 -1
  244. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +0 -235
  245. package/src/hooks/push/useProcessPushCallEffect.ts +0 -108
  246. package/src/utils/push/libs/callkeep.ts +0 -16
  247. package/src/utils/push/libs/voipPushNotification.ts +0 -17
  248. package/src/utils/push/setupIosCallKeepEvents.ts +0 -252
@@ -5,6 +5,18 @@ import {
5
5
  } from '@stream-io/video-client';
6
6
  import type { AndroidChannel } from '@notifee/react-native';
7
7
 
8
+ export type AndroidChannelConfig = {
9
+ id: string;
10
+ name: string;
11
+ sound?: string;
12
+ vibration?: boolean;
13
+ };
14
+
15
+ export type KeepAliveAndroidNotificationTexts = {
16
+ title: string;
17
+ body: string;
18
+ };
19
+
8
20
  export type NonRingingPushEvent =
9
21
  | 'call.live_started'
10
22
  | 'call.notification'
@@ -32,6 +44,27 @@ export type StreamVideoConfig = {
32
44
  * @example "production-apn-video" or "staging-apn-video" based on the environment
33
45
  */
34
46
  pushProviderName?: string;
47
+ supportsVideo?: boolean;
48
+ /**
49
+ * Sound to play when an incoming call is received. Must be a valid sound resource name in the project.
50
+ * @default '' (no sound)
51
+ */
52
+ sound?: string;
53
+ /**
54
+ * Image to display when an incoming call is received. Must be a valid image resource name in the project.
55
+ * @default '' (no image)
56
+ */
57
+ imageName?: string;
58
+ /**
59
+ * Enable calls history. When enabled, the call will be added to the calls history.
60
+ * @default false
61
+ */
62
+ callsHistory?: boolean;
63
+ /**
64
+ * Timeout to display an incoming call. When the call is displayed for more than the timeout, the call will be rejected.
65
+ * @default 60000 (1 minute)
66
+ */
67
+ displayCallTimeout?: number;
35
68
  };
36
69
  android: {
37
70
  /**
@@ -61,28 +94,30 @@ export type StreamVideoConfig = {
61
94
  * The notification channel to be used for incoming calls for Android.
62
95
  * @example
63
96
  * {
64
- * id: 'stream_incoming_call',
65
- * name: 'Incoming call notifications',
66
- * importance: AndroidImportance.HIGH,
97
+ * id: 'incoming_calls_channel',
98
+ * name: 'Incoming calls',
99
+ * sound?: string;
100
+ * vibration?: boolean;
67
101
  * }
68
102
  */
69
- incomingCallChannel?: AndroidChannel;
103
+ incomingChannel?: AndroidChannelConfig;
70
104
  /**
71
- * Functions to create the texts shown in the notification for incoming calls in Android.
105
+ * Texts used for call state notifications while the system is connecting or declining the call.
106
+ * If not provided, platform defaults will be used.
72
107
  * @example
73
108
  * {
74
- * getTitle: (createdUserName: string) => `Incoming call from ${createdUserName}`,
75
- * getBody: (createdUserName: string) => `Tap to answer the call`
76
- * getAcceptButtonTitle?: () => `Accept`,
77
- * getDeclineButtonTitle?: () => `Decline`,
109
+ * accepting: 'Connecting...',
110
+ * rejecting: 'Declining...',
78
111
  * }
79
112
  */
80
- incomingCallNotificationTextGetters?: {
81
- getTitle: (createdUserName: string) => string;
82
- getBody: (createdUserName: string) => string;
83
- getAcceptButtonTitle?: () => string;
84
- getDeclineButtonTitle?: () => string;
113
+ notificationTexts?: {
114
+ accepting?: string;
115
+ rejecting?: string;
85
116
  };
117
+ /**
118
+ * The transformer to be used to transform the call title in the notification for ringing and ongoing calls for Android.
119
+ */
120
+ titleTransformer?: (memberName: string, incoming: boolean) => string;
86
121
  /**
87
122
  * Functions to create the texts shown in the notification for non ringing calls in Android.
88
123
  * @example
@@ -111,6 +146,16 @@ export type StreamVideoConfig = {
111
146
  getBody: (type: NonRingingPushEvent, createdUserName: string) => string;
112
147
  };
113
148
  };
149
+ /**
150
+ * Whether to enable ongoing calls.
151
+ * @default false
152
+ */
153
+ enableOngoingCalls?: boolean;
154
+ /**
155
+ * Whether to reject calls when the user is busy.
156
+ * @default false
157
+ */
158
+ shouldRejectCallWhenBusy?: boolean;
114
159
  /**
115
160
  * This function is used to create a custom video client.
116
161
  * This is used create a video client for incoming calls in the background and inform call events to the server.
@@ -130,12 +175,6 @@ export type StreamVideoConfig = {
130
175
  * }
131
176
  */
132
177
  createStreamVideoClient: () => Promise<StreamVideoClient | undefined>;
133
- /** @deprecated This method will be removed in the future. Please watch for incoming and outgoing calls in the root component of your app.
134
- Please see https://getstream.io/video/docs/react-native/advanced/ringing-calls/#watch-for-incoming-and-outgoing-calls for more information */
135
- navigateAcceptCall?: () => void;
136
- /** @deprecated This method will be removed in the future. Please watch for incoming and outgoing calls in the root component of your app.
137
- Please see https://getstream.io/video/docs/react-native/advanced/ringing-calls/#watch-for-incoming-and-outgoing-calls for more information */
138
- navigateToIncomingCall?: () => void;
139
178
  /** Callback that is called when a non ringing push notification was tapped */
140
179
  onTapNonRingingCallNotification?: (
141
180
  call_cid: string,
@@ -147,14 +186,11 @@ export type StreamVideoConfig = {
147
186
  /**
148
187
  * The notification channel to keep call alive in the background for Android using a foreground service.
149
188
  */
150
- channel: AndroidChannel;
189
+ channel: Omit<AndroidChannelConfig, 'sound' | 'vibration'>;
151
190
  /**
152
191
  * The texts shown in the notification to keep call alive in the background
153
192
  */
154
- notificationTexts: {
155
- title: string;
156
- body: string;
157
- };
193
+ notificationTexts: KeepAliveAndroidNotificationTexts;
158
194
  /**
159
195
  * The task to run in the foreground service
160
196
  * The task must resolve a promise once complete
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Module to manage pending promise for audio session activation.
3
+ * Used to wait for iOS CallKit's didActivateAudioSession event after starting a call.
4
+ */
5
+
6
+ import { videoLoggerSystem } from '@stream-io/video-client';
7
+
8
+ const logger = videoLoggerSystem.getLogger('callingx');
9
+
10
+ let pendingResolve: (() => void) | null = null;
11
+ let pendingTimeout: ReturnType<typeof setTimeout> | null = null;
12
+ let resolveSetTime: number | null = null;
13
+ /**
14
+ * Flag to check if the audio session is already activated.
15
+ * This solves race condition for a cold start case, when the audio session is activated before the promise is created.
16
+ */
17
+ let isAudioSessionAlreadyActivated = false;
18
+
19
+ const AUDIO_SESSION_TIMEOUT_MS = 5000;
20
+
21
+ /**
22
+ * Creates a promise that resolves when the audio session is activated,
23
+ * or after a timeout to prevent hanging indefinitely.
24
+ * @returns Promise that resolves when audio session is activated or timeout occurs
25
+ */
26
+ export function waitForAudioSessionActivation(): Promise<void> {
27
+ if (isAudioSessionAlreadyActivated) {
28
+ isAudioSessionAlreadyActivated = false;
29
+ return Promise.resolve();
30
+ }
31
+
32
+ resolveSetTime = Date.now();
33
+ return new Promise((resolve) => {
34
+ pendingResolve = resolve;
35
+ pendingTimeout = setTimeout(() => {
36
+ // Resolve on timeout to prevent hanging
37
+ logger.debug('audioSessionPromise timed out');
38
+ resolvePendingAudioSession();
39
+ }, AUDIO_SESSION_TIMEOUT_MS);
40
+ });
41
+ }
42
+
43
+ /**
44
+ * Resolves the pending audio session activation promise.
45
+ * Called when the didActivateAudioSession event fires or on timeout.
46
+ */
47
+ export function resolvePendingAudioSession(): void {
48
+ if (pendingTimeout) {
49
+ clearTimeout(pendingTimeout);
50
+ pendingTimeout = null;
51
+ }
52
+
53
+ if (pendingResolve) {
54
+ pendingResolve();
55
+ if (resolveSetTime) {
56
+ const elapsedTime = Date.now() - resolveSetTime;
57
+ resolveSetTime = null;
58
+ logger.debug(`audioSessionPromise resolved in ${elapsedTime}ms`);
59
+ }
60
+ pendingResolve = null;
61
+ isAudioSessionAlreadyActivated = false;
62
+ } else {
63
+ isAudioSessionAlreadyActivated = true;
64
+ }
65
+ }
@@ -0,0 +1,194 @@
1
+ /***
2
+ * Internal utils for callingx library usage from video-client.
3
+ * See @./registerSDKGlobals.ts for more usage details.
4
+ */
5
+ import { Platform } from 'react-native';
6
+ import type { EndCallReason } from '@stream-io/react-native-callingx';
7
+ import { getCallingxLibIfAvailable } from '../../push/libs/callingx';
8
+ import { waitForAudioSessionActivation } from './audioSessionPromise';
9
+ import type {
10
+ Call,
11
+ MemberResponse,
12
+ StreamVideoParticipant,
13
+ } from '@stream-io/video-client';
14
+ import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
15
+ const CallingxModule = getCallingxLibIfAvailable();
16
+
17
+ /**
18
+ * Gets the call display name. To be used for display in native call screen.
19
+ */
20
+ export function getCallDisplayName(
21
+ callMembers: MemberResponse[] | undefined,
22
+ participants: StreamVideoParticipant[] | undefined,
23
+ currentUserId: string | undefined,
24
+ ): string {
25
+ if (!callMembers || !participants || !currentUserId) {
26
+ return 'Call';
27
+ }
28
+
29
+ let names: string[] = [];
30
+
31
+ if (callMembers.length > 0) {
32
+ // for ringing calls, members array contains all call members from the very early state and participants array is empty in the beginning
33
+ names = callMembers
34
+ .filter((member) => member.user.id !== currentUserId)
35
+ .map((member) => member.user.name)
36
+ .filter((name): name is string => name !== undefined);
37
+ } else if (participants.length > 0) {
38
+ // for non-ringing calls, members array is empty and we rely on participants array there
39
+ names = participants
40
+ .filter((participant) => participant.userId !== currentUserId)
41
+ .map((participant) => participant.name)
42
+ .filter(Boolean);
43
+ }
44
+
45
+ // if no names are found, we use the name of the current user
46
+ if (names.length === 0) {
47
+ names = [
48
+ participants.find((participant) => participant.userId === currentUserId)
49
+ ?.name ?? 'Call',
50
+ ];
51
+ }
52
+
53
+ return names.sort().join(', ');
54
+ }
55
+
56
+ function getCallDisplayNameFromCall(call: Call): string {
57
+ return getCallDisplayName(
58
+ call.state.members,
59
+ call.state.participants,
60
+ call.currentUserId,
61
+ );
62
+ }
63
+
64
+ export async function registerOutgoingCall(call: Call) {
65
+ if (!CallingxModule || !CallingxModule.isSetup) {
66
+ return;
67
+ }
68
+
69
+ const isOutcomingCall = call.ringing && call.isCreatedByMe;
70
+ if (!isOutcomingCall) {
71
+ return;
72
+ }
73
+
74
+ const logger = videoLoggerSystem.getLogger('callingx');
75
+
76
+ try {
77
+ logger.debug(`registerOutgoingCall: Registering outgoing call ${call.cid}`);
78
+ await CallingxModule.startCall(
79
+ call.cid, // unique id for call
80
+ call.id, // phone number for display in dialer (we use call id as phone number)
81
+ getCallDisplayNameFromCall(call), // display name for display in call screen
82
+ call.state.settings?.video?.enabled ?? false, // is video call?
83
+ );
84
+ } catch (error) {
85
+ logger.error(
86
+ `registerOutgoingCall: Error registering outgoing call in callingx: ${call.cid}`,
87
+ error,
88
+ );
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Starts the call in the callingx library.
94
+ * It is done by client on every join
95
+ * Does either of the following:
96
+ * 1. Sets the state for outgoing calls in the callingx library
97
+ * 2. Displays the incoming call in the callingx library
98
+ * 3. Optionally for non-ringing calls also when ongoing calls are enabled.
99
+ */
100
+ export async function joinCallingxCall(call: Call, activeCalls: Call[]) {
101
+ if (!CallingxModule || !CallingxModule.isSetup) {
102
+ return;
103
+ }
104
+
105
+ const logger = videoLoggerSystem.getLogger('callingx');
106
+ const isOutcomingCall = call.ringing && call.isCreatedByMe;
107
+ const isIncomingCall = call.ringing && !call.isCreatedByMe;
108
+
109
+ if (
110
+ isOutcomingCall ||
111
+ (!call.ringing && CallingxModule.isOngoingCallsEnabled)
112
+ ) {
113
+ logger.debug(`joinCallingxCall: Joining call ${call.cid}`);
114
+ try {
115
+ await CallingxModule.startCall(
116
+ call.cid, // unique id for call
117
+ call.id, // phone number for display in dialer (we use call id as phone number)
118
+ getCallDisplayNameFromCall(call), // display name for display in call screen
119
+ call.state.settings?.video?.enabled ?? false, // is video call?
120
+ );
121
+
122
+ // Wait for audio session activation on iOS only
123
+ if (Platform.OS === 'ios') {
124
+ await waitForAudioSessionActivation();
125
+ }
126
+ } catch (error) {
127
+ logger.error(
128
+ `startCallingxCall: Error starting call in callingx: ${call.cid}`,
129
+ error,
130
+ );
131
+ }
132
+ } else if (isIncomingCall) {
133
+ logger.debug(`joinCallingxCall: Joining incoming call ${call.cid}`);
134
+ try {
135
+ // Leave any existing active ringing calls before joining a new ringing call
136
+ const activeCallsToLeave = activeCalls.filter(
137
+ (c) =>
138
+ c.cid !== call.cid &&
139
+ c.ringing &&
140
+ c.state.callingState !== CallingState.LEFT,
141
+ );
142
+ for (const activeCall of activeCallsToLeave) {
143
+ logger.debug(
144
+ `leaving active call ${activeCall.cid} before joining ${call.cid}`,
145
+ );
146
+ await activeCall.leave({ reason: 'cancel' }).catch((e) => {
147
+ logger.error(`failed to leave active call ${activeCall.cid}`, e);
148
+ });
149
+ }
150
+
151
+ // Awaits native CallKit/Telecom registration before answering.
152
+ // Safe to call even if the call is already registered (e.g. from VoIP push) --
153
+ // iOS early-returns with no error, Android sends the registered broadcast.
154
+ await CallingxModule.displayIncomingCall(
155
+ call.cid, // unique id for call
156
+ call.id, // phone number for display in dialer (we use call id as phone number)
157
+ getCallDisplayNameFromCall(call), // display name for display in call screen
158
+ call.state.settings?.video?.enabled ?? false, // is video call?
159
+ );
160
+
161
+ await CallingxModule.answerIncomingCall(call.cid);
162
+
163
+ if (Platform.OS === 'ios') {
164
+ await waitForAudioSessionActivation();
165
+ }
166
+ } catch (error) {
167
+ logger.error(
168
+ `Error displaying incoming call in callingx: ${call.cid}`,
169
+ error,
170
+ );
171
+ }
172
+ }
173
+ }
174
+
175
+ export async function endCallingxCall(call: Call, reason?: EndCallReason) {
176
+ if (
177
+ !CallingxModule ||
178
+ !CallingxModule.isSetup ||
179
+ !CallingxModule.isCallTracked(call.cid)
180
+ ) {
181
+ return;
182
+ }
183
+
184
+ const logger = videoLoggerSystem.getLogger('callingx');
185
+ try {
186
+ logger.debug(`endCallingxCall: Ending call ${call.cid}`);
187
+ await CallingxModule.endCallWithReason(call.cid, reason ?? 'local');
188
+ } catch (error) {
189
+ logger.error(
190
+ `endCallingxCall: Error ending call in callingx: ${call.cid}`,
191
+ error,
192
+ );
193
+ }
194
+ }
@@ -1,23 +1,71 @@
1
- import type { StreamRNVideoSDKGlobals } from '@stream-io/video-client';
1
+ import { StreamRNVideoSDKGlobals } from '@stream-io/video-client';
2
2
  import { NativeModules, PermissionsAndroid, Platform } from 'react-native';
3
+ import { getCallingxLibIfAvailable } from '../push/libs/callingx';
4
+ import {
5
+ endCallingxCall,
6
+ registerOutgoingCall,
7
+ joinCallingxCall,
8
+ } from './callingx/callingx';
3
9
 
4
10
  const StreamInCallManagerNativeModule = NativeModules.StreamInCallManager;
5
11
  const StreamVideoReactNativeModule = NativeModules.StreamVideoReactNative as {
6
12
  checkPermission: StreamRNVideoSDKGlobals['permissions']['check'] | undefined;
7
13
  };
8
14
 
15
+ const CallingxModule = getCallingxLibIfAvailable();
16
+
17
+ /**
18
+ * Checks if StreamInCallManager should be bypassed because CallKit is handling
19
+ * the audio session via CallingX.
20
+ *
21
+ * On iOS, when CallingX is set up and has a registered call, the audio session
22
+ * is managed by CallKit through CallingxImpl.swift.
23
+ * In this case, StreamInCallManager should not run to avoid conflicting audio
24
+ * session configurations.
25
+ */
26
+ const shouldBypassForCallKit = ({
27
+ isRingingTypeCall,
28
+ }: {
29
+ isRingingTypeCall: boolean;
30
+ }): boolean => {
31
+ if (Platform.OS !== 'ios') {
32
+ return false;
33
+ }
34
+ if (!CallingxModule) {
35
+ return false;
36
+ }
37
+ const bypass =
38
+ CallingxModule.isSetup &&
39
+ (isRingingTypeCall || CallingxModule.isOngoingCallsEnabled);
40
+ return bypass;
41
+ };
42
+
9
43
  const streamRNVideoSDKGlobals: StreamRNVideoSDKGlobals = {
44
+ callingX: {
45
+ joinCall: joinCallingxCall,
46
+ endCall: endCallingxCall,
47
+ registerOutgoingCall: registerOutgoingCall,
48
+ },
10
49
  callManager: {
11
- setup: ({ defaultDevice }) => {
50
+ setup: ({ defaultDevice, isRingingTypeCall }) => {
51
+ if (shouldBypassForCallKit({ isRingingTypeCall })) {
52
+ return;
53
+ }
12
54
  StreamInCallManagerNativeModule.setDefaultAudioDeviceEndpointType(
13
55
  defaultDevice,
14
56
  );
15
57
  StreamInCallManagerNativeModule.setup();
16
58
  },
17
- start: () => {
59
+ start: ({ isRingingTypeCall }) => {
60
+ if (shouldBypassForCallKit({ isRingingTypeCall })) {
61
+ return;
62
+ }
18
63
  StreamInCallManagerNativeModule.start();
19
64
  },
20
- stop: () => {
65
+ stop: ({ isRingingTypeCall }) => {
66
+ if (shouldBypassForCallKit({ isRingingTypeCall })) {
67
+ return;
68
+ }
21
69
  StreamInCallManagerNativeModule.stop();
22
70
  },
23
71
  },
@@ -0,0 +1,54 @@
1
+ import { AppRegistry, Platform } from 'react-native';
2
+ import type { Call } from '@stream-io/video-client';
3
+ import { videoLoggerSystem } from '@stream-io/video-client';
4
+ import { StreamVideoRN } from './StreamVideoRN';
5
+
6
+ export const KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = 'StreamVideoKeepCallAlive';
7
+
8
+ /**
9
+ * The keep-alive headless task needs access to the active `Call` instance.
10
+ * The keep-alive hook will set this reference before starting the native service.
11
+ */
12
+ export const keepCallAliveCallRef: { current: Call | undefined } = {
13
+ current: undefined,
14
+ };
15
+
16
+ function registerKeepCallAliveHeadlessTaskOnce() {
17
+ if (Platform.OS !== 'android') return;
18
+
19
+ AppRegistry.registerHeadlessTask(
20
+ KEEP_CALL_ALIVE_HEADLESS_TASK_NAME,
21
+ () => async (data: { callCid?: string } | undefined) => {
22
+ const logger = videoLoggerSystem.getLogger(
23
+ 'KEEP_CALL_ALIVE_HEADLESS_TASK',
24
+ );
25
+ const callCid = data?.callCid;
26
+
27
+ const call = keepCallAliveCallRef.current;
28
+ if (!call) {
29
+ logger.warn(
30
+ 'No active call instance available for keep-alive task; skipping.',
31
+ { callCid },
32
+ );
33
+ return;
34
+ }
35
+ if (callCid && call.cid && call.cid !== callCid) {
36
+ logger.warn(
37
+ 'Keep-alive task callCid does not match active call; skipping.',
38
+ { callCid, activeCallCid: call.cid },
39
+ );
40
+ return;
41
+ }
42
+
43
+ const config = StreamVideoRN.getConfig();
44
+ const taskToRun = config.foregroundService.android.taskToRun;
45
+ try {
46
+ await taskToRun(call);
47
+ } catch (e) {
48
+ logger.error('Keep-alive headless task failed', e);
49
+ }
50
+ },
51
+ );
52
+ }
53
+
54
+ registerKeepCallAliveHeadlessTaskOnce();