@stream-io/video-react-native-sdk 1.28.3 → 1.29.0-beta.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 (240) hide show
  1. package/android/src/main/AndroidManifest.xml +8 -1
  2. package/android/src/main/AndroidManifestNew.xml +11 -0
  3. package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +42 -5
  4. package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +70 -6
  5. package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +6 -4
  6. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +83 -0
  7. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +134 -0
  8. package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js +3 -1
  9. package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
  10. package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js +5 -2
  11. package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
  12. package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js +6 -3
  13. package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
  14. package/dist/commonjs/components/Participant/FloatingParticipantView/index.js +3 -1
  15. package/dist/commonjs/components/Participant/FloatingParticipantView/index.js.map +1 -1
  16. package/dist/commonjs/components/Participant/ParticipantView/ParticipantView.js +3 -1
  17. package/dist/commonjs/components/Participant/ParticipantView/ParticipantView.js.map +1 -1
  18. package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/index.js +3 -2
  19. package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/index.js.map +1 -1
  20. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +216 -0
  21. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  22. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  23. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  24. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +64 -97
  25. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.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/call-manager/CallManager.js +26 -0
  29. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  30. package/dist/commonjs/providers/StreamCall/index.js +6 -6
  31. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  32. package/dist/commonjs/utils/StreamVideoRN/index.js +33 -21
  33. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  34. package/dist/commonjs/utils/internal/audioSessionPromise.js +46 -0
  35. package/dist/commonjs/utils/internal/audioSessionPromise.js.map +1 -0
  36. package/dist/commonjs/utils/internal/callingx.js +84 -0
  37. package/dist/commonjs/utils/internal/callingx.js.map +1 -0
  38. package/dist/commonjs/utils/internal/registerSDKGlobals.js +52 -3
  39. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  40. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +48 -0
  41. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +1 -0
  42. package/dist/commonjs/utils/push/android.js +145 -200
  43. package/dist/commonjs/utils/push/android.js.map +1 -1
  44. package/dist/commonjs/utils/push/internal/ios.js +16 -34
  45. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  46. package/dist/commonjs/utils/push/internal/rxSubjects.js +1 -20
  47. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  48. package/dist/commonjs/utils/push/internal/utils.js +17 -1
  49. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  50. package/dist/commonjs/utils/push/ios.js.map +1 -1
  51. package/dist/commonjs/utils/push/libs/callingx.js +75 -0
  52. package/dist/commonjs/utils/push/libs/callingx.js.map +1 -0
  53. package/dist/commonjs/utils/push/libs/index.js +8 -19
  54. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  55. package/dist/commonjs/utils/push/libs/notifee/index.js +0 -19
  56. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  57. package/dist/commonjs/utils/push/setupCallingExpEvents.js +97 -0
  58. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -0
  59. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +7 -6
  60. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  61. package/dist/commonjs/version.js +1 -1
  62. package/dist/commonjs/version.js.map +1 -1
  63. package/dist/module/components/Call/CallLayout/CallParticipantsGrid.js +3 -1
  64. package/dist/module/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
  65. package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js +5 -2
  66. package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
  67. package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js +6 -3
  68. package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
  69. package/dist/module/components/Participant/FloatingParticipantView/index.js +3 -1
  70. package/dist/module/components/Participant/FloatingParticipantView/index.js.map +1 -1
  71. package/dist/module/components/Participant/ParticipantView/ParticipantView.js +3 -1
  72. package/dist/module/components/Participant/ParticipantView/ParticipantView.js.map +1 -1
  73. package/dist/module/components/Participant/ParticipantView/VideoRenderer/index.js +3 -2
  74. package/dist/module/components/Participant/ParticipantView/VideoRenderer/index.js.map +1 -1
  75. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +209 -0
  76. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  77. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  78. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  79. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +66 -99
  80. package/dist/module/hooks/useAndroidKeepCallAliveEffect.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/call-manager/CallManager.js +26 -0
  84. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  85. package/dist/module/providers/StreamCall/index.js +6 -6
  86. package/dist/module/providers/StreamCall/index.js.map +1 -1
  87. package/dist/module/utils/StreamVideoRN/index.js +33 -21
  88. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  89. package/dist/module/utils/internal/audioSessionPromise.js +39 -0
  90. package/dist/module/utils/internal/audioSessionPromise.js.map +1 -0
  91. package/dist/module/utils/internal/callingx.js +75 -0
  92. package/dist/module/utils/internal/callingx.js.map +1 -0
  93. package/dist/module/utils/internal/registerSDKGlobals.js +53 -4
  94. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  95. package/dist/module/utils/keepCallAliveHeadlessTask.js +42 -0
  96. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +1 -0
  97. package/dist/module/utils/push/android.js +147 -202
  98. package/dist/module/utils/push/android.js.map +1 -1
  99. package/dist/module/utils/push/internal/ios.js +16 -34
  100. package/dist/module/utils/push/internal/ios.js.map +1 -1
  101. package/dist/module/utils/push/internal/rxSubjects.js +0 -19
  102. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  103. package/dist/module/utils/push/internal/utils.js +14 -0
  104. package/dist/module/utils/push/internal/utils.js.map +1 -1
  105. package/dist/module/utils/push/ios.js.map +1 -1
  106. package/dist/module/utils/push/libs/callingx.js +67 -0
  107. package/dist/module/utils/push/libs/callingx.js.map +1 -0
  108. package/dist/module/utils/push/libs/index.js +1 -2
  109. package/dist/module/utils/push/libs/index.js.map +1 -1
  110. package/dist/module/utils/push/libs/notifee/index.js +0 -18
  111. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  112. package/dist/module/utils/push/setupCallingExpEvents.js +91 -0
  113. package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -0
  114. package/dist/module/utils/push/setupIosVoipPushEvents.js +7 -6
  115. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  116. package/dist/module/version.js +1 -1
  117. package/dist/module/version.js.map +1 -1
  118. package/dist/typescript/components/Call/CallLayout/CallParticipantsGrid.d.ts +2 -2
  119. package/dist/typescript/components/Call/CallLayout/CallParticipantsGrid.d.ts.map +1 -1
  120. package/dist/typescript/components/Call/CallLayout/CallParticipantsSpotlight.d.ts +2 -2
  121. package/dist/typescript/components/Call/CallLayout/CallParticipantsSpotlight.d.ts.map +1 -1
  122. package/dist/typescript/components/Call/CallParticipantsList/CallParticipantsList.d.ts +6 -1
  123. package/dist/typescript/components/Call/CallParticipantsList/CallParticipantsList.d.ts.map +1 -1
  124. package/dist/typescript/components/Participant/FloatingParticipantView/index.d.ts +2 -2
  125. package/dist/typescript/components/Participant/FloatingParticipantView/index.d.ts.map +1 -1
  126. package/dist/typescript/components/Participant/ParticipantView/ParticipantView.d.ts +6 -1
  127. package/dist/typescript/components/Participant/ParticipantView/ParticipantView.d.ts.map +1 -1
  128. package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/index.d.ts +2 -2
  129. package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/index.d.ts.map +1 -1
  130. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +5 -0
  131. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -0
  132. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  133. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  134. package/dist/typescript/index.d.ts +1 -0
  135. package/dist/typescript/index.d.ts.map +1 -1
  136. package/dist/typescript/modules/call-manager/CallManager.d.ts +5 -0
  137. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  138. package/dist/typescript/utils/StreamVideoRN/index.d.ts +20 -2
  139. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  140. package/dist/typescript/utils/StreamVideoRN/types.d.ts +54 -29
  141. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  142. package/dist/typescript/utils/internal/audioSessionPromise.d.ts +16 -0
  143. package/dist/typescript/utils/internal/audioSessionPromise.d.ts.map +1 -0
  144. package/dist/typescript/utils/internal/callingx.d.ts +13 -0
  145. package/dist/typescript/utils/internal/callingx.d.ts.map +1 -0
  146. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  147. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +10 -0
  148. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +1 -0
  149. package/dist/typescript/utils/push/android.d.ts +1 -2
  150. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  151. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  152. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +0 -12
  153. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  154. package/dist/typescript/utils/push/internal/utils.d.ts +4 -0
  155. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  156. package/dist/typescript/utils/push/ios.d.ts +1 -2
  157. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  158. package/dist/typescript/utils/push/libs/callingx.d.ts +9 -0
  159. package/dist/typescript/utils/push/libs/callingx.d.ts.map +1 -0
  160. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +16 -2
  161. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  162. package/dist/typescript/utils/push/libs/index.d.ts +1 -2
  163. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  164. package/dist/typescript/utils/push/libs/notifee/index.d.ts +0 -1
  165. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  166. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +8 -0
  167. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -0
  168. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  169. package/dist/typescript/version.d.ts +1 -1
  170. package/dist/typescript/version.d.ts.map +1 -1
  171. package/expo-config-plugin/dist/withAndroidManifest.js +1 -33
  172. package/expo-config-plugin/dist/withAndroidPermissions.js +2 -7
  173. package/expo-config-plugin/dist/withAppDelegate.js +19 -197
  174. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  175. package/expo-config-plugin/dist/withiOSInfoPlist.js +2 -3
  176. package/ios/StreamInCallManager.m +2 -0
  177. package/ios/StreamInCallManager.swift +20 -5
  178. package/ios/StreamVideoReactNative.h +7 -4
  179. package/ios/StreamVideoReactNative.m +191 -82
  180. package/package.json +10 -15
  181. package/src/components/Call/CallLayout/CallParticipantsGrid.tsx +3 -1
  182. package/src/components/Call/CallLayout/CallParticipantsSpotlight.tsx +4 -1
  183. package/src/components/Call/CallParticipantsList/CallParticipantsList.tsx +8 -0
  184. package/src/components/Participant/FloatingParticipantView/index.tsx +3 -1
  185. package/src/components/Participant/ParticipantView/ParticipantView.tsx +7 -0
  186. package/src/components/Participant/ParticipantView/VideoRenderer/index.tsx +7 -2
  187. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +307 -0
  188. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
  189. package/src/hooks/useAndroidKeepCallAliveEffect.ts +94 -120
  190. package/src/index.ts +1 -0
  191. package/src/modules/call-manager/CallManager.ts +36 -0
  192. package/src/modules/call-manager/native-module.d.ts +7 -0
  193. package/src/providers/StreamCall/index.tsx +6 -6
  194. package/src/utils/StreamVideoRN/index.ts +40 -30
  195. package/src/utils/StreamVideoRN/types.ts +56 -29
  196. package/src/utils/internal/audioSessionPromise.ts +39 -0
  197. package/src/utils/internal/callingx.ts +108 -0
  198. package/src/utils/internal/registerSDKGlobals.ts +47 -4
  199. package/src/utils/keepCallAliveHeadlessTask.ts +54 -0
  200. package/src/utils/push/android.ts +223 -308
  201. package/src/utils/push/internal/ios.ts +25 -46
  202. package/src/utils/push/internal/rxSubjects.ts +0 -29
  203. package/src/utils/push/internal/utils.ts +25 -0
  204. package/src/utils/push/ios.ts +1 -6
  205. package/src/utils/push/libs/callingx.ts +90 -0
  206. package/src/utils/push/libs/index.ts +1 -2
  207. package/src/utils/push/libs/notifee/index.ts +0 -27
  208. package/src/utils/push/setupCallingExpEvents.ts +117 -0
  209. package/src/utils/push/setupIosVoipPushEvents.ts +11 -7
  210. package/src/version.ts +1 -1
  211. package/CHANGELOG.md +0 -3103
  212. package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +0 -95
  213. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -160
  214. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  215. package/dist/commonjs/utils/push/libs/callkeep.js +0 -17
  216. package/dist/commonjs/utils/push/libs/callkeep.js.map +0 -1
  217. package/dist/commonjs/utils/push/libs/voipPushNotification.js +0 -17
  218. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +0 -1
  219. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +0 -205
  220. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +0 -1
  221. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -153
  222. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  223. package/dist/module/utils/push/libs/callkeep.js +0 -11
  224. package/dist/module/utils/push/libs/callkeep.js.map +0 -1
  225. package/dist/module/utils/push/libs/voipPushNotification.js +0 -11
  226. package/dist/module/utils/push/libs/voipPushNotification.js.map +0 -1
  227. package/dist/module/utils/push/setupIosCallKeepEvents.js +0 -199
  228. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +0 -1
  229. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +0 -5
  230. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +0 -1
  231. package/dist/typescript/utils/push/libs/callkeep.d.ts +0 -3
  232. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +0 -1
  233. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +0 -3
  234. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +0 -1
  235. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +0 -6
  236. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +0 -1
  237. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +0 -235
  238. package/src/utils/push/libs/callkeep.ts +0 -16
  239. package/src/utils/push/libs/voipPushNotification.ts +0 -17
  240. package/src/utils/push/setupIosCallKeepEvents.ts +0 -252
@@ -1,10 +1,9 @@
1
- import { AppState, NativeModules, Platform } from 'react-native';
2
- import { getCallKeepLib, getVoipPushNotificationLib } from '../libs';
3
- import { voipPushNotificationCallCId$ } from './rxSubjects';
1
+ import { Platform } from 'react-native';
4
2
  import { pushUnsubscriptionCallbacks } from './constants';
5
- import { canAddPushWSSubscriptionsRef, shouldCallBeEnded } from './utils';
3
+ import { canListenToWS, shouldCallBeClosed } from './utils';
6
4
  import { StreamVideoConfig } from '../../StreamVideoRN/types';
7
5
  import { videoLoggerSystem } from '@stream-io/video-client';
6
+ import { getCallingxLib } from '../libs/callingx';
8
7
 
9
8
  export const onVoipNotificationReceived = async (
10
9
  notification: any,
@@ -32,71 +31,51 @@ export const onVoipNotificationReceived = async (
32
31
  "version": "v2"
33
32
  }
34
33
  } */
34
+ const logger = videoLoggerSystem.getLogger('setupIosVoipPushEvents');
35
+
35
36
  const sender = notification?.stream?.sender;
36
37
  const type = notification?.stream?.type;
37
38
  // do not process any other notifications other than stream.video or ringing
38
39
  if (sender !== 'stream.video' && type !== 'call.ring') {
39
40
  return;
40
41
  }
42
+
41
43
  const call_cid = notification?.stream?.call_cid;
42
44
  if (!call_cid || Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName) {
43
45
  return;
44
46
  }
45
- const logger = videoLoggerSystem.getLogger('setupIosVoipPushEvents');
46
- const client = await pushConfig.createStreamVideoClient();
47
47
 
48
- if (!client) {
48
+ const callingx = getCallingxLib();
49
+ if (callingx.isCallRegistered(call_cid)) {
50
+ //same call_cid is registered, so we skipping the notification
49
51
  logger.debug(
50
- 'client not found, not processing call.ring voip push notification',
52
+ `the same call_cid ${call_cid} is registered, skipping the call.ring notification`,
51
53
  );
52
54
  return;
53
55
  }
54
- const shouldRejectCallWhenBusy = client['rejectCallWhenBusy'] ?? false;
55
- if (shouldRejectCallWhenBusy) {
56
- // inform the iOS native module that we should reject call when busy
57
- NativeModules.StreamVideoReactNative.setShouldRejectCallWhenBusy(
58
- shouldRejectCallWhenBusy,
59
- );
60
- }
61
- const callFromPush = await client.onRingingCall(call_cid);
62
- let uuid = '';
63
- try {
64
- uuid =
65
- await NativeModules?.StreamVideoReactNative?.getIncomingCallUUid(
66
- call_cid,
67
- );
68
- } catch (error) {
69
- logger.error('Error in getting call uuid from native module', error);
70
- }
71
- if (!uuid) {
72
- logger.error(
73
- `Not processing call.ring push notification, as no uuid found for call_cid: ${call_cid}`,
56
+
57
+ const client = await pushConfig.createStreamVideoClient();
58
+ if (!client) {
59
+ logger.debug(
60
+ 'client not found, not processing call.ring voip push notification',
74
61
  );
75
62
  return;
76
63
  }
77
- const created_by_id = notification?.stream?.created_by_id;
78
- const receiver_id = notification?.stream?.receiver_id;
64
+
65
+ const callFromPush = await client.onRingingCall(call_cid);
66
+
79
67
  function closeCallIfNecessary() {
80
- const { mustEndCall, callkeepReason } = shouldCallBeEnded(
81
- callFromPush,
82
- created_by_id,
83
- receiver_id,
84
- );
68
+ const mustEndCall = shouldCallBeClosed(callFromPush, notification?.stream);
85
69
  if (mustEndCall) {
86
- const callkeep = getCallKeepLib();
87
- logger.debug(
88
- `callkeep.reportEndCallWithUUID for uuid: ${uuid}, call_cid: ${call_cid}, reason: ${callkeepReason}`,
89
- );
90
- callkeep.reportEndCallWithUUID(uuid, callkeepReason);
91
- const voipPushNotification = getVoipPushNotificationLib();
92
- voipPushNotification.onVoipNotificationCompleted(uuid);
70
+ logger.debug(`callkeep.reportEndCallWithUUID for call_cid: ${call_cid}`);
71
+ //TODO: think about sending appropriate reason for end call
72
+ callingx.endCallWithReason(call_cid, 'local');
93
73
  return true;
94
74
  }
95
75
  return false;
96
76
  }
77
+
97
78
  const closed = closeCallIfNecessary();
98
- const canListenToWS = () =>
99
- canAddPushWSSubscriptionsRef.current && AppState.currentState !== 'active';
100
79
  if (!closed && canListenToWS()) {
101
80
  const unsubscribe = callFromPush.on('all', (event) => {
102
81
  const _canListenToWS = canListenToWS();
@@ -121,10 +100,10 @@ export const onVoipNotificationReceived = async (
121
100
  pushUnsubscriptionCallbacks.get(call_cid)?.forEach((cb) => cb());
122
101
  pushUnsubscriptionCallbacks.set(call_cid, [unsubscribe]);
123
102
  }
103
+
124
104
  // send the info to this subject, it is listened by callkeep events
125
105
  // callkeep events will then accept/reject the call
126
106
  logger.debug(
127
- `call_cid:${call_cid} uuid:${uuid} received and processed from call.ring push notification`,
107
+ `call_cid:${call_cid} received and processed from call.ring push notification`,
128
108
  );
129
- voipPushNotificationCallCId$.next(call_cid);
130
109
  };
@@ -40,32 +40,3 @@ export const pushAndroidBackgroundDeliveredIncomingCallCId$ =
40
40
  export const pushRejectedIncomingCallCId$ = new BehaviorSubject<
41
41
  string | undefined
42
42
  >(undefined);
43
-
44
- /**
45
- * This rxjs subject is used to store the call cid of the incoming call from ios voip pushkit notification
46
- */
47
- export const voipPushNotificationCallCId$ = new BehaviorSubject<
48
- string | undefined
49
- >(undefined);
50
-
51
- /** The pair of cid of a call and its corresponding uuid created in the native side */
52
- type CallkeepMap = {
53
- uuid: string;
54
- cid: string;
55
- };
56
-
57
- /*
58
- * This rxjs subject should only used to store the CallkeepMap
59
- * for the incoming call when on foreground
60
- * or in other words, when we get didDisplayIncomingCall from callkeep lib
61
- */
62
- export const voipCallkeepCallOnForegroundMap$ = new BehaviorSubject<
63
- CallkeepMap | undefined
64
- >(undefined);
65
-
66
- /*
67
- * This rxjs subject should only used to store the CallkeepMap when it was accepted in the native dialer
68
- */
69
- export const voipCallkeepAcceptedCallOnNativeDialerMap$ = new BehaviorSubject<
70
- CallkeepMap | undefined
71
- >(undefined);
@@ -10,6 +10,7 @@ import type {
10
10
  } from '../../StreamVideoRN/types';
11
11
  import { onNewCallNotification } from '../../internal/newNotificationCallbacks';
12
12
  import { pushUnsubscriptionCallbacks } from './constants';
13
+ import { AppState } from 'react-native';
13
14
 
14
15
  type PushConfig = NonNullable<StreamVideoConfig['push']>;
15
16
 
@@ -122,6 +123,16 @@ export const processCallFromPush = async (
122
123
  .debug(
123
124
  `joining call from push notification with callCid: ${callFromPush.cid}`,
124
125
  );
126
+
127
+ if (callFromPush.state.callingState === CallingState.JOINED) {
128
+ videoLoggerSystem
129
+ .getLogger('processCallFromPush')
130
+ .debug(
131
+ `call already joined from push notification with callCid: ${callFromPush.cid}`,
132
+ );
133
+ return;
134
+ }
135
+
125
136
  await callFromPush.join();
126
137
  } else if (action === 'decline') {
127
138
  const canReject =
@@ -191,3 +202,17 @@ export const clearPushWSEventSubscriptions = (call_cid: string) => {
191
202
  export const canAddPushWSSubscriptionsRef: CanAddPushWSSubscriptionsRef = {
192
203
  current: true,
193
204
  };
205
+
206
+ export const canListenToWS = () =>
207
+ canAddPushWSSubscriptionsRef.current && AppState.currentState !== 'active';
208
+
209
+ export const shouldCallBeClosed = (
210
+ call: Call,
211
+ pushData: { [key: string]: string | object },
212
+ ) => {
213
+ const created_by_id = pushData?.created_by_id as string;
214
+ const receiver_id = pushData?.receiver_id as string;
215
+
216
+ const { mustEndCall } = shouldCallBeEnded(call, created_by_id, receiver_id);
217
+ return mustEndCall;
218
+ };
@@ -62,12 +62,7 @@ export const oniOSExpoNotificationEvent = (event: ExpoNotification) => {
62
62
  }
63
63
  };
64
64
 
65
- export const oniOSNotifeeEvent = ({
66
- event,
67
- }: {
68
- event: Event;
69
- isBackground: boolean;
70
- }) => {
65
+ export const oniOSNotifeeEvent = ({ event }: { event: Event }) => {
71
66
  if (Platform.OS !== 'ios') return;
72
67
  const pushConfig = StreamVideoRN.getConfig().push;
73
68
  const { type, detail } = event;
@@ -0,0 +1,90 @@
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.subtitleTransformer) {
67
+ androidOptions.subtitleTransformer =
68
+ pushConfig.android.subtitleTransformer;
69
+ }
70
+ }
71
+
72
+ if (foregroundServiceConfig.android.channel) {
73
+ androidOptions.ongoingChannel = foregroundServiceConfig.android.channel;
74
+ }
75
+
76
+ if (Object.keys(androidOptions).length > 0) {
77
+ callingExpOptions.android = androidOptions;
78
+ }
79
+
80
+ if (pushConfig?.shouldRejectCallWhenBusy !== undefined) {
81
+ callingExpOptions.shouldRejectCallWhenBusy =
82
+ pushConfig.shouldRejectCallWhenBusy;
83
+ }
84
+
85
+ if (pushConfig?.enableOngoingCalls !== undefined) {
86
+ callingExpOptions.enableOngoingCalls = pushConfig?.enableOngoingCalls;
87
+ }
88
+
89
+ return callingExpOptions;
90
+ }
@@ -1,9 +1,8 @@
1
1
  export * from './expoNotifications';
2
2
  export * from './firebaseMessaging';
3
3
  export * from './iosPushNotification';
4
- export * from './voipPushNotification';
5
- export * from './callkeep';
6
4
  export * from './notifee';
5
+ export * from './callingx';
7
6
 
8
7
  /*
9
8
  NOTE: must keep each libs in different files
@@ -1,6 +1,4 @@
1
- import { PermissionsAndroid } from 'react-native';
2
1
  import { lib, type Type } from './lib';
3
- import { videoLoggerSystem } from '@stream-io/video-client';
4
2
 
5
3
  export type NotifeeLib = Type;
6
4
 
@@ -36,34 +34,9 @@ export function getNotifeeLibThrowIfNotInstalledForPush() {
36
34
  }
37
35
 
38
36
  export function getNotifeeLibNoThrowForKeepCallAlive() {
39
- if (!lib) {
40
- const logger = videoLoggerSystem.getLogger('getNotifeeLibNoThrow');
41
- logger.info(
42
- `${'@notifee/react-native library not installed. It is required to keep call alive in the background for Android. '}${INSTALLATION_INSTRUCTION}`,
43
- );
44
- }
45
37
  return lib;
46
38
  }
47
39
 
48
- export async function getKeepCallAliveForegroundServiceTypes() {
49
- const types: AndroidForegroundServiceType[] = [
50
- AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK,
51
- ];
52
- const hasCameraPermission = await PermissionsAndroid.check(
53
- PermissionsAndroid.PERMISSIONS.CAMERA!,
54
- );
55
- if (hasCameraPermission) {
56
- types.push(AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_CAMERA);
57
- }
58
- const hasMicrophonePermission = await PermissionsAndroid.check(
59
- PermissionsAndroid.PERMISSIONS.RECORD_AUDIO!,
60
- );
61
- if (hasMicrophonePermission) {
62
- types.push(AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_MICROPHONE);
63
- }
64
- return types;
65
- }
66
-
67
40
  export function getIncomingCallForegroundServiceTypes() {
68
41
  const types: AndroidForegroundServiceType[] = [
69
42
  AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE,
@@ -0,0 +1,117 @@
1
+ import { pushAcceptedIncomingCallCId$ } from './internal/rxSubjects';
2
+ import { videoLoggerSystem } from '@stream-io/video-client';
3
+ import type { StreamVideoConfig } from '../StreamVideoRN/types';
4
+ import {
5
+ clearPushWSEventSubscriptions,
6
+ processCallFromPushInBackground,
7
+ } from './internal/utils';
8
+ import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
9
+ import { resolvePendingAudioSession } from '../internal/audioSessionPromise';
10
+ import {
11
+ getCallingxLib,
12
+ type EventData,
13
+ type EventParams,
14
+ } from './libs/callingx';
15
+ import { Platform } from 'react-native';
16
+
17
+ type PushConfig = NonNullable<StreamVideoConfig['push']>;
18
+
19
+ const logger = videoLoggerSystem.getLogger('Callingx');
20
+
21
+ /**
22
+ * This hook is used to listen to callkeep events and do the necessary actions
23
+ */
24
+ export function setupCallingExpEvents(pushConfig: NonNullable<PushConfig>) {
25
+ const hasPushProvider =
26
+ (Platform.OS === 'android' && pushConfig.android?.pushProviderName) ||
27
+ (Platform.OS === 'ios' && pushConfig.ios?.pushProviderName);
28
+
29
+ if (!hasPushProvider) {
30
+ return;
31
+ }
32
+
33
+ const callingx = getCallingxLib();
34
+
35
+ const { remove: removeAnswerCall } = callingx.addEventListener(
36
+ 'answerCall',
37
+ onAcceptCall,
38
+ );
39
+ const { remove: removeEndCall } = callingx.addEventListener(
40
+ 'endCall',
41
+ onEndCall(pushConfig),
42
+ );
43
+
44
+ const { remove: removeDidActivateAudioSession } = callingx.addEventListener(
45
+ 'didActivateAudioSession',
46
+ onDidActivateAudioSession,
47
+ );
48
+ const { remove: removeDidDeactivateAudioSession } = callingx.addEventListener(
49
+ 'didDeactivateAudioSession',
50
+ onDidDeactivateAudioSession,
51
+ );
52
+
53
+ //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
54
+ //in most cases there will be no delayed answers or ends, but it we don't want to miss any of them
55
+ const events = callingx.getInitialEvents();
56
+ events.forEach((event: EventData) => {
57
+ const { eventName, params } = event;
58
+ if (eventName === 'answerCall') {
59
+ logger.debug(`answerCall delayed event callId: ${params?.callId}`);
60
+ onAcceptCall(params as EventParams['answerCall']);
61
+ } else if (eventName === 'endCall') {
62
+ logger.debug(`endCall delayed event callId: ${params?.callId}`);
63
+ onEndCall(pushConfig)(params as EventParams['endCall']);
64
+ } else if (eventName === 'didActivateAudioSession') {
65
+ onDidActivateAudioSession();
66
+ } else if (eventName === 'didDeactivateAudioSession') {
67
+ onDidDeactivateAudioSession();
68
+ }
69
+ });
70
+
71
+ setPushLogoutCallback(async () => {
72
+ removeAnswerCall();
73
+ removeEndCall();
74
+ removeDidActivateAudioSession();
75
+ removeDidDeactivateAudioSession();
76
+ });
77
+ }
78
+
79
+ const onDidActivateAudioSession = () => {
80
+ logger.debug('callingExpDidActivateAudioSession');
81
+ resolvePendingAudioSession();
82
+ };
83
+
84
+ const onDidDeactivateAudioSession = () => {
85
+ logger.debug('callingExpDidDeactivateAudioSession');
86
+ };
87
+
88
+ const onAcceptCall = ({
89
+ callId: call_cid,
90
+ source,
91
+ }: EventParams['answerCall']) => {
92
+ logger.debug(`onAcceptCall event callId: ${call_cid} source: ${source}`);
93
+
94
+ if (source === 'app' || !call_cid) {
95
+ //we only need to process the call if the call was answered from the system
96
+ return;
97
+ }
98
+
99
+ clearPushWSEventSubscriptions(call_cid);
100
+ // to process the call in the app
101
+ pushAcceptedIncomingCallCId$.next(call_cid);
102
+ };
103
+
104
+ const onEndCall =
105
+ (pushConfig: PushConfig) =>
106
+ async ({ callId: call_cid, source }: EventParams['endCall']) => {
107
+ logger.debug(`onEndCall event callId: ${call_cid} source: ${source}`);
108
+
109
+ if (source === 'app' || !call_cid) {
110
+ //we only need to process the call if the call was rejected from the system
111
+ return;
112
+ }
113
+
114
+ clearPushWSEventSubscriptions(call_cid);
115
+
116
+ await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
117
+ };
@@ -1,10 +1,11 @@
1
- import { getVoipPushNotificationLib } from './libs';
1
+ // import { getVoipPushNotificationLib } from './libs';
2
2
 
3
3
  import { Platform } from 'react-native';
4
4
  import { onVoipNotificationReceived } from './internal/ios';
5
5
  import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
6
6
  import { StreamVideoConfig } from '../StreamVideoRN/types';
7
7
  import { videoLoggerSystem } from '@stream-io/video-client';
8
+ import { getCallingxLib } from './libs';
8
9
 
9
10
  export function setupIosVoipPushEvents(
10
11
  pushConfig: NonNullable<StreamVideoConfig['push']>,
@@ -20,16 +21,19 @@ export function setupIosVoipPushEvents(
20
21
  );
21
22
  return;
22
23
  }
23
- const voipPushNotification = getVoipPushNotificationLib();
24
24
 
25
- logger.debug('notification event listener added');
26
- voipPushNotification.addEventListener('notification', (notification) => {
27
- onVoipNotificationReceived(notification, pushConfig);
28
- });
25
+ const callingx = getCallingxLib();
26
+ const voipNotificationReceivedListener = callingx.addEventListener(
27
+ 'voipNotificationReceived',
28
+ (params) => {
29
+ onVoipNotificationReceived(params, pushConfig);
30
+ },
31
+ );
32
+
29
33
  setPushLogoutCallback(async () => {
30
34
  videoLoggerSystem
31
35
  .getLogger('setPushLogoutCallback')
32
36
  .debug('notification event listener removed');
33
- voipPushNotification.removeEventListener('notification');
37
+ voipNotificationReceivedListener.remove();
34
38
  });
35
39
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.28.3';
1
+ export const version = '1.29.0-beta.1';