@stream-io/video-react-native-sdk 1.31.1-beta.0 → 1.31.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 (217) hide show
  1. package/CHANGELOG.md +11 -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/Participant/ParticipantView/ParticipantLabel.js +2 -6
  9. package/dist/commonjs/components/Participant/ParticipantView/ParticipantLabel.js.map +1 -1
  10. package/dist/commonjs/hooks/push/index.js +2 -0
  11. package/dist/commonjs/hooks/push/index.js.map +1 -1
  12. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
  13. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  14. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  15. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  16. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +67 -0
  17. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +1 -0
  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 -35
  27. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  28. package/dist/commonjs/utils/internal/registerSDKGlobals.js +3 -53
  29. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  30. package/dist/commonjs/utils/push/android.js +202 -135
  31. package/dist/commonjs/utils/push/android.js.map +1 -1
  32. package/dist/commonjs/utils/push/internal/ios.js +34 -17
  33. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  34. package/dist/commonjs/utils/push/internal/rxSubjects.js +45 -1
  35. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  36. package/dist/commonjs/utils/push/internal/utils.js +53 -71
  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/Participant/ParticipantView/ParticipantLabel.js +2 -6
  54. package/dist/module/components/Participant/ParticipantView/ParticipantLabel.js.map +1 -1
  55. package/dist/module/hooks/push/index.js +2 -0
  56. package/dist/module/hooks/push/index.js.map +1 -1
  57. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +153 -0
  58. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  59. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  60. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  61. package/dist/module/hooks/push/useProcessPushCallEffect.js +60 -0
  62. package/dist/module/hooks/push/useProcessPushCallEffect.js.map +1 -0
  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 -35
  72. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  73. package/dist/module/utils/internal/registerSDKGlobals.js +3 -53
  74. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  75. package/dist/module/utils/push/android.js +204 -137
  76. package/dist/module/utils/push/android.js.map +1 -1
  77. package/dist/module/utils/push/internal/ios.js +34 -17
  78. package/dist/module/utils/push/internal/ios.js.map +1 -1
  79. package/dist/module/utils/push/internal/rxSubjects.js +44 -0
  80. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  81. package/dist/module/utils/push/internal/utils.js +50 -67
  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/Participant/ParticipantView/ParticipantLabel.d.ts.map +1 -1
  99. package/dist/typescript/hooks/push/index.d.ts.map +1 -1
  100. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
  101. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -0
  102. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  103. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts +8 -0
  104. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts.map +1 -0
  105. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  106. package/dist/typescript/index.d.ts +0 -1
  107. package/dist/typescript/index.d.ts.map +1 -1
  108. package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
  109. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  110. package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -22
  111. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  112. package/dist/typescript/utils/StreamVideoRN/types.d.ts +25 -59
  113. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  114. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  115. package/dist/typescript/utils/push/android.d.ts +2 -1
  116. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  117. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  118. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +33 -0
  119. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  120. package/dist/typescript/utils/push/internal/utils.d.ts +8 -14
  121. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  122. package/dist/typescript/utils/push/ios.d.ts +2 -1
  123. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  124. package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
  125. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
  126. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +2 -16
  127. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  128. package/dist/typescript/utils/push/libs/index.d.ts +2 -1
  129. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  130. package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
  131. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  132. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
  133. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
  134. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
  135. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
  136. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  137. package/dist/typescript/version.d.ts +1 -1
  138. package/dist/typescript/version.d.ts.map +1 -1
  139. package/expo-config-plugin/dist/withAndroidManifest.js +33 -1
  140. package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
  141. package/expo-config-plugin/dist/withAppDelegate.js +197 -19
  142. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  143. package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
  144. package/ios/StreamInCallManager.m +0 -2
  145. package/ios/StreamInCallManager.swift +7 -19
  146. package/ios/StreamVideoReactNative.h +4 -7
  147. package/ios/StreamVideoReactNative.m +82 -189
  148. package/package.json +16 -11
  149. package/src/components/Participant/ParticipantView/ParticipantLabel.tsx +2 -7
  150. package/src/hooks/push/index.ts +2 -0
  151. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
  152. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
  153. package/src/hooks/push/useProcessPushCallEffect.ts +108 -0
  154. package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
  155. package/src/index.ts +0 -1
  156. package/src/modules/call-manager/CallManager.ts +0 -36
  157. package/src/modules/call-manager/native-module.d.ts +0 -7
  158. package/src/providers/StreamCall/index.tsx +6 -6
  159. package/src/utils/StreamVideoRN/index.ts +30 -42
  160. package/src/utils/StreamVideoRN/types.ts +25 -61
  161. package/src/utils/internal/registerSDKGlobals.ts +4 -52
  162. package/src/utils/push/android.ts +311 -198
  163. package/src/utils/push/internal/ios.ts +44 -28
  164. package/src/utils/push/internal/rxSubjects.ts +61 -0
  165. package/src/utils/push/internal/utils.ts +64 -108
  166. package/src/utils/push/ios.ts +6 -1
  167. package/src/utils/push/libs/callkeep.ts +16 -0
  168. package/src/utils/push/libs/index.ts +2 -1
  169. package/src/utils/push/libs/notifee/index.ts +27 -0
  170. package/src/utils/push/libs/voipPushNotification.ts +17 -0
  171. package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
  172. package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
  173. package/src/version.ts +1 -1
  174. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
  175. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -149
  176. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -144
  177. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  178. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +0 -68
  179. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +0 -1
  180. package/dist/commonjs/utils/internal/callingx/callingx.js +0 -150
  181. package/dist/commonjs/utils/internal/callingx/callingx.js.map +0 -1
  182. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
  183. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
  184. package/dist/commonjs/utils/push/libs/callingx.js +0 -75
  185. package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
  186. package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -105
  187. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
  188. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -137
  189. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  190. package/dist/module/utils/internal/callingx/audioSessionPromise.js +0 -61
  191. package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +0 -1
  192. package/dist/module/utils/internal/callingx/callingx.js +0 -140
  193. package/dist/module/utils/internal/callingx/callingx.js.map +0 -1
  194. package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
  195. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
  196. package/dist/module/utils/push/libs/callingx.js +0 -67
  197. package/dist/module/utils/push/libs/callingx.js.map +0 -1
  198. package/dist/module/utils/push/setupCallingExpEvents.js +0 -99
  199. package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
  200. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
  201. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
  202. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +0 -16
  203. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +0 -1
  204. package/dist/typescript/utils/internal/callingx/callingx.d.ts +0 -18
  205. package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +0 -1
  206. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
  207. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
  208. package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
  209. package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
  210. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
  211. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
  212. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -189
  213. package/src/utils/internal/callingx/audioSessionPromise.ts +0 -65
  214. package/src/utils/internal/callingx/callingx.ts +0 -194
  215. package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
  216. package/src/utils/push/libs/callingx.ts +0 -89
  217. package/src/utils/push/setupCallingExpEvents.ts +0 -135
@@ -1,189 +0,0 @@
1
- import { Call, CallingState, videoLoggerSystem } from '@stream-io/video-client';
2
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
3
- import { useEffect, useMemo } from 'react';
4
- import { filter, take } from 'rxjs/operators';
5
- import { getCallDisplayName } from '../../utils/internal/callingx/callingx';
6
- import { getCallingxLibIfAvailable } from '../../utils/push/libs/callingx';
7
-
8
- const logger = videoLoggerSystem.getLogger('callingx');
9
-
10
- /**
11
- * This hook is used to inform sync call state with CallKit/Telecom (i.e. start call, end call, mute/unmute call).
12
- */
13
- export const useCallingExpWithCallingStateEffect = () => {
14
- const { useMicrophoneState, useParticipants, useCallMembers } =
15
- useCallStateHooks();
16
-
17
- const activeCall = useCall();
18
- const { isMute, microphone } = useMicrophoneState();
19
- const callMembers = useCallMembers();
20
- const participants = useParticipants();
21
-
22
- const activeCallCid = activeCall?.cid;
23
- const currentUserId = activeCall?.currentUserId;
24
- const isIncoming =
25
- (activeCall?.ringing && !activeCall?.isCreatedByMe) || false;
26
-
27
- const callDisplayName = useMemo(
28
- () => getCallDisplayName(callMembers, participants, currentUserId),
29
- [callMembers, participants, currentUserId],
30
- );
31
-
32
- useEffect(() => {
33
- const callingx = getCallingxLibIfAvailable();
34
- if (!callingx?.isSetup || !activeCall) {
35
- return;
36
- }
37
- // need to capture RINGING -> Joining -> Joined state change for the first time
38
- // and inform callingx that the call is active
39
- const shouldMakeCallActive = (call: Call): boolean => {
40
- // only for outgoing calls or non-ringing ongoing calls in callingx
41
- // Note: incoming calls are handled by callingx pending states instead
42
- return (
43
- (call.ringing && call.isCreatedByMe) ||
44
- (!call.ringing && callingx.isOngoingCallsEnabled)
45
- );
46
- };
47
- const subscription = activeCall.state.callingState$
48
- .pipe(
49
- filter(
50
- (callingState) =>
51
- shouldMakeCallActive(activeCall) &&
52
- callingState === CallingState.JOINED &&
53
- callingx.isCallTracked(activeCall.cid),
54
- ),
55
- take(1), // only need to capture the first joined state for outgoing calls
56
- // then subscription completes and is automatically unsubscribed
57
- )
58
- .subscribe(() => {
59
- callingx.setCurrentCallActive(activeCall.cid);
60
- });
61
- return () => {
62
- subscription.unsubscribe();
63
- };
64
- }, [activeCall]);
65
-
66
- useEffect(() => {
67
- return () => {
68
- const callingx = getCallingxLibIfAvailable();
69
- if (!callingx?.isSetup || !activeCallCid) {
70
- return;
71
- }
72
-
73
- const isCallTracked = callingx.isCallTracked(activeCallCid);
74
- if (!isCallTracked) {
75
- logger.debug(
76
- `useCallingExpWithCallingStateEffect:No active call cid to end in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked}`,
77
- );
78
- return;
79
- }
80
- //if incoming stream call was unmounted, we need to end the call in CallKit/Telecom
81
- logger.debug(
82
- `useCallingExpWithCallingStateEffect: Ending call in callingx: ${activeCallCid}`,
83
- );
84
- callingx
85
- .endCallWithReason(activeCallCid, 'local')
86
- .catch((error: unknown) => {
87
- logger.error(
88
- `useCallingExpWithCallingStateEffect: Error ending call in callingx: ${activeCallCid}`,
89
- error,
90
- );
91
- });
92
- };
93
- }, [activeCallCid]);
94
-
95
- useEffect(() => {
96
- const callingx = getCallingxLibIfAvailable();
97
- if (!callingx?.isSetup || !activeCallCid) {
98
- return;
99
- }
100
-
101
- const isCallTracked = callingx.isCallTracked(activeCallCid);
102
- if (!isCallTracked) {
103
- logger.debug(
104
- `useCallingExpWithCallingStateEffect:No active call cid to update callingx: ${activeCallCid} isCallTracked: ${isCallTracked}`,
105
- );
106
- return;
107
- }
108
-
109
- callingx.updateDisplay(
110
- activeCallCid,
111
- activeCallCid,
112
- callDisplayName,
113
- isIncoming,
114
- );
115
- }, [activeCallCid, callDisplayName, isIncoming]);
116
-
117
- // Sync microphone mute state from app → CallKit
118
- useEffect(() => {
119
- const callingx = getCallingxLibIfAvailable();
120
- if (!callingx?.isSetup || !activeCallCid) {
121
- return;
122
- }
123
-
124
- const isCallTracked = callingx.isCallTracked(activeCallCid);
125
- if (!isCallTracked) {
126
- logger.debug(
127
- `useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked}`,
128
- );
129
- return;
130
- }
131
-
132
- callingx.setMutedCall(activeCallCid, isMute);
133
- }, [activeCallCid, isMute]);
134
-
135
- // Sync mute state from CallKit → app (only for system-initiated mute actions)
136
- useEffect(() => {
137
- const callingx = getCallingxLibIfAvailable();
138
- if (!callingx?.isSetup || !activeCallCid) {
139
- logger.debug(
140
- `useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} callingx isSetup: ${callingx?.isSetup}`,
141
- );
142
- return;
143
- }
144
-
145
- // Listen to mic toggle events from CallKit/Telecom and update stream call microphone state.
146
- // Only system-initiated mute actions (e.g. user tapped mute on the native CallKit UI)
147
- // are sent here — app-initiated actions are filtered out on the native side to prevent
148
- // the feedback loop: app mutes mic → setMutedCall → CallKit delegate → event to JS → loop.
149
- const subscription = callingx.addEventListener(
150
- 'didPerformSetMutedCallAction',
151
- async (event: { callId: string; muted: boolean }) => {
152
- const { callId, muted } = event;
153
-
154
- const isCallTracked = callingx.isCallTracked(activeCallCid);
155
- if (!isCallTracked || callId !== activeCallCid) {
156
- logger.debug(
157
- `useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked} callId: ${callId}`,
158
- );
159
- return;
160
- }
161
-
162
- const isCurrentlyMuted = microphone.state.status === 'disabled';
163
- if (isCurrentlyMuted === muted) {
164
- logger.debug(
165
- `useCallingExpWithCallingStateEffect: Mic toggle is already in the desired state: ${muted} for call: ${activeCallCid}`,
166
- );
167
- return;
168
- }
169
-
170
- try {
171
- if (muted) {
172
- await microphone.disable();
173
- } else {
174
- await microphone.enable();
175
- }
176
- } catch (error: unknown) {
177
- logger.error(
178
- `useCallingExpWithCallingStateEffect: Error toggling mic in calling exp: ${activeCallCid}`,
179
- error,
180
- );
181
- }
182
- },
183
- );
184
-
185
- return () => {
186
- subscription.remove();
187
- };
188
- }, [activeCallCid, microphone]);
189
- };
@@ -1,65 +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
- 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
- }
@@ -1,194 +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 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,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();
@@ -1,89 +0,0 @@
1
- import { StreamVideoConfig } from '../../StreamVideoRN/types';
2
-
3
- export type RNCallingxType =
4
- import('@stream-io/react-native-callingx').ICallingxModule;
5
- export type EventData = import('@stream-io/react-native-callingx').EventData;
6
- export type EventParams =
7
- import('@stream-io/react-native-callingx').EventParams;
8
- export type CallingExpOptions =
9
- import('@stream-io/react-native-callingx').CallingExpOptions;
10
-
11
- let callingx: RNCallingxType | undefined;
12
-
13
- try {
14
- callingx = require('@stream-io/react-native-callingx').CallingxModule;
15
- } catch {}
16
-
17
- export function getCallingxLib() {
18
- if (!callingx) {
19
- throw Error('react-native-callingx library is not installed.');
20
- }
21
- return callingx;
22
- }
23
-
24
- export function getCallingxLibIfAvailable() {
25
- return callingx ?? undefined;
26
- }
27
-
28
- export function extractCallingExpOptions(
29
- config: StreamVideoConfig,
30
- ): CallingExpOptions {
31
- const { push: pushConfig, foregroundService: foregroundServiceConfig } =
32
- config;
33
- const callingExpOptions: CallingExpOptions = {};
34
-
35
- if (pushConfig?.ios) {
36
- const iosOptions: CallingExpOptions['ios'] = {};
37
- if (pushConfig.ios.supportsVideo !== undefined) {
38
- iosOptions.supportsVideo = pushConfig.ios.supportsVideo;
39
- }
40
- if (pushConfig.ios.sound !== undefined) {
41
- iosOptions.sound = pushConfig.ios.sound;
42
- }
43
- if (pushConfig.ios.imageName !== undefined) {
44
- iosOptions.imageName = pushConfig.ios.imageName;
45
- }
46
- if (pushConfig.ios.callsHistory !== undefined) {
47
- iosOptions.callsHistory = pushConfig.ios.callsHistory;
48
- }
49
- if (pushConfig.ios.displayCallTimeout !== undefined) {
50
- iosOptions.displayCallTimeout = pushConfig.ios.displayCallTimeout;
51
- }
52
-
53
- if (Object.keys(iosOptions).length > 0) {
54
- callingExpOptions.ios = iosOptions;
55
- }
56
- }
57
-
58
- const androidOptions: CallingExpOptions['android'] = {};
59
- if (pushConfig?.android) {
60
- if (pushConfig.android.incomingChannel) {
61
- androidOptions.incomingChannel = pushConfig.android.incomingChannel;
62
- }
63
- if (pushConfig.android.titleTransformer) {
64
- androidOptions.titleTransformer = pushConfig.android.titleTransformer;
65
- }
66
- if (pushConfig.android.notificationTexts) {
67
- androidOptions.notificationTexts = pushConfig.android.notificationTexts;
68
- }
69
- }
70
-
71
- if (foregroundServiceConfig.android.channel) {
72
- androidOptions.ongoingChannel = foregroundServiceConfig.android.channel;
73
- }
74
-
75
- if (Object.keys(androidOptions).length > 0) {
76
- callingExpOptions.android = androidOptions;
77
- }
78
-
79
- if (pushConfig?.shouldRejectCallWhenBusy !== undefined) {
80
- callingExpOptions.shouldRejectCallWhenBusy =
81
- pushConfig.shouldRejectCallWhenBusy;
82
- }
83
-
84
- if (pushConfig?.enableOngoingCalls !== undefined) {
85
- callingExpOptions.enableOngoingCalls = pushConfig?.enableOngoingCalls;
86
- }
87
-
88
- return callingExpOptions;
89
- }