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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/CHANGELOG.md +3114 -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/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
  9. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  10. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  11. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  12. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +97 -64
  13. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  14. package/dist/commonjs/index.js +0 -1
  15. package/dist/commonjs/index.js.map +1 -1
  16. package/dist/commonjs/modules/call-manager/CallManager.js +0 -26
  17. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  18. package/dist/commonjs/providers/StreamCall/index.js +6 -6
  19. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  20. package/dist/commonjs/utils/StreamVideoRN/index.js +21 -33
  21. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  22. package/dist/commonjs/utils/internal/registerSDKGlobals.js +3 -52
  23. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  24. package/dist/commonjs/utils/push/android.js +200 -145
  25. package/dist/commonjs/utils/push/android.js.map +1 -1
  26. package/dist/commonjs/utils/push/internal/ios.js +34 -16
  27. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  28. package/dist/commonjs/utils/push/internal/rxSubjects.js +20 -1
  29. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  30. package/dist/commonjs/utils/push/internal/utils.js +1 -17
  31. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  32. package/dist/commonjs/utils/push/ios.js.map +1 -1
  33. package/dist/commonjs/utils/push/libs/callkeep.js +17 -0
  34. package/dist/commonjs/utils/push/libs/callkeep.js.map +1 -0
  35. package/dist/commonjs/utils/push/libs/index.js +19 -8
  36. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  37. package/dist/commonjs/utils/push/libs/notifee/index.js +19 -0
  38. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  39. package/dist/commonjs/utils/push/libs/voipPushNotification.js +17 -0
  40. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +1 -0
  41. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +205 -0
  42. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
  43. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
  44. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  45. package/dist/commonjs/version.js +1 -1
  46. package/dist/commonjs/version.js.map +1 -1
  47. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +153 -0
  48. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  49. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  50. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  51. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +99 -66
  52. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  53. package/dist/module/index.js +0 -1
  54. package/dist/module/index.js.map +1 -1
  55. package/dist/module/modules/call-manager/CallManager.js +0 -26
  56. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  57. package/dist/module/providers/StreamCall/index.js +6 -6
  58. package/dist/module/providers/StreamCall/index.js.map +1 -1
  59. package/dist/module/utils/StreamVideoRN/index.js +21 -33
  60. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  61. package/dist/module/utils/internal/registerSDKGlobals.js +4 -53
  62. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  63. package/dist/module/utils/push/android.js +202 -147
  64. package/dist/module/utils/push/android.js.map +1 -1
  65. package/dist/module/utils/push/internal/ios.js +34 -16
  66. package/dist/module/utils/push/internal/ios.js.map +1 -1
  67. package/dist/module/utils/push/internal/rxSubjects.js +19 -0
  68. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  69. package/dist/module/utils/push/internal/utils.js +0 -14
  70. package/dist/module/utils/push/internal/utils.js.map +1 -1
  71. package/dist/module/utils/push/ios.js.map +1 -1
  72. package/dist/module/utils/push/libs/callkeep.js +11 -0
  73. package/dist/module/utils/push/libs/callkeep.js.map +1 -0
  74. package/dist/module/utils/push/libs/index.js +2 -1
  75. package/dist/module/utils/push/libs/index.js.map +1 -1
  76. package/dist/module/utils/push/libs/notifee/index.js +18 -0
  77. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  78. package/dist/module/utils/push/libs/voipPushNotification.js +11 -0
  79. package/dist/module/utils/push/libs/voipPushNotification.js.map +1 -0
  80. package/dist/module/utils/push/setupIosCallKeepEvents.js +199 -0
  81. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
  82. package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
  83. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  84. package/dist/module/version.js +1 -1
  85. package/dist/module/version.js.map +1 -1
  86. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
  87. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -0
  88. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  89. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  90. package/dist/typescript/index.d.ts +0 -1
  91. package/dist/typescript/index.d.ts.map +1 -1
  92. package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
  93. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  94. package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -20
  95. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  96. package/dist/typescript/utils/StreamVideoRN/types.d.ts +29 -54
  97. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  98. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  99. package/dist/typescript/utils/push/android.d.ts +2 -1
  100. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  101. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  102. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +12 -0
  103. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  104. package/dist/typescript/utils/push/internal/utils.d.ts +0 -4
  105. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  106. package/dist/typescript/utils/push/ios.d.ts +2 -1
  107. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  108. package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
  109. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
  110. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +2 -16
  111. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  112. package/dist/typescript/utils/push/libs/index.d.ts +2 -1
  113. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  114. package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
  115. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  116. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
  117. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
  118. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
  119. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
  120. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  121. package/dist/typescript/version.d.ts +1 -1
  122. package/dist/typescript/version.d.ts.map +1 -1
  123. package/expo-config-plugin/dist/withAndroidManifest.js +33 -1
  124. package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
  125. package/expo-config-plugin/dist/withAppDelegate.js +197 -19
  126. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  127. package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
  128. package/ios/StreamInCallManager.m +0 -2
  129. package/ios/StreamInCallManager.swift +5 -20
  130. package/ios/StreamVideoReactNative.h +4 -7
  131. package/ios/StreamVideoReactNative.m +82 -191
  132. package/package.json +17 -12
  133. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
  134. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
  135. package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
  136. package/src/index.ts +0 -1
  137. package/src/modules/call-manager/CallManager.ts +0 -36
  138. package/src/modules/call-manager/native-module.d.ts +0 -7
  139. package/src/providers/StreamCall/index.tsx +6 -6
  140. package/src/utils/StreamVideoRN/index.ts +30 -40
  141. package/src/utils/StreamVideoRN/types.ts +29 -56
  142. package/src/utils/internal/registerSDKGlobals.ts +4 -47
  143. package/src/utils/push/android.ts +308 -223
  144. package/src/utils/push/internal/ios.ts +46 -25
  145. package/src/utils/push/internal/rxSubjects.ts +29 -0
  146. package/src/utils/push/internal/utils.ts +0 -25
  147. package/src/utils/push/ios.ts +6 -1
  148. package/src/utils/push/libs/callkeep.ts +16 -0
  149. package/src/utils/push/libs/index.ts +2 -1
  150. package/src/utils/push/libs/notifee/index.ts +27 -0
  151. package/src/utils/push/libs/voipPushNotification.ts +17 -0
  152. package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
  153. package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
  154. package/src/version.ts +1 -1
  155. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
  156. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -134
  157. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -216
  158. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  159. package/dist/commonjs/utils/internal/audioSessionPromise.js +0 -46
  160. package/dist/commonjs/utils/internal/audioSessionPromise.js.map +0 -1
  161. package/dist/commonjs/utils/internal/callingx.js +0 -84
  162. package/dist/commonjs/utils/internal/callingx.js.map +0 -1
  163. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
  164. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
  165. package/dist/commonjs/utils/push/libs/callingx.js +0 -75
  166. package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
  167. package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -97
  168. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
  169. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -209
  170. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  171. package/dist/module/utils/internal/audioSessionPromise.js +0 -39
  172. package/dist/module/utils/internal/audioSessionPromise.js.map +0 -1
  173. package/dist/module/utils/internal/callingx.js +0 -75
  174. package/dist/module/utils/internal/callingx.js.map +0 -1
  175. package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
  176. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
  177. package/dist/module/utils/push/libs/callingx.js +0 -67
  178. package/dist/module/utils/push/libs/callingx.js.map +0 -1
  179. package/dist/module/utils/push/setupCallingExpEvents.js +0 -91
  180. package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
  181. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
  182. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
  183. package/dist/typescript/utils/internal/audioSessionPromise.d.ts +0 -16
  184. package/dist/typescript/utils/internal/audioSessionPromise.d.ts.map +0 -1
  185. package/dist/typescript/utils/internal/callingx.d.ts +0 -13
  186. package/dist/typescript/utils/internal/callingx.d.ts.map +0 -1
  187. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
  188. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
  189. package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
  190. package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
  191. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
  192. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
  193. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -307
  194. package/src/utils/internal/audioSessionPromise.ts +0 -39
  195. package/src/utils/internal/callingx.ts +0 -108
  196. package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
  197. package/src/utils/push/libs/callingx.ts +0 -90
  198. package/src/utils/push/setupCallingExpEvents.ts +0 -117
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rxSubjects","require","_videoClient","_libs","_utils","_reactNative","_reactNativeWebrtc","_pushLogoutCallback","setupIosCallKeepEvents","pushConfig","Platform","OS","ios","pushProviderName","android","incomingCallChannel","videoLoggerSystem","getLogger","debug","logger","callkeep","getCallKeepLib","getCallCid","callUUID","call_cid","NativeModules","StreamVideoReactNative","getIncomingCallCid","voipPushNotificationCallCId","RxUtils","getCurrentValue","voipPushNotificationCallCId$","next","undefined","answerCall","then","iosCallkeepAcceptCall","endCall","iosCallkeepRejectCall","didActivateAudioSession","RTCAudioSession","audioSessionDidActivate","didDeactivateAudioSession","audioSessionDidDeactivate","didDisplayIncomingCall","payload","voipPushNotification","getVoipPushNotificationLib","AppState","currentState","processCallFromPushInBackground","voipCallkeepCallOnForegroundMap$","uuid","cid","onVoipNotificationCompleted","remove","removeAnswerCall","addEventListener","removeEndCall","removeDisplayIncomingCall","removeDidActivateAudioSession","removeDidDeactivateAudioSession","removeDidLoadWithEvents","events","Array","isArray","length","forEach","event","name","data","setPushLogoutCallback","callUUIDFromCallkeep","shouldProcessCallFromCallkeep","clearPushWSEventSubscriptions","voipCallkeepAcceptedCallOnNativeDialerMap$","pushAcceptedIncomingCallCId$","removeIncomingCall"],"sourceRoot":"../../../../src","sources":["utils/push/setupIosCallKeepEvents.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAIA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AAIA;AACA;AACA;AACO,SAASO,sBAAsBA,CACpCC,UAAkD,EAClD;EACA,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACF,UAAU,CAACG,GAAG,CAACC,gBAAgB,EAAE;IAC7D;EACF;EACA,IAAI,CAACJ,UAAU,CAACK,OAAO,CAACC,mBAAmB,EAAE;IAC3C;IACAC,8BAAiB,CACdC,SAAS,CAAC,wBAAwB,CAAC,CACnCC,KAAK,CACJ,oFACF,CAAC;IACH;EACF;EACA,MAAMC,MAAM,GAAGH,8BAAiB,CAACC,SAAS,CAAC,wBAAwB,CAAC;EACpE,MAAMG,QAAQ,GAAG,IAAAC,oBAAc,EAAC,CAAC;EAEjC,eAAeC,UAAUA,CAACC,QAAgB,EAA+B;IACvE,IAAI;MACF,MAAMC,QAAQ,GACZ,MAAMC,0BAAa,CAACC,sBAAsB,CAACC,kBAAkB,CAACJ,QAAQ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AACgD,oBAAoB,EAAE;IACtC,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setupIosVoipPushEvents = setupIosVoipPushEvents;
7
+ var _libs = require("./libs");
7
8
  var _reactNative = require("react-native");
8
9
  var _ios = require("./internal/ios");
9
10
  var _pushLogoutCallback = require("../internal/pushLogoutCallback");
10
11
  var _videoClient = require("@stream-io/video-client");
11
- var _libs = require("./libs");
12
- // import { getVoipPushNotificationLib } from './libs';
13
-
14
12
  function setupIosVoipPushEvents(pushConfig) {
15
13
  if (_reactNative.Platform.OS !== 'ios' || !pushConfig.ios?.pushProviderName) {
16
14
  return;
@@ -21,13 +19,14 @@ function setupIosVoipPushEvents(pushConfig) {
21
19
  logger.debug('ios pushProviderName is not defined, so skipping the setupIosVoipPushEvents');
22
20
  return;
23
21
  }
24
- const callingx = (0, _libs.getCallingxLib)();
25
- const voipNotificationReceivedListener = callingx.addEventListener('voipNotificationReceived', params => {
26
- (0, _ios.onVoipNotificationReceived)(params, pushConfig);
22
+ const voipPushNotification = (0, _libs.getVoipPushNotificationLib)();
23
+ logger.debug('notification event listener added');
24
+ voipPushNotification.addEventListener('notification', notification => {
25
+ (0, _ios.onVoipNotificationReceived)(notification, pushConfig);
27
26
  });
28
27
  (0, _pushLogoutCallback.setPushLogoutCallback)(async () => {
29
28
  _videoClient.videoLoggerSystem.getLogger('setPushLogoutCallback').debug('notification event listener removed');
30
- voipNotificationReceivedListener.remove();
29
+ voipPushNotification.removeEventListener('notification');
31
30
  });
32
31
  }
33
32
  //# sourceMappingURL=setupIosVoipPushEvents.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_ios","_pushLogoutCallback","_videoClient","_libs","setupIosVoipPushEvents","pushConfig","Platform","OS","ios","pushProviderName","logger","videoLoggerSystem","getLogger","debug","callingx","getCallingxLib","voipNotificationReceivedListener","addEventListener","params","onVoipNotificationReceived","setPushLogoutCallback","remove"],"sourceRoot":"../../../../src","sources":["utils/push/setupIosVoipPushEvents.ts"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAPA;;AASO,SAASK,sBAAsBA,CACpCC,UAAkD,EAClD;EACA,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACF,UAAU,CAACG,GAAG,EAAEC,gBAAgB,EAAE;IAC9D;EACF;EACA,MAAMC,MAAM,GAAGC,8BAAiB,CAACC,SAAS,CAAC,wBAAwB,CAAC;EACpE,IAAI,CAACP,UAAU,CAACG,GAAG,CAACC,gBAAgB,EAAE;IACpC;IACAC,MAAM,CAACG,KAAK,CACV,6EACF,CAAC;IACD;EACF;EAEA,MAAMC,QAAQ,GAAG,IAAAC,oBAAc,EAAC,CAAC;EACjC,MAAMC,gCAAgC,GAAGF,QAAQ,CAACG,gBAAgB,CAChE,0BAA0B,EACzBC,MAAM,IAAK;IACV,IAAAC,+BAA0B,EAACD,MAAM,EAAEb,UAAU,CAAC;EAChD,CACF,CAAC;EAED,IAAAe,yCAAqB,EAAC,YAAY;IAChCT,8BAAiB,CACdC,SAAS,CAAC,uBAAuB,CAAC,CAClCC,KAAK,CAAC,qCAAqC,CAAC;IAC/CG,gCAAgC,CAACK,MAAM,CAAC,CAAC;EAC3C,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_libs","require","_reactNative","_ios","_pushLogoutCallback","_videoClient","setupIosVoipPushEvents","pushConfig","Platform","OS","ios","pushProviderName","logger","videoLoggerSystem","getLogger","debug","voipPushNotification","getVoipPushNotificationLib","addEventListener","notification","onVoipNotificationReceived","setPushLogoutCallback","removeEventListener"],"sourceRoot":"../../../../src","sources":["utils/push/setupIosVoipPushEvents.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AAEO,SAASK,sBAAsBA,CACpCC,UAAkD,EAClD;EACA,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACF,UAAU,CAACG,GAAG,EAAEC,gBAAgB,EAAE;IAC9D;EACF;EACA,MAAMC,MAAM,GAAGC,8BAAiB,CAACC,SAAS,CAAC,wBAAwB,CAAC;EACpE,IAAI,CAACP,UAAU,CAACG,GAAG,CAACC,gBAAgB,EAAE;IACpC;IACAC,MAAM,CAACG,KAAK,CACV,6EACF,CAAC;IACD;EACF;EACA,MAAMC,oBAAoB,GAAG,IAAAC,gCAA0B,EAAC,CAAC;EAEzDL,MAAM,CAACG,KAAK,CAAC,mCAAmC,CAAC;EACjDC,oBAAoB,CAACE,gBAAgB,CAAC,cAAc,EAAGC,YAAY,IAAK;IACtE,IAAAC,+BAA0B,EAACD,YAAY,EAAEZ,UAAU,CAAC;EACtD,CAAC,CAAC;EACF,IAAAc,yCAAqB,EAAC,YAAY;IAChCR,8BAAiB,CACdC,SAAS,CAAC,uBAAuB,CAAC,CAClCC,KAAK,CAAC,qCAAqC,CAAC;IAC/CC,oBAAoB,CAACM,mBAAmB,CAAC,cAAc,CAAC;EAC1D,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- const version = exports.version = '1.29.0-beta.1';
7
+ const version = exports.version = '1.29.0';
8
8
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["version","exports"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;;;;;AAAO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["version","exports"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;;;;;AAAO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,QAAQ","ignoreList":[]}
@@ -0,0 +1,153 @@
1
+ import { CallingState, RxUtils, videoLoggerSystem } from '@stream-io/video-client';
2
+ import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
3
+ import { NativeModules, Platform } from 'react-native';
4
+ import { useEffect, useState } from 'react';
5
+ import { StreamVideoRN } from '../../utils';
6
+ import { getCallKeepLib } from '../../utils/push/libs';
7
+ import { voipCallkeepAcceptedCallOnNativeDialerMap$, voipCallkeepCallOnForegroundMap$, voipPushNotificationCallCId$ } from '../../utils/push/internal/rxSubjects';
8
+ const isNonActiveCallingState = callingState => {
9
+ return callingState === CallingState.IDLE || callingState === CallingState.UNKNOWN || callingState === CallingState.LEFT;
10
+ };
11
+ const isAcceptedCallingState = callingState => {
12
+ return callingState === CallingState.JOINING || callingState === CallingState.JOINED;
13
+ };
14
+ const unsubscribeCallkeepEvents = async activeCallCid => {
15
+ const voipPushNotificationCallCId = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
16
+ if (activeCallCid && activeCallCid === voipPushNotificationCallCId) {
17
+ // callkeep events should not be listened anymore so clear the call cid
18
+ voipPushNotificationCallCId$.next(undefined);
19
+ }
20
+ return await NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid);
21
+ };
22
+ const logger = videoLoggerSystem.getLogger('useIosCallkeepWithCallingStateEffect');
23
+ const log = message => {
24
+ logger.warn(message);
25
+ };
26
+
27
+ /**
28
+ * This hook is used to inform the callkeep library that the call has been joined or ended.
29
+ */
30
+ export const useIosCallkeepWithCallingStateEffect = () => {
31
+ const activeCall = useCall();
32
+ const {
33
+ useCallCallingState
34
+ } = useCallStateHooks();
35
+ const callingState = useCallCallingState();
36
+ const [acceptedForegroundCallkeepMap, setAcceptedForegroundCallkeepMap] = useState();
37
+ useEffect(() => {
38
+ return () => {
39
+ const pushConfig = StreamVideoRN.getConfig().push;
40
+ if (Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios?.pushProviderName) {
41
+ return;
42
+ }
43
+ if (!pushConfig.android.incomingCallChannel) {
44
+ // TODO: remove this check and find a better way once we have telecom integration for android
45
+ return;
46
+ }
47
+ const callkeep = getCallKeepLib();
48
+ // if the component is unmounted and the callID was not reported to callkeep, then report it now
49
+ if (acceptedForegroundCallkeepMap) {
50
+ log(`Ending call in callkeep: ${acceptedForegroundCallkeepMap.cid}, reason: component unmounted and call was present in acceptedForegroundCallkeepMap`);
51
+ unsubscribeCallkeepEvents(acceptedForegroundCallkeepMap.cid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
52
+ }
53
+ };
54
+ }, [acceptedForegroundCallkeepMap]);
55
+ const activeCallCid = activeCall?.cid;
56
+ useEffect(() => {
57
+ return () => {
58
+ const pushConfig = StreamVideoRN.getConfig().push;
59
+ if (Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios?.pushProviderName || !activeCallCid) {
60
+ return;
61
+ }
62
+ if (!pushConfig.android.incomingCallChannel) {
63
+ // TODO: remove this check and find a better way once we have telecom integration for android
64
+ return;
65
+ }
66
+ const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(voipCallkeepAcceptedCallOnNativeDialerMap$);
67
+ const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
68
+ const callkeep = getCallKeepLib();
69
+ if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
70
+ log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in nativeDialerAcceptedCallMap`);
71
+ unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
72
+ // no need to keep this reference anymore
73
+ voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
74
+ } else if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
75
+ log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in foregroundIncomingCallkeepMap`);
76
+ unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
77
+ }
78
+ };
79
+ }, [activeCallCid]);
80
+ const pushConfig = StreamVideoRN.getConfig().push;
81
+ if (Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios.pushProviderName || !activeCallCid) {
82
+ return;
83
+ }
84
+ if (!pushConfig.android.incomingCallChannel) {
85
+ // TODO: remove this check and find a better way once we have telecom integration for android
86
+ return;
87
+ }
88
+
89
+ /**
90
+ * Check if current call is still needed to be accepted in callkeep
91
+ */
92
+ if (isAcceptedCallingState(callingState) && acceptedForegroundCallkeepMap?.cid !== activeCallCid) {
93
+ const callkeep = getCallKeepLib();
94
+ // push notification was displayed
95
+ // but the call has been accepted through the app and not through the native dialer
96
+ const foregroundCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
97
+ if (foregroundCallkeepMap && foregroundCallkeepMap.cid === activeCallCid) {
98
+ log(
99
+ // @ts-expect-error - types issue
100
+ `Accepting call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundCallkeepMap`);
101
+ // no need to keep this reference anymore
102
+ voipCallkeepCallOnForegroundMap$.next(undefined);
103
+ NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid).then(() => callkeep.answerIncomingCall(foregroundCallkeepMap.uuid));
104
+ // this call should be accepted in callkeep
105
+ setAcceptedForegroundCallkeepMap(foregroundCallkeepMap);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Check if current call is still needed to be ended in callkeep
111
+ */
112
+ if (isNonActiveCallingState(callingState)) {
113
+ const callkeep = getCallKeepLib();
114
+
115
+ // this was a previously joined call which had push notification displayed
116
+ // the call was accepted through the app and not through native dialer
117
+ // the call was left using the leave button in the app and not through native dialer
118
+ if (activeCallCid === acceptedForegroundCallkeepMap?.cid) {
119
+ log(
120
+ // @ts-expect-error - types issue
121
+ `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in acceptedForegroundCallkeepMap`);
122
+ unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
123
+ setAcceptedForegroundCallkeepMap(undefined);
124
+ return;
125
+ }
126
+ // this was a call which had push notification displayed but never joined
127
+ // the user rejected in the app and not from native dialer
128
+ const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
129
+ if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
130
+ log(
131
+ // @ts-expect-error - types issue
132
+ `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundIncomingCallkeepMap`);
133
+ unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
134
+ // no need to keep this reference anymore
135
+ voipCallkeepCallOnForegroundMap$.next(undefined);
136
+ return;
137
+ }
138
+ // this was a previously joined call
139
+ // it was an accepted call from native dialer and not from the app
140
+ // the user left using the leave button in the app
141
+ const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(voipCallkeepAcceptedCallOnNativeDialerMap$);
142
+ if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
143
+ log(
144
+ // @ts-expect-error - types issue
145
+ `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in nativeDialerAcceptedCallMap`);
146
+ unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
147
+ // no need to keep this reference anymore
148
+ voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
149
+ return;
150
+ }
151
+ }
152
+ };
153
+ //# sourceMappingURL=useIosCallkeepWithCallingStateEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CallingState","RxUtils","videoLoggerSystem","useCall","useCallStateHooks","NativeModules","Platform","useEffect","useState","StreamVideoRN","getCallKeepLib","voipCallkeepAcceptedCallOnNativeDialerMap$","voipCallkeepCallOnForegroundMap$","voipPushNotificationCallCId$","isNonActiveCallingState","callingState","IDLE","UNKNOWN","LEFT","isAcceptedCallingState","JOINING","JOINED","unsubscribeCallkeepEvents","activeCallCid","voipPushNotificationCallCId","getCurrentValue","next","undefined","StreamVideoReactNative","removeIncomingCall","logger","getLogger","log","message","warn","useIosCallkeepWithCallingStateEffect","activeCall","useCallCallingState","acceptedForegroundCallkeepMap","setAcceptedForegroundCallkeepMap","pushConfig","getConfig","push","OS","ios","pushProviderName","android","incomingCallChannel","callkeep","cid","then","endCall","uuid","nativeDialerAcceptedCallMap","foregroundIncomingCallkeepMap","foregroundCallkeepMap","answerIncomingCall"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosCallkeepWithCallingStateEffect.ts"],"mappings":"AAAA,SACEA,YAAY,EACZC,OAAO,EACPC,iBAAiB,QACZ,yBAAyB;AAChC,SAASC,OAAO,EAAEC,iBAAiB,QAAQ,iCAAiC;AAC5E,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SACEC,0CAA0C,EAC1CC,gCAAgC,EAChCC,4BAA4B,QACvB,sCAAsC;AAE7C,MAAMC,uBAAuB,GAAIC,YAA0B,IAAK;EAC9D,OACEA,YAAY,KAAKf,YAAY,CAACgB,IAAI,IAClCD,YAAY,KAAKf,YAAY,CAACiB,OAAO,IACrCF,YAAY,KAAKf,YAAY,CAACkB,IAAI;AAEtC,CAAC;AAED,MAAMC,sBAAsB,GAAIJ,YAA0B,IAAK;EAC7D,OACEA,YAAY,KAAKf,YAAY,CAACoB,OAAO,IACrCL,YAAY,KAAKf,YAAY,CAACqB,MAAM;AAExC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A4BT,aAAa,kCAAkCvB,YAAY,CAACe,YAAY,CAAC,wDACvG,CAAC;MACDO,yBAAyB,CAACC,aAAa,CAAC,CAAC2B,IAAI,CAAC,MAC5CF,QAAQ,CAACG,OAAO,CAACb,6BAA6B,CAACc,IAAI,CACrD,CAAC;MACDb,gCAAgC,CAACZ,SAAS,CAAC;MAC3C;IACF;IACA;IACA;IACA,MAAM2B,6BAA6B,GAAGrD,OAAO,CAACwB,eAAe,CAC3Db,gCACF,CAAC;IACD,IAAIW,aAAa,KAAK+B,6BAA6B,EAAEL,GAAG,EAAE;MACxDjB,GAAG;MACD;MACA,4BAA4BT,aAAa,kCAAkCvB,YAAY,CAACe,YAAY,CAAC,wDACvG,CAAC;MACDO,yBAAyB,CAACC,aAAa,CAAC,CAAC2B,IAAI,CAAC,MAC5CF,QAAQ,CAACG,OAAO,CAACG,6BAA6B,CAACF,IAAI,CACrD,CAAC;MACD;MACAxC,gCAAgC,CAACc,IAAI,CAACC,SAAS,CAAC;MAChD;IACF;IACA;IACA;IACA;IACA,MAAM0B,2BAA2B,GAAGpD,OAAO,CAACwB,eAAe,CACzDd,0CACF,CAAC;IACD,IAAIY,aAAa,KAAK8B,2BAA2B,EAAEJ,GAAG,EAAE;MACtDjB,GAAG;MACD;MACA,4BAA4BT,aAAa,kCAAkCvB,YAAY,CAACe,YAAY,CAAC,sDACvG,CAAC;MACDO,yBAAyB,CAACC,aAAa,CAAC,CAAC2B,IAAI,CAAC,MAC5CF,QAAQ,CAACG,OAAO,CAACE,2BAA2B,CAACD,IAAI,CACnD,CAAC;MACD;MACAzC,0CAA0C,CAACe,IAAI,CAACC,SAAS,CAAC;MAC1D;IACF;EACF;AACF,CAAC","ignoreList":[]}
@@ -1,11 +1,11 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
+ import { getVoipPushNotificationLib } from '../../utils/push/libs';
2
3
  import { Platform } from 'react-native';
3
4
  import { StreamVideoRN } from '../../utils';
4
5
  import { onVoipNotificationReceived } from '../../utils/push/internal/ios';
5
6
  import { useConnectedUser, useStreamVideoClient } from '@stream-io/video-react-bindings';
6
7
  import { setPushLogoutCallback } from '../../utils/internal/pushLogoutCallback';
7
8
  import { videoLoggerSystem } from '@stream-io/video-client';
8
- import { getCallingxLibIfAvailable } from '../../utils/push/libs';
9
9
  const logger = videoLoggerSystem.getLogger('useIosVoipPushEventsSetupEffect');
10
10
 
11
11
  /* VoipPushNotificationLib has support for only one listener type at a time
@@ -23,7 +23,6 @@ function setLogoutCallback(client, token, lastVoipTokenRef) {
23
23
  };
24
24
  try {
25
25
  await client.removeDevice(token);
26
- logger.debug('PushLogoutCallback - Removed voip token', token);
27
26
  } catch (err) {
28
27
  logger.warn('PushLogoutCallback - Failed to remove voip token', err);
29
28
  }
@@ -78,10 +77,20 @@ export const useIosVoipPushEventsSetupEffect = () => {
78
77
  useEffect(() => {
79
78
  const pushConfig = StreamVideoRN.getConfig().push;
80
79
  const pushProviderName = pushConfig?.ios.pushProviderName;
81
- const callingx = getCallingxLibIfAvailable();
82
- if (Platform.OS !== 'ios' || !client || !pushProviderName || !callingx) {
80
+ if (Platform.OS !== 'ios' || !client || !pushProviderName) {
83
81
  return;
84
82
  }
83
+ if (!pushConfig.android.incomingCallChannel) {
84
+ // TODO: remove this check and find a better way once we have telecom integration for android
85
+ logger.debug('android incomingCallChannel is not defined, so skipping the useIosVoipPushEventsSetupEffect');
86
+ return;
87
+ }
88
+ const voipPushNotification = getVoipPushNotificationLib();
89
+
90
+ // even though we do this natively, we have to still register here again
91
+ // natively this will make sure "register" event for JS is sent with the last push token
92
+ // Necessary if client changed before we got the event here or user logged out and logged in again
93
+ voipPushNotification.registerVoipToken();
85
94
  const onTokenReceived = token => {
86
95
  const userId = client.streamClient._user?.id ?? '';
87
96
  if (client.streamClient.anonymous || !token || !userId) {
@@ -109,24 +118,27 @@ export const useIosVoipPushEventsSetupEffect = () => {
109
118
  });
110
119
  };
111
120
  // fired when PushKit give us the latest token
112
- const voipRegisterListener = callingx.addEventListener('voipNotificationsRegistered', ({
113
- token
114
- }) => {
121
+ voipPushNotification.addEventListener('register', token => {
115
122
  onTokenReceived(token);
116
123
  });
117
124
 
118
- // this will return events that were fired before js bridge initialized
119
- callingx.getInitialVoipEvents().forEach(({
120
- eventName,
121
- params
122
- }) => {
123
- if (eventName === 'voipNotificationsRegistered' && 'token' in params) {
124
- onTokenReceived(params.token);
125
- } else if (eventName === 'voipNotificationReceived') {
126
- onVoipNotificationReceived(params, pushConfig);
125
+ // this will fire when there are events occured before js bridge initialized
126
+ voipPushNotification.addEventListener('didLoadWithEvents', events => {
127
+ if (!events || !Array.isArray(events) || events.length < 1) {
128
+ return;
129
+ }
130
+ for (const voipPushEvent of events) {
131
+ const {
132
+ name,
133
+ data
134
+ } = voipPushEvent;
135
+ if (name === 'RNVoipPushRemoteNotificationsRegisteredEvent') {
136
+ onTokenReceived(data);
137
+ } else if (name === 'RNVoipPushRemoteNotificationReceivedEvent') {
138
+ onVoipNotificationReceived(data, pushConfig);
139
+ }
127
140
  }
128
141
  });
129
- callingx.registerVoipToken();
130
142
  lastListener.count += 1;
131
143
  const currentListenerCount = lastListener.count;
132
144
  return () => {
@@ -136,7 +148,8 @@ export const useIosVoipPushEventsSetupEffect = () => {
136
148
  return;
137
149
  }
138
150
  logger.debug(`Voip event listeners are removed for user: ${userId}`);
139
- voipRegisterListener.remove();
151
+ voipPushNotification.removeEventListener('didLoadWithEvents');
152
+ voipPushNotification.removeEventListener('register');
140
153
  };
141
154
  }, [client]);
142
155
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","useState","Platform","StreamVideoRN","onVoipNotificationReceived","useConnectedUser","useStreamVideoClient","setPushLogoutCallback","videoLoggerSystem","getCallingxLibIfAvailable","logger","getLogger","lastListener","count","setLogoutCallback","client","token","lastVoipTokenRef","current","userId","removeDevice","debug","err","warn","useIosVoipPushEventsSetupEffect","connectedUserId","id","unsentToken","setUnsentToken","pushProviderName","getConfig","push","ios","tokenToSend","addVoipDevice","then","undefined","catch","error","pushConfig","callingx","OS","onTokenReceived","streamClient","_user","anonymous","reason","lastVoipToken","voipRegisterListener","addEventListener","getInitialVoipEvents","forEach","eventName","params","registerVoipToken","currentListenerCount","remove"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosVoipPushEventsSetupEffect.ts"],"mappings":"AAAA,SAAgCA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1E,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,0BAA0B,QAAQ,+BAA+B;AAC1E,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,iCAAiC;AACxC,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAA4BC,iBAAiB,QAAQ,yBAAyB;AAC9E,SAASC,yBAAyB,QAAQ,uBAAuB;AAEjE,MAAMC,MAAM,GAAGF,iBAAiB,CAACG,SAAS,CAAC,iCAAiC,CAAC;;AAE7E;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG;EAAEC,KAAK,EAAE;AAAE,CAAC;AAEjC,SAASC,iBAAiBA,CACxBC,MAAyB,EACzBC,KAAa,EACbC,gBAAqE,EACrE;EACAV,qBAAqB,CAAC,YAAY;IAChCU,gBAAgB,CAACC,OAAO,GAAG;MAAEF,KAAK,EAAE,EAAE;MAAEG,MAAM,EAAE;IAAG,CAAC;IACpD,IAAI;MACF,MAAMJ,MAAM,CAACK,YAAY,CAACJ,KAAK,CAAC;MAChCN,MAAM,CAACW,KAAK,CAAC,yCAAyC,EAAEL,KAAK,CAAC;IAChE,CAAC,CAAC,OAAOM,GAAG,EAAE;MACZZ,MAAM,CAACa,IAAI,CAAC,kDAAkD,EAAED,GAAG,CAAC;IACtE;EACF,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACnD,MAAMT,MAAM,GAAGT,oBAAoB,CAAC,CAAC;EACrC,MAA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AAmDF,MAAM,EAC3D,CAAC;QACD;MACF;MACAT,MAAM,CAACW,KAAK,CAAC,8CAA8CF,MAAM,EAAE,CAAC;MACpE6B,oBAAoB,CAACQ,MAAM,CAAC,CAAC;IAC/B,CAAC;EACH,CAAC,EAAE,CAACzC,MAAM,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useRef","useState","getVoipPushNotificationLib","Platform","StreamVideoRN","onVoipNotificationReceived","useConnectedUser","useStreamVideoClient","setPushLogoutCallback","videoLoggerSystem","logger","getLogger","lastListener","count","setLogoutCallback","client","token","lastVoipTokenRef","current","userId","removeDevice","err","warn","useIosVoipPushEventsSetupEffect","connectedUserId","id","unsentToken","setUnsentToken","pushProviderName","getConfig","push","ios","tokenToSend","debug","addVoipDevice","then","undefined","catch","error","pushConfig","OS","android","incomingCallChannel","voipPushNotification","registerVoipToken","onTokenReceived","streamClient","_user","anonymous","reason","lastVoipToken","addEventListener","events","Array","isArray","length","voipPushEvent","name","data","currentListenerCount","removeEventListener"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosVoipPushEventsSetupEffect.ts"],"mappings":"AAAA,SAAgCA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1E,SAASC,0BAA0B,QAAQ,uBAAuB;AAElE,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,0BAA0B,QAAQ,+BAA+B;AAC1E,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,iCAAiC;AACxC,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAA4BC,iBAAiB,QAAQ,yBAAyB;AAE9E,MAAMC,MAAM,GAAGD,iBAAiB,CAACE,SAAS,CAAC,iCAAiC,CAAC;;AAE7E;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG;EAAEC,KAAK,EAAE;AAAE,CAAC;AAEjC,SAASC,iBAAiBA,CACxBC,MAAyB,EACzBC,KAAa,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AAM,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAIA,MAAM,CAACG,MAAM,GAAG,CAAC,EAAE;QAC1D;MACF;MACA,KAAK,MAAMC,aAAa,IAAIJ,MAAM,EAAE;QAClC,MAAM;UAAEK,IAAI;UAAEC;QAAK,CAAC,GAAGF,aAAa;QACpC,IAAIC,IAAI,KAAK,8CAA8C,EAAE;UAC3DZ,eAAe,CAACa,IAAI,CAAC;QACvB,CAAC,MAAM,IAAID,IAAI,KAAK,2CAA2C,EAAE;UAC/DpD,0BAA0B,CAACqD,IAAI,EAAEnB,UAAU,CAAC;QAC9C;MACF;IACF,CAAC,CAAC;IACF3B,YAAY,CAACC,KAAK,IAAI,CAAC;IACvB,MAAM8C,oBAAoB,GAAG/C,YAAY,CAACC,KAAK;IAE/C,OAAO,MAAM;MACX,MAAMM,MAAM,GAAGJ,MAAM,CAAC+B,YAAY,CAACC,KAAK,EAAEtB,EAAE;MAC5C,IAAIkC,oBAAoB,KAAK/C,YAAY,CAACC,KAAK,EAAE;QAC/CH,MAAM,CAACuB,KAAK,CACV,mDAAmDd,MAAM,EAC3D,CAAC;QACD;MACF;MACAT,MAAM,CAACuB,KAAK,CAAC,8CAA8Cd,MAAM,EAAE,CAAC;MACpEwB,oBAAoB,CAACiB,mBAAmB,CAAC,mBAAmB,CAAC;MAC7DjB,oBAAoB,CAACiB,mBAAmB,CAAC,UAAU,CAAC;IACtD,CAAC;EACH,CAAC,EAAE,CAAC7C,MAAM,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
@@ -1,58 +1,93 @@
1
1
  import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
2
2
  import { useEffect, useRef } from 'react';
3
3
  import { StreamVideoRN } from '../utils';
4
- import { AppState, NativeModules, PermissionsAndroid, Platform } from 'react-native';
4
+ import { AppState, NativeModules, Platform } from 'react-native';
5
5
  import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
6
- import { keepCallAliveCallRef } from '../utils/keepCallAliveHeadlessTask';
7
- import { getNotifeeLibNoThrowForKeepCallAlive } from '../utils/push/libs/notifee';
8
- import { getCallingxLibIfAvailable } from '../utils/push/libs';
6
+ import { getKeepCallAliveForegroundServiceTypes, getNotifeeLibNoThrowForKeepCallAlive } from '../utils/push/libs/notifee';
9
7
  const notifeeLib = getNotifeeLibNoThrowForKeepCallAlive();
10
- async function stopForegroundServiceNoThrow() {
11
- const logger = videoLoggerSystem.getLogger('stopForegroundServiceNoThrow');
12
- try {
13
- await NativeModules.StreamVideoReactNative.stopKeepCallAliveService();
14
- } catch (e) {
15
- logger.warn('Failed to stop keep-call-alive foreground service', e);
16
- }
8
+ const callToPassToForegroundService = {
9
+ current: undefined
10
+ };
11
+ function setForegroundService() {
12
+ if (Platform.OS === 'ios' || !notifeeLib) return;
13
+ NativeModules.StreamVideoReactNative.isCallAliveConfigured().then(isConfigured => {
14
+ if (!isConfigured) {
15
+ const logger = videoLoggerSystem.getLogger('setForegroundService method');
16
+ logger.info('KeepCallAlive is not configured. Skipping foreground service setup.');
17
+ return;
18
+ }
19
+ notifeeLib.default.registerForegroundService(() => {
20
+ const task = new Promise(resolve => {
21
+ const logger = videoLoggerSystem.getLogger('setForegroundService method');
22
+ logger.info('Foreground service running for call in progress');
23
+ // any task to run from SDK in the foreground service must be added
24
+ resolve(true);
25
+ });
26
+ const videoConfig = StreamVideoRN.getConfig();
27
+ const foregroundServiceConfig = videoConfig.foregroundService;
28
+ const {
29
+ taskToRun
30
+ } = foregroundServiceConfig.android;
31
+ const call = callToPassToForegroundService.current;
32
+ if (!call) {
33
+ const logger = videoLoggerSystem.getLogger('setForegroundService method');
34
+ logger.warn('No call to pass to foreground service');
35
+ return task.then(() => new Promise(() => {}));
36
+ }
37
+ callToPassToForegroundService.current = undefined;
38
+ return task.then(() => taskToRun(call));
39
+ });
40
+ });
17
41
  }
18
42
  async function startForegroundService(call_cid) {
19
- const logger = videoLoggerSystem.getLogger('startForegroundService');
20
- const isCallAliveConfigured = await (async () => {
21
- try {
22
- return await NativeModules.StreamVideoReactNative.isCallAliveConfigured();
23
- } catch (e) {
24
- logger.warn('Failed to check whether KeepCallAlive is configured', e);
25
- return false;
26
- }
27
- })();
43
+ const isCallAliveConfigured = await NativeModules.StreamVideoReactNative.isCallAliveConfigured();
28
44
  if (!isCallAliveConfigured) {
45
+ const logger = videoLoggerSystem.getLogger('startForegroundService');
29
46
  logger.info('KeepCallAlive is not configured. Skipping foreground service setup.');
30
47
  return;
31
48
  }
32
- // Check for notification permission (Android 13+) before starting the service.
33
- const hasPostNotificationsPermission = Number(Platform.Version) < 33 || (await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS));
34
- if (!hasPostNotificationsPermission) {
49
+ // check for notification permission and then start the foreground service
50
+ if (!notifeeLib) return;
51
+ const settings = await notifeeLib.default.getNotificationSettings();
52
+ if (settings.authorizationStatus !== notifeeLib.AuthorizationStatus.AUTHORIZED) {
53
+ const logger = videoLoggerSystem.getLogger('startForegroundService');
35
54
  logger.info('Notification permission not granted, can not start foreground service to keep the call alive');
36
55
  return;
37
56
  }
38
57
  const videoConfig = StreamVideoRN.getConfig();
39
58
  const foregroundServiceConfig = videoConfig.foregroundService;
40
59
  const notificationTexts = foregroundServiceConfig.android.notificationTexts;
41
- const channel = foregroundServiceConfig.android.channel;
42
- const smallIconName = videoConfig.push?.android.smallIcon;
43
-
60
+ const channelId = foregroundServiceConfig.android.channel.id;
61
+ await notifeeLib.default.createChannel(foregroundServiceConfig.android.channel);
62
+ const foregroundServiceTypes = await getKeepCallAliveForegroundServiceTypes();
44
63
  // NOTE: we use requestAnimationFrame to ensure that the foreground service is started after all the current UI operations are done
45
64
  // this is a workaround for the crash - android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground()
46
65
  // this crash was reproducible only in some android devices
47
- requestAnimationFrame(async () => {
48
- try {
49
- await NativeModules.StreamVideoReactNative.startKeepCallAliveService(call_cid, channel.id, channel.name, notificationTexts.title, notificationTexts.body, smallIconName ?? null);
50
- } catch (e) {
51
- logger.warn('Failed to start keep-call-alive foreground service', e);
52
- }
66
+ requestAnimationFrame(() => {
67
+ notifeeLib.default.displayNotification({
68
+ id: call_cid,
69
+ title: notificationTexts.title,
70
+ body: notificationTexts.body,
71
+ android: {
72
+ channelId,
73
+ smallIcon: videoConfig.push?.android.smallIcon,
74
+ foregroundServiceTypes,
75
+ asForegroundService: true,
76
+ ongoing: true,
77
+ // user cannot dismiss the notification
78
+ colorized: true,
79
+ pressAction: {
80
+ id: 'default',
81
+ launchActivity: 'default' // open the app when the notification is pressed
82
+ }
83
+ }
84
+ });
53
85
  });
54
86
  }
55
87
 
88
+ // flag to check if setForegroundService has already been run once
89
+ let isSetForegroundServiceRan = false;
90
+
56
91
  /**
57
92
  * This hook is used to keep the call alive in the background for Android.
58
93
  * It starts a foreground service to keep the call alive as soon as the call is joined
@@ -62,7 +97,7 @@ async function startForegroundService(call_cid) {
62
97
  export const useAndroidKeepCallAliveEffect = () => {
63
98
  const foregroundServiceStartedRef = useRef(false);
64
99
  const call = useCall();
65
- keepCallAliveCallRef.current = call;
100
+ callToPassToForegroundService.current = call;
66
101
  const activeCallCid = call?.cid;
67
102
  const {
68
103
  useCallCallingState
@@ -70,16 +105,12 @@ export const useAndroidKeepCallAliveEffect = () => {
70
105
  const callingState = useCallCallingState();
71
106
  const isOutgoingCall = callingState === CallingState.RINGING && call?.isCreatedByMe;
72
107
  const isCallJoined = callingState === CallingState.JOINED;
73
- const isRingingCall = call?.ringing;
74
108
  const shouldStartForegroundService = !foregroundServiceStartedRef.current && (isOutgoingCall || isCallJoined);
75
109
  useEffect(() => {
76
110
  if (Platform.OS === 'ios' || !activeCallCid) {
77
111
  return undefined;
78
112
  }
79
- const callingx = getCallingxLibIfAvailable();
80
- if (callingx?.isSetup && (isRingingCall || !isRingingCall && callingx?.isOngoingCallsEnabled)) {
81
- return undefined;
82
- }
113
+ if (!notifeeLib) return undefined;
83
114
 
84
115
  // start foreground service as soon as the call is joined
85
116
  if (shouldStartForegroundService) {
@@ -87,18 +118,21 @@ export const useAndroidKeepCallAliveEffect = () => {
87
118
  if (foregroundServiceStartedRef.current) {
88
119
  return;
89
120
  }
90
- // Optional compatibility cleanup: if the app uses Notifee for ringing push,
91
- // we might have an incoming call notification running as a foreground service.
92
- if (notifeeLib) {
93
- const notifee = notifeeLib.default;
94
- const displayedNotifications = await notifee.getDisplayedNotifications();
95
- const activeCallNotification = displayedNotifications.find(notification => notification.id === activeCallCid);
96
- if (activeCallNotification) {
97
- // this means that we have a incoming call notification shown as foreground service and we must stop it
98
- notifee.stopForegroundService();
99
- notifee.cancelDisplayedNotification(activeCallCid);
100
- }
121
+ if (!isSetForegroundServiceRan) {
122
+ isSetForegroundServiceRan = true;
123
+ setForegroundService();
124
+ }
125
+ const notifee = notifeeLib.default;
126
+ const displayedNotifications = await notifee.getDisplayedNotifications();
127
+ const activeCallNotification = displayedNotifications.find(notification => notification.id === activeCallCid);
128
+ if (activeCallNotification) {
129
+ callToPassToForegroundService.current = undefined;
130
+ // this means that we have a incoming call notification shown as foreground service and we must stop it
131
+ notifee.stopForegroundService();
132
+ notifee.cancelDisplayedNotification(activeCallCid);
101
133
  }
134
+ // check for notification permission and then start the foreground service
135
+
102
136
  await startForegroundService(activeCallCid);
103
137
  foregroundServiceStartedRef.current = true;
104
138
  };
@@ -106,6 +140,7 @@ export const useAndroidKeepCallAliveEffect = () => {
106
140
  // ensure that app is active before running the function
107
141
  if (AppState.currentState === 'active') {
108
142
  run();
143
+ return undefined;
109
144
  }
110
145
  const sub = AppState.addEventListener('change', nextAppState => {
111
146
  if (nextAppState === 'active') {
@@ -120,36 +155,34 @@ export const useAndroidKeepCallAliveEffect = () => {
120
155
  return () => {
121
156
  // cancel any notifee displayed notification when the call has transitioned out of ringing
122
157
  // NOTE: cancels only the non fg service notifications
123
- if (notifeeLib) {
124
- notifeeLib.default.cancelDisplayedNotification(activeCallCid);
125
- }
158
+ notifeeLib.default.cancelDisplayedNotification(activeCallCid);
126
159
  };
127
160
  } else if (callingState === CallingState.IDLE || callingState === CallingState.LEFT) {
128
161
  if (foregroundServiceStartedRef.current) {
129
- keepCallAliveCallRef.current = undefined;
162
+ callToPassToForegroundService.current = undefined;
130
163
  // stop foreground service when the call is not active
131
- stopForegroundServiceNoThrow();
164
+ notifeeLib.default.stopForegroundService();
132
165
  foregroundServiceStartedRef.current = false;
133
166
  } else {
134
- if (notifeeLib) {
135
- notifeeLib.default.getDisplayedNotifications().then(displayedNotifications => {
136
- const activeCallNotification = displayedNotifications.find(notification => notification.id === activeCallCid);
137
- if (activeCallNotification) {
138
- // this means that we have a incoming call notification shown as foreground service and we must stop it
139
- notifeeLib.default.stopForegroundService();
140
- }
141
- });
142
- }
167
+ notifeeLib.default.getDisplayedNotifications().then(displayedNotifications => {
168
+ const activeCallNotification = displayedNotifications.find(notification => notification.id === activeCallCid);
169
+ if (activeCallNotification) {
170
+ callToPassToForegroundService.current = undefined;
171
+ // this means that we have a incoming call notification shown as foreground service and we must stop it
172
+ notifeeLib.default.stopForegroundService();
173
+ }
174
+ });
143
175
  }
144
176
  }
145
177
  return undefined;
146
- }, [activeCallCid, callingState, shouldStartForegroundService, isRingingCall]);
178
+ }, [activeCallCid, callingState, shouldStartForegroundService]);
147
179
  useEffect(() => {
148
180
  return () => {
149
181
  // stop foreground service when this effect is unmounted
150
182
  if (foregroundServiceStartedRef.current) {
151
- keepCallAliveCallRef.current = undefined;
152
- stopForegroundServiceNoThrow();
183
+ if (!notifeeLib) return;
184
+ callToPassToForegroundService.current = undefined;
185
+ notifeeLib.default.stopForegroundService();
153
186
  foregroundServiceStartedRef.current = false;
154
187
  }
155
188
  };