@stream-io/video-react-native-sdk 1.29.0-beta.3 → 1.29.1

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 (224) hide show
  1. package/CHANGELOG.md +3126 -0
  2. package/android/src/main/AndroidManifest.xml +1 -8
  3. package/android/src/main/AndroidManifestNew.xml +0 -11
  4. package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +5 -42
  5. package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +6 -70
  6. package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +4 -6
  7. package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +95 -0
  8. package/dist/commonjs/components/Call/CallContent/CallContent.js +7 -2
  9. package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
  10. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +8 -1
  11. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  12. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +3 -0
  13. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  14. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
  15. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  16. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  17. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  18. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +97 -64
  19. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  20. package/dist/commonjs/index.js +0 -1
  21. package/dist/commonjs/index.js.map +1 -1
  22. package/dist/commonjs/modules/call-manager/CallManager.js +0 -26
  23. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  24. package/dist/commonjs/providers/StreamCall/index.js +6 -6
  25. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  26. package/dist/commonjs/utils/StreamVideoRN/index.js +21 -33
  27. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  28. package/dist/commonjs/utils/internal/registerSDKGlobals.js +15 -52
  29. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  30. package/dist/commonjs/utils/push/android.js +202 -155
  31. package/dist/commonjs/utils/push/android.js.map +1 -1
  32. package/dist/commonjs/utils/push/internal/ios.js +32 -16
  33. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  34. package/dist/commonjs/utils/push/internal/rxSubjects.js +20 -1
  35. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  36. package/dist/commonjs/utils/push/internal/utils.js +16 -28
  37. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  38. package/dist/commonjs/utils/push/ios.js.map +1 -1
  39. package/dist/commonjs/utils/push/libs/callkeep.js +17 -0
  40. package/dist/commonjs/utils/push/libs/callkeep.js.map +1 -0
  41. package/dist/commonjs/utils/push/libs/index.js +19 -8
  42. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  43. package/dist/commonjs/utils/push/libs/notifee/index.js +19 -0
  44. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  45. package/dist/commonjs/utils/push/libs/voipPushNotification.js +17 -0
  46. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +1 -0
  47. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +205 -0
  48. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
  49. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
  50. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  51. package/dist/commonjs/version.js +1 -1
  52. package/dist/commonjs/version.js.map +1 -1
  53. package/dist/module/components/Call/CallContent/CallContent.js +7 -2
  54. package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
  55. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +8 -1
  56. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  57. package/dist/module/components/Call/CallContent/RTCViewPipNative.js +3 -0
  58. package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  59. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +153 -0
  60. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  61. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  62. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  63. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +99 -66
  64. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  65. package/dist/module/index.js +0 -1
  66. package/dist/module/index.js.map +1 -1
  67. package/dist/module/modules/call-manager/CallManager.js +0 -26
  68. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  69. package/dist/module/providers/StreamCall/index.js +6 -6
  70. package/dist/module/providers/StreamCall/index.js.map +1 -1
  71. package/dist/module/utils/StreamVideoRN/index.js +21 -33
  72. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  73. package/dist/module/utils/internal/registerSDKGlobals.js +16 -53
  74. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  75. package/dist/module/utils/push/android.js +204 -157
  76. package/dist/module/utils/push/android.js.map +1 -1
  77. package/dist/module/utils/push/internal/ios.js +32 -16
  78. package/dist/module/utils/push/internal/ios.js.map +1 -1
  79. package/dist/module/utils/push/internal/rxSubjects.js +19 -0
  80. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  81. package/dist/module/utils/push/internal/utils.js +15 -25
  82. package/dist/module/utils/push/internal/utils.js.map +1 -1
  83. package/dist/module/utils/push/ios.js.map +1 -1
  84. package/dist/module/utils/push/libs/callkeep.js +11 -0
  85. package/dist/module/utils/push/libs/callkeep.js.map +1 -0
  86. package/dist/module/utils/push/libs/index.js +2 -1
  87. package/dist/module/utils/push/libs/index.js.map +1 -1
  88. package/dist/module/utils/push/libs/notifee/index.js +18 -0
  89. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  90. package/dist/module/utils/push/libs/voipPushNotification.js +11 -0
  91. package/dist/module/utils/push/libs/voipPushNotification.js.map +1 -0
  92. package/dist/module/utils/push/setupIosCallKeepEvents.js +199 -0
  93. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
  94. package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
  95. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  96. package/dist/module/version.js +1 -1
  97. package/dist/module/version.js.map +1 -1
  98. package/dist/typescript/components/Call/CallContent/CallContent.d.ts +2 -2
  99. package/dist/typescript/components/Call/CallContent/CallContent.d.ts.map +1 -1
  100. package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts +4 -0
  101. package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
  102. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +9 -6
  103. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -1
  104. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
  105. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -0
  106. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  107. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  108. package/dist/typescript/index.d.ts +0 -1
  109. package/dist/typescript/index.d.ts.map +1 -1
  110. package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
  111. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  112. package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -20
  113. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  114. package/dist/typescript/utils/StreamVideoRN/types.d.ts +29 -54
  115. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  116. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  117. package/dist/typescript/utils/push/android.d.ts +2 -1
  118. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  119. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  120. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +12 -0
  121. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  122. package/dist/typescript/utils/push/internal/utils.d.ts +1 -8
  123. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  124. package/dist/typescript/utils/push/ios.d.ts +2 -1
  125. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  126. package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
  127. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
  128. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +2 -16
  129. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  130. package/dist/typescript/utils/push/libs/index.d.ts +2 -1
  131. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  132. package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
  133. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  134. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
  135. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
  136. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
  137. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
  138. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  139. package/dist/typescript/version.d.ts +1 -1
  140. package/dist/typescript/version.d.ts.map +1 -1
  141. package/expo-config-plugin/dist/withAndroidManifest.js +33 -1
  142. package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
  143. package/expo-config-plugin/dist/withAppDelegate.js +197 -19
  144. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  145. package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
  146. package/ios/PictureInPicture/StreamAVPictureInPictureVideoCallViewController.swift +8 -0
  147. package/ios/PictureInPicture/StreamPictureInPictureController.swift +8 -0
  148. package/ios/PictureInPicture/StreamPictureInPictureVideoRenderer.swift +10 -0
  149. package/ios/RTCViewPip.swift +6 -0
  150. package/ios/RTCViewPipManager.mm +1 -0
  151. package/ios/StreamInCallManager.m +0 -2
  152. package/ios/StreamInCallManager.swift +7 -19
  153. package/ios/StreamVideoReactNative.h +4 -7
  154. package/ios/StreamVideoReactNative.m +102 -191
  155. package/package.json +19 -14
  156. package/src/components/Call/CallContent/CallContent.tsx +6 -1
  157. package/src/components/Call/CallContent/RTCViewPipIOS.tsx +18 -2
  158. package/src/components/Call/CallContent/RTCViewPipNative.tsx +4 -7
  159. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
  160. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
  161. package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
  162. package/src/index.ts +0 -1
  163. package/src/modules/call-manager/CallManager.ts +0 -36
  164. package/src/modules/call-manager/native-module.d.ts +0 -7
  165. package/src/providers/StreamCall/index.tsx +6 -6
  166. package/src/utils/StreamVideoRN/index.ts +30 -40
  167. package/src/utils/StreamVideoRN/types.ts +29 -56
  168. package/src/utils/internal/registerSDKGlobals.ts +23 -47
  169. package/src/utils/push/android.ts +309 -231
  170. package/src/utils/push/internal/ios.ts +42 -27
  171. package/src/utils/push/internal/rxSubjects.ts +29 -0
  172. package/src/utils/push/internal/utils.ts +15 -38
  173. package/src/utils/push/ios.ts +6 -1
  174. package/src/utils/push/libs/callkeep.ts +16 -0
  175. package/src/utils/push/libs/index.ts +2 -1
  176. package/src/utils/push/libs/notifee/index.ts +27 -0
  177. package/src/utils/push/libs/voipPushNotification.ts +17 -0
  178. package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
  179. package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
  180. package/src/version.ts +1 -1
  181. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
  182. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -134
  183. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -121
  184. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  185. package/dist/commonjs/utils/internal/audioSessionPromise.js +0 -57
  186. package/dist/commonjs/utils/internal/audioSessionPromise.js.map +0 -1
  187. package/dist/commonjs/utils/internal/callingx.js +0 -136
  188. package/dist/commonjs/utils/internal/callingx.js.map +0 -1
  189. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
  190. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
  191. package/dist/commonjs/utils/push/libs/callingx.js +0 -75
  192. package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
  193. package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -97
  194. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
  195. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -114
  196. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  197. package/dist/module/utils/internal/audioSessionPromise.js +0 -50
  198. package/dist/module/utils/internal/audioSessionPromise.js.map +0 -1
  199. package/dist/module/utils/internal/callingx.js +0 -127
  200. package/dist/module/utils/internal/callingx.js.map +0 -1
  201. package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
  202. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
  203. package/dist/module/utils/push/libs/callingx.js +0 -67
  204. package/dist/module/utils/push/libs/callingx.js.map +0 -1
  205. package/dist/module/utils/push/setupCallingExpEvents.js +0 -91
  206. package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
  207. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
  208. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
  209. package/dist/typescript/utils/internal/audioSessionPromise.d.ts +0 -16
  210. package/dist/typescript/utils/internal/audioSessionPromise.d.ts.map +0 -1
  211. package/dist/typescript/utils/internal/callingx.d.ts +0 -13
  212. package/dist/typescript/utils/internal/callingx.d.ts.map +0 -1
  213. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
  214. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
  215. package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
  216. package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
  217. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
  218. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
  219. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -147
  220. package/src/utils/internal/audioSessionPromise.ts +0 -52
  221. package/src/utils/internal/callingx.ts +0 -192
  222. package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
  223. package/src/utils/push/libs/callingx.ts +0 -90
  224. package/src/utils/push/setupCallingExpEvents.ts +0 -117
@@ -1,91 +0,0 @@
1
- import { pushAcceptedIncomingCallCId$ } from './internal/rxSubjects';
2
- import { videoLoggerSystem } from '@stream-io/video-client';
3
- import { clearPushWSEventSubscriptions, processCallFromPushInBackground } from './internal/utils';
4
- import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
5
- import { resolvePendingAudioSession } from '../internal/audioSessionPromise';
6
- import { getCallingxLib } from './libs/callingx';
7
- import { Platform } from 'react-native';
8
- const logger = videoLoggerSystem.getLogger('Callingx');
9
-
10
- /**
11
- * This hook is used to listen to callkeep events and do the necessary actions
12
- */
13
- export function setupCallingExpEvents(pushConfig) {
14
- const hasPushProvider = Platform.OS === 'android' && pushConfig.android?.pushProviderName || Platform.OS === 'ios' && pushConfig.ios?.pushProviderName;
15
- if (!hasPushProvider) {
16
- return;
17
- }
18
- const callingx = getCallingxLib();
19
- const {
20
- remove: removeAnswerCall
21
- } = callingx.addEventListener('answerCall', onAcceptCall);
22
- const {
23
- remove: removeEndCall
24
- } = callingx.addEventListener('endCall', onEndCall(pushConfig));
25
- const {
26
- remove: removeDidActivateAudioSession
27
- } = callingx.addEventListener('didActivateAudioSession', onDidActivateAudioSession);
28
- const {
29
- remove: removeDidDeactivateAudioSession
30
- } = callingx.addEventListener('didDeactivateAudioSession', onDidDeactivateAudioSession);
31
-
32
- //NOTE: until getInitialEvents invocation, events are delayed and won't be sent to event listeners, this is a way to make sure none of required events are missed
33
- //in most cases there will be no delayed answers or ends, but it we don't want to miss any of them
34
- const events = callingx.getInitialEvents();
35
- events.forEach(event => {
36
- const {
37
- eventName,
38
- params
39
- } = event;
40
- if (eventName === 'answerCall') {
41
- logger.debug(`answerCall delayed event callId: ${params?.callId}`);
42
- onAcceptCall(params);
43
- } else if (eventName === 'endCall') {
44
- logger.debug(`endCall delayed event callId: ${params?.callId}`);
45
- onEndCall(pushConfig)(params);
46
- } else if (eventName === 'didActivateAudioSession') {
47
- onDidActivateAudioSession();
48
- } else if (eventName === 'didDeactivateAudioSession') {
49
- onDidDeactivateAudioSession();
50
- }
51
- });
52
- setPushLogoutCallback(async () => {
53
- removeAnswerCall();
54
- removeEndCall();
55
- removeDidActivateAudioSession();
56
- removeDidDeactivateAudioSession();
57
- });
58
- }
59
- const onDidActivateAudioSession = () => {
60
- logger.debug('callingExpDidActivateAudioSession');
61
- resolvePendingAudioSession();
62
- };
63
- const onDidDeactivateAudioSession = () => {
64
- logger.debug('callingExpDidDeactivateAudioSession');
65
- };
66
- const onAcceptCall = ({
67
- callId: call_cid,
68
- source
69
- }) => {
70
- logger.debug(`onAcceptCall event callId: ${call_cid} source: ${source}`);
71
- if (source === 'app' || !call_cid) {
72
- //we only need to process the call if the call was answered from the system
73
- return;
74
- }
75
- clearPushWSEventSubscriptions(call_cid);
76
- // to process the call in the app
77
- pushAcceptedIncomingCallCId$.next(call_cid);
78
- };
79
- const onEndCall = pushConfig => async ({
80
- callId: call_cid,
81
- source
82
- }) => {
83
- logger.debug(`onEndCall event callId: ${call_cid} source: ${source}`);
84
- if (source === 'app' || !call_cid) {
85
- //we only need to process the call if the call was rejected from the system
86
- return;
87
- }
88
- clearPushWSEventSubscriptions(call_cid);
89
- await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
90
- };
91
- //# sourceMappingURL=setupCallingExpEvents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["pushAcceptedIncomingCallCId$","videoLoggerSystem","clearPushWSEventSubscriptions","processCallFromPushInBackground","setPushLogoutCallback","resolvePendingAudioSession","getCallingxLib","Platform","logger","getLogger","setupCallingExpEvents","pushConfig","hasPushProvider","OS","android","pushProviderName","ios","callingx","remove","removeAnswerCall","addEventListener","onAcceptCall","removeEndCall","onEndCall","removeDidActivateAudioSession","onDidActivateAudioSession","removeDidDeactivateAudioSession","onDidDeactivateAudioSession","events","getInitialEvents","forEach","event","eventName","params","debug","callId","call_cid","source","next"],"sourceRoot":"../../../../src","sources":["utils/push/setupCallingExpEvents.ts"],"mappings":"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","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- /**
2
- * This hook is used to inform sync call state with CallKit/Telecom (i.e. start call, end call, mute/unmute call).
3
- */
4
- export declare const useCallingExpWithCallingStateEffect: () => void;
5
- //# sourceMappingURL=useCallingExpWithCallingStateEffect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCallingExpWithCallingStateEffect.d.ts","sourceRoot":"","sources":["../../../../src/hooks/push/useCallingExpWithCallingStateEffect.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,eAAO,MAAM,mCAAmC,YAqI/C,CAAC"}
@@ -1,16 +0,0 @@
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
- * Creates a promise that resolves when the audio session is activated,
7
- * or after a timeout to prevent hanging indefinitely.
8
- * @returns Promise that resolves when audio session is activated or timeout occurs
9
- */
10
- export declare function waitForAudioSessionActivation(): Promise<void>;
11
- /**
12
- * Resolves the pending audio session activation promise.
13
- * Called when the didActivateAudioSession event fires or on timeout.
14
- */
15
- export declare function resolvePendingAudioSession(): void;
16
- //# sourceMappingURL=audioSessionPromise.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audioSessionPromise.d.ts","sourceRoot":"","sources":["../../../../src/utils/internal/audioSessionPromise.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;GAIG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC,CAY7D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAajD"}
@@ -1,13 +0,0 @@
1
- import { Call, MemberResponse, StreamVideoParticipant } from '@stream-io/video-client';
2
- /**
3
- * Gets the call display name. To be used for display in native call screen.
4
- */
5
- export declare function getCallDisplayName(callMembers: MemberResponse[] | undefined, participants: StreamVideoParticipant[] | undefined, currentUserId: string | undefined): string;
6
- /**
7
- * Starts the call in the callingx library.
8
- * Must be called for all outgoing calls
9
- * and optionally for non-ringing calls when ongoing calls are enabled.
10
- */
11
- export declare function startCallingxCall(call: Call): Promise<void>;
12
- export declare function endCallingxCall(call: Call): Promise<void>;
13
- //# sourceMappingURL=callingx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"callingx.d.ts","sourceRoot":"","sources":["../../../../src/utils/internal/callingx.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,IAAI,EACJ,cAAc,EACd,sBAAsB,EAEvB,MAAM,yBAAyB,CAAC;AAKjC;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,cAAc,EAAE,GAAG,SAAS,EACzC,YAAY,EAAE,sBAAsB,EAAE,GAAG,SAAS,EAClD,aAAa,EAAE,MAAM,GAAG,SAAS,UA+BlC;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,iBAgEjD;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,iBAgB/C"}
@@ -1,10 +0,0 @@
1
- import type { Call } from '@stream-io/video-client';
2
- export declare const KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = "StreamVideoKeepCallAlive";
3
- /**
4
- * The keep-alive headless task needs access to the active `Call` instance.
5
- * The keep-alive hook will set this reference before starting the native service.
6
- */
7
- export declare const keepCallAliveCallRef: {
8
- current: Call | undefined;
9
- };
10
- //# sourceMappingURL=keepCallAliveHeadlessTask.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keepCallAliveHeadlessTask.d.ts","sourceRoot":"","sources":["../../../src/utils/keepCallAliveHeadlessTask.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAIpD,eAAO,MAAM,kCAAkC,6BAA6B,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE;IAAE,OAAO,EAAE,IAAI,GAAG,SAAS,CAAA;CAE7D,CAAC"}
@@ -1,9 +0,0 @@
1
- import { StreamVideoConfig } from '../../StreamVideoRN/types';
2
- export type RNCallingxType = import('@stream-io/react-native-callingx').ICallingxModule;
3
- export type EventData = import('@stream-io/react-native-callingx').EventData;
4
- export type EventParams = import('@stream-io/react-native-callingx').EventParams;
5
- export type CallingExpOptions = import('@stream-io/react-native-callingx').CallingExpOptions;
6
- export declare function getCallingxLib(): import("@stream-io/react-native-callingx").ICallingxModule;
7
- export declare function getCallingxLibIfAvailable(): import("@stream-io/react-native-callingx").ICallingxModule | undefined;
8
- export declare function extractCallingExpOptions(config: StreamVideoConfig): CallingExpOptions;
9
- //# sourceMappingURL=callingx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"callingx.d.ts","sourceRoot":"","sources":["../../../../../src/utils/push/libs/callingx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,MAAM,cAAc,GACxB,OAAO,kCAAkC,EAAE,eAAe,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,OAAO,kCAAkC,EAAE,SAAS,CAAC;AAC7E,MAAM,MAAM,WAAW,GACrB,OAAO,kCAAkC,EAAE,WAAW,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAC3B,OAAO,kCAAkC,EAAE,iBAAiB,CAAC;AAQ/D,wBAAgB,cAAc,+DAK7B;AAED,wBAAgB,yBAAyB,2EAExC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,iBAAiB,GACxB,iBAAiB,CA4DnB"}
@@ -1,8 +0,0 @@
1
- import type { StreamVideoConfig } from '../StreamVideoRN/types';
2
- type PushConfig = NonNullable<StreamVideoConfig['push']>;
3
- /**
4
- * This hook is used to listen to callkeep events and do the necessary actions
5
- */
6
- export declare function setupCallingExpEvents(pushConfig: NonNullable<PushConfig>): void;
7
- export {};
8
- //# sourceMappingURL=setupCallingExpEvents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupCallingExpEvents.d.ts","sourceRoot":"","sources":["../../../../src/utils/push/setupCallingExpEvents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAchE,KAAK,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AAIzD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,QAqDxE"}
@@ -1,147 +0,0 @@
1
- import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
2
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
3
- import { useEffect, useMemo, useRef } from 'react';
4
- import { getCallDisplayName } from '../../utils/internal/callingx';
5
- import { getCallingxLibIfAvailable } from '../../utils/push/libs/callingx';
6
-
7
- const logger = videoLoggerSystem.getLogger(
8
- 'Callingx - useCallingExpWithCallingStateEffect',
9
- );
10
-
11
- /**
12
- * This hook is used to inform sync call state with CallKit/Telecom (i.e. start call, end call, mute/unmute call).
13
- */
14
- export const useCallingExpWithCallingStateEffect = () => {
15
- const { useMicrophoneState, useParticipants, useCallMembers } =
16
- useCallStateHooks();
17
-
18
- const activeCall = useCall();
19
- const { isMute, microphone } = useMicrophoneState();
20
- const callMembers = useCallMembers();
21
- const participants = useParticipants();
22
-
23
- const activeCallCid = activeCall?.cid;
24
- const currentUserId = activeCall?.currentUserId;
25
-
26
- const callDisplayName = useMemo(
27
- () => getCallDisplayName(callMembers, participants, currentUserId),
28
- [callMembers, participants, currentUserId],
29
- );
30
-
31
- useEffect(() => {
32
- return () => {
33
- const callingx = getCallingxLibIfAvailable();
34
- if (!callingx?.isSetup || !activeCallCid) {
35
- return;
36
- }
37
-
38
- const isCallRegistered = callingx.isCallRegistered(activeCallCid);
39
- if (!isCallRegistered) {
40
- logger.debug(
41
- `No active call cid to end in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
42
- );
43
- return;
44
- }
45
- //if incoming stream call was unmounted, we need to end the call in CallKit/Telecom
46
- logger.debug(`Ending call in callingx: ${activeCallCid}`);
47
- callingx
48
- .endCallWithReason(activeCallCid, 'local')
49
- .catch((error: unknown) => {
50
- logger.error(
51
- `Error ending call in callingx: ${activeCallCid}`,
52
- error,
53
- );
54
- });
55
- };
56
- }, [activeCallCid]);
57
-
58
- useEffect(() => {
59
- const callingx = getCallingxLibIfAvailable();
60
- if (!callingx?.isSetup || !activeCallCid) {
61
- return;
62
- }
63
-
64
- const isCallRegistered = callingx.isCallRegistered(activeCallCid);
65
- if (!isCallRegistered) {
66
- logger.debug(
67
- `No active call cid to update callingx: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
68
- );
69
- return;
70
- }
71
-
72
- callingx.updateDisplay(activeCallCid, activeCallCid, callDisplayName);
73
- }, [activeCallCid, callDisplayName]);
74
-
75
- // Sync microphone mute state from app → CallKit
76
- useEffect(() => {
77
- const callingx = getCallingxLibIfAvailable();
78
- if (!callingx?.isSetup || !activeCallCid) {
79
- return;
80
- }
81
-
82
- const isCallRegistered = callingx.isCallRegistered(activeCallCid);
83
- if (!isCallRegistered) {
84
- logger.debug(
85
- `No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
86
- );
87
- return;
88
- }
89
-
90
- callingx.setMutedCall(activeCallCid, isMute);
91
- }, [activeCallCid, isMute]);
92
-
93
- // Sync mute state from CallKit → app (only for system-initiated mute actions)
94
- useEffect(() => {
95
- const callingx = getCallingxLibIfAvailable();
96
- if (!callingx?.isSetup || !activeCallCid) {
97
- logger.debug(
98
- `No active call cid to set muted in calling exp: ${activeCallCid} callingx isSetup: ${callingx?.isSetup}`,
99
- );
100
- return;
101
- }
102
-
103
- // Listen to mic toggle events from CallKit/Telecom and update stream call microphone state.
104
- // Only system-initiated mute actions (e.g. user tapped mute on the native CallKit UI)
105
- // are sent here — app-initiated actions are filtered out on the native side to prevent
106
- // the feedback loop: app mutes mic → setMutedCall → CallKit delegate → event to JS → loop.
107
- const subscription = callingx.addEventListener(
108
- 'didPerformSetMutedCallAction',
109
- async (event: { callId: string; muted: boolean }) => {
110
- const { callId, muted } = event;
111
-
112
- const isCallRegistered = callingx.isCallRegistered(activeCallCid);
113
- if (!isCallRegistered || callId !== activeCallCid) {
114
- logger.debug(
115
- `No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered} callId: ${callId}`,
116
- );
117
- return;
118
- }
119
-
120
- const isCurrentlyMuted = microphone.state.status === 'disabled';
121
- if (isCurrentlyMuted === muted) {
122
- logger.debug(
123
- `Mic toggle is already in the desired state: ${muted} for call: ${activeCallCid}`,
124
- );
125
- return;
126
- }
127
-
128
- try {
129
- if (muted) {
130
- await microphone.disable();
131
- } else {
132
- await microphone.enable();
133
- }
134
- } catch (error: unknown) {
135
- logger.error(
136
- `Error toggling mic in calling exp: ${activeCallCid}`,
137
- error,
138
- );
139
- }
140
- },
141
- );
142
-
143
- return () => {
144
- subscription.remove();
145
- };
146
- }, [activeCallCid, microphone]);
147
- };
@@ -1,52 +0,0 @@
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
- let pendingResolve: (() => void) | null = null;
7
- let pendingTimeout: ReturnType<typeof setTimeout> | null = null;
8
- /**
9
- * Flag to check if the audio session is already activated.
10
- * This solves race condition for a cold start case, when the audio session is activated before the promise is created.
11
- */
12
- let isAudioSessionAlreadyActivated = false;
13
-
14
- const AUDIO_SESSION_TIMEOUT_MS = 5000;
15
-
16
- /**
17
- * Creates a promise that resolves when the audio session is activated,
18
- * or after a timeout to prevent hanging indefinitely.
19
- * @returns Promise that resolves when audio session is activated or timeout occurs
20
- */
21
- export function waitForAudioSessionActivation(): Promise<void> {
22
- if (isAudioSessionAlreadyActivated) {
23
- return Promise.resolve();
24
- }
25
-
26
- return new Promise((resolve) => {
27
- pendingResolve = resolve;
28
- pendingTimeout = setTimeout(() => {
29
- // Resolve on timeout to prevent hanging
30
- resolvePendingAudioSession();
31
- }, AUDIO_SESSION_TIMEOUT_MS);
32
- });
33
- }
34
-
35
- /**
36
- * Resolves the pending audio session activation promise.
37
- * Called when the didActivateAudioSession event fires or on timeout.
38
- */
39
- export function resolvePendingAudioSession(): void {
40
- if (pendingTimeout) {
41
- clearTimeout(pendingTimeout);
42
- pendingTimeout = null;
43
- }
44
-
45
- if (pendingResolve) {
46
- pendingResolve();
47
- pendingResolve = null;
48
- isAudioSessionAlreadyActivated = false;
49
- } else {
50
- isAudioSessionAlreadyActivated = true;
51
- }
52
- }
@@ -1,192 +0,0 @@
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 { getCallingxLibIfAvailable } from '../push/libs/callingx';
7
- import {
8
- Call,
9
- MemberResponse,
10
- StreamVideoParticipant,
11
- videoLoggerSystem,
12
- } from '@stream-io/video-client';
13
- import { waitForAudioSessionActivation } from './audioSessionPromise';
14
-
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
- ) {
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
- /**
57
- * Starts the call in the callingx library.
58
- * Must be called for all outgoing calls
59
- * and optionally for non-ringing calls when ongoing calls are enabled.
60
- */
61
- export async function startCallingxCall(call: Call) {
62
- if (!CallingxModule || !CallingxModule.isSetup) {
63
- return;
64
- }
65
-
66
- const isOutcomingCall = call.ringing && call.isCreatedByMe;
67
- const isIncomingCall = call.ringing && !call.isCreatedByMe;
68
-
69
- const callDisplayName = getCallDisplayName(
70
- call.state.members,
71
- call.state.participants,
72
- call.currentUserId,
73
- );
74
-
75
- if (
76
- !CallingxModule.isCallRegistered(call.cid) &&
77
- (isOutcomingCall || (!call.ringing && CallingxModule.isOngoingCallsEnabled))
78
- ) {
79
- try {
80
- await CallingxModule.startCall(
81
- call.cid, // unique id for call
82
- call.id, // phone number for display in dialer (we use call id as phone number)
83
- callDisplayName, // display name for display in call screen
84
- call.state.settings?.video?.enabled ?? false, // is video call?
85
- );
86
-
87
- // Wait for audio session activation on iOS only
88
- if (Platform.OS === 'ios') {
89
- await waitForAudioSessionActivation();
90
- }
91
-
92
- CallingxModule.setCurrentCallActive(call.cid);
93
- } catch (error) {
94
- videoLoggerSystem
95
- .getLogger('startCallingxCall')
96
- .error(`Error starting call in callingx: ${call.cid}`, error);
97
- }
98
- } else if (isIncomingCall) {
99
- try {
100
- if (!CallingxModule.isCallRegistered(call.cid)) {
101
- await CallingxModule.displayIncomingCall(
102
- call.cid, // unique id for call
103
- call.id, // phone number for display in dialer (we use call id as phone number)
104
- callDisplayName, // display name for display in call screen
105
- call.state.settings?.video?.enabled ?? false, // is video call?
106
- );
107
-
108
- await waitForDisplayIncomingCall(call.cid);
109
- } else {
110
- await CallingxModule.answerIncomingCall(call.cid);
111
- }
112
-
113
- if (Platform.OS === 'ios') {
114
- await waitForAudioSessionActivation();
115
- }
116
- } catch (error) {
117
- videoLoggerSystem
118
- .getLogger('startCallingxCall')
119
- .error(
120
- `Error displaying incoming call in callingx: ${call.cid}`,
121
- error,
122
- );
123
- }
124
- }
125
- }
126
-
127
- export async function endCallingxCall(call: Call) {
128
- if (
129
- !CallingxModule ||
130
- !CallingxModule.isSetup ||
131
- !CallingxModule.isCallRegistered(call.cid)
132
- ) {
133
- return;
134
- }
135
-
136
- try {
137
- await CallingxModule.endCallWithReason(call.cid, 'local');
138
- } catch (error) {
139
- videoLoggerSystem
140
- .getLogger('endCallingxCall')
141
- .error(`Error ending call in callingx: ${call.cid}`, error);
142
- }
143
- }
144
-
145
- const waitForDisplayIncomingCall = (
146
- callId: string,
147
- timeoutMs: number = 5000,
148
- ): Promise<void> => {
149
- if (!CallingxModule) {
150
- return Promise.resolve();
151
- }
152
-
153
- return new Promise((resolve, reject) => {
154
- let timeoutId: ReturnType<typeof setTimeout> | undefined = undefined;
155
- let subscription:
156
- | ReturnType<typeof CallingxModule.addEventListener>
157
- | undefined = undefined;
158
-
159
- const cleanup = () => {
160
- if (timeoutId) {
161
- clearTimeout(timeoutId);
162
- }
163
- subscription?.remove();
164
- };
165
-
166
- subscription = CallingxModule.addEventListener(
167
- 'didDisplayIncomingCall',
168
- async (params) => {
169
- videoLoggerSystem
170
- .getLogger('waitForDisplayIncomingCall')
171
- .debug('didDisplayIncomingCall', params);
172
- cleanup();
173
-
174
- try {
175
- await CallingxModule.answerIncomingCall(callId);
176
- resolve();
177
- } catch (error) {
178
- reject(error);
179
- }
180
- },
181
- );
182
-
183
- timeoutId = setTimeout(() => {
184
- cleanup();
185
- reject(
186
- new Error(
187
- `Timeout waiting for didDisplayIncomingCall after ${timeoutMs}ms`,
188
- ),
189
- );
190
- }, timeoutMs);
191
- });
192
- };
@@ -1,54 +0,0 @@
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();