@stream-io/video-react-native-sdk 1.30.0 → 1.30.1-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 (208) 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 +149 -0
  8. package/dist/commonjs/hooks/push/index.js +0 -2
  9. package/dist/commonjs/hooks/push/index.js.map +1 -1
  10. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +121 -0
  11. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  12. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  13. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  14. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +64 -97
  15. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  16. package/dist/commonjs/index.js +1 -0
  17. package/dist/commonjs/index.js.map +1 -1
  18. package/dist/commonjs/modules/call-manager/CallManager.js +26 -0
  19. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  20. package/dist/commonjs/providers/StreamCall/index.js +6 -6
  21. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  22. package/dist/commonjs/utils/StreamVideoRN/index.js +33 -21
  23. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  24. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +68 -0
  25. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +1 -0
  26. package/dist/commonjs/utils/internal/callingx/callingx.js +123 -0
  27. package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -0
  28. package/dist/commonjs/utils/internal/registerSDKGlobals.js +52 -3
  29. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  30. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +48 -0
  31. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +1 -0
  32. package/dist/commonjs/utils/push/android.js +135 -202
  33. package/dist/commonjs/utils/push/android.js.map +1 -1
  34. package/dist/commonjs/utils/push/internal/ios.js +17 -34
  35. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  36. package/dist/commonjs/utils/push/internal/rxSubjects.js +1 -45
  37. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  38. package/dist/commonjs/utils/push/internal/utils.js +67 -52
  39. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  40. package/dist/commonjs/utils/push/ios.js.map +1 -1
  41. package/dist/commonjs/utils/push/libs/callingx.js +78 -0
  42. package/dist/commonjs/utils/push/libs/callingx.js.map +1 -0
  43. package/dist/commonjs/utils/push/libs/index.js +8 -19
  44. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  45. package/dist/commonjs/utils/push/libs/notifee/index.js +0 -19
  46. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  47. package/dist/commonjs/utils/push/setupCallingExpEvents.js +105 -0
  48. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -0
  49. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +7 -6
  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/hooks/push/index.js +0 -2
  54. package/dist/module/hooks/push/index.js.map +1 -1
  55. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +114 -0
  56. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  57. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  58. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  59. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +66 -99
  60. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  61. package/dist/module/index.js +1 -0
  62. package/dist/module/index.js.map +1 -1
  63. package/dist/module/modules/call-manager/CallManager.js +26 -0
  64. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  65. package/dist/module/providers/StreamCall/index.js +6 -6
  66. package/dist/module/providers/StreamCall/index.js.map +1 -1
  67. package/dist/module/utils/StreamVideoRN/index.js +33 -21
  68. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  69. package/dist/module/utils/internal/callingx/audioSessionPromise.js +61 -0
  70. package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +1 -0
  71. package/dist/module/utils/internal/callingx/callingx.js +114 -0
  72. package/dist/module/utils/internal/callingx/callingx.js.map +1 -0
  73. package/dist/module/utils/internal/registerSDKGlobals.js +52 -3
  74. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  75. package/dist/module/utils/keepCallAliveHeadlessTask.js +42 -0
  76. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +1 -0
  77. package/dist/module/utils/push/android.js +137 -204
  78. package/dist/module/utils/push/android.js.map +1 -1
  79. package/dist/module/utils/push/internal/ios.js +17 -34
  80. package/dist/module/utils/push/internal/ios.js.map +1 -1
  81. package/dist/module/utils/push/internal/rxSubjects.js +0 -44
  82. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  83. package/dist/module/utils/push/internal/utils.js +63 -49
  84. package/dist/module/utils/push/internal/utils.js.map +1 -1
  85. package/dist/module/utils/push/ios.js.map +1 -1
  86. package/dist/module/utils/push/libs/callingx.js +70 -0
  87. package/dist/module/utils/push/libs/callingx.js.map +1 -0
  88. package/dist/module/utils/push/libs/index.js +1 -2
  89. package/dist/module/utils/push/libs/index.js.map +1 -1
  90. package/dist/module/utils/push/libs/notifee/index.js +0 -18
  91. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  92. package/dist/module/utils/push/setupCallingExpEvents.js +99 -0
  93. package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -0
  94. package/dist/module/utils/push/setupIosVoipPushEvents.js +7 -6
  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/hooks/push/index.d.ts.map +1 -1
  99. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +5 -0
  100. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -0
  101. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  102. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  103. package/dist/typescript/index.d.ts +1 -0
  104. package/dist/typescript/index.d.ts.map +1 -1
  105. package/dist/typescript/modules/call-manager/CallManager.d.ts +5 -0
  106. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  107. package/dist/typescript/utils/StreamVideoRN/index.d.ts +20 -2
  108. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  109. package/dist/typescript/utils/StreamVideoRN/types.d.ts +63 -25
  110. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  111. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +16 -0
  112. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +1 -0
  113. package/dist/typescript/utils/internal/callingx/callingx.d.ts +17 -0
  114. package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +1 -0
  115. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  116. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +10 -0
  117. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +1 -0
  118. package/dist/typescript/utils/push/android.d.ts +1 -2
  119. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  120. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  121. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +0 -33
  122. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  123. package/dist/typescript/utils/push/internal/utils.d.ts +14 -8
  124. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  125. package/dist/typescript/utils/push/ios.d.ts +1 -2
  126. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  127. package/dist/typescript/utils/push/libs/callingx.d.ts +9 -0
  128. package/dist/typescript/utils/push/libs/callingx.d.ts.map +1 -0
  129. package/dist/typescript/utils/push/libs/index.d.ts +1 -2
  130. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  131. package/dist/typescript/utils/push/libs/notifee/index.d.ts +0 -1
  132. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  133. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +8 -0
  134. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -0
  135. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  136. package/dist/typescript/version.d.ts +1 -1
  137. package/dist/typescript/version.d.ts.map +1 -1
  138. package/expo-config-plugin/dist/withAndroidManifest.js +1 -33
  139. package/expo-config-plugin/dist/withAndroidPermissions.js +2 -7
  140. package/expo-config-plugin/dist/withAppDelegate.js +19 -197
  141. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  142. package/expo-config-plugin/dist/withiOSInfoPlist.js +2 -3
  143. package/ios/StreamInCallManager.m +2 -0
  144. package/ios/StreamInCallManager.swift +19 -7
  145. package/ios/StreamVideoReactNative.h +7 -4
  146. package/ios/StreamVideoReactNative.m +189 -82
  147. package/package.json +13 -18
  148. package/src/hooks/push/index.ts +0 -2
  149. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +147 -0
  150. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
  151. package/src/hooks/useAndroidKeepCallAliveEffect.ts +94 -120
  152. package/src/index.ts +1 -0
  153. package/src/modules/call-manager/CallManager.ts +36 -0
  154. package/src/modules/call-manager/native-module.d.ts +7 -0
  155. package/src/providers/StreamCall/index.tsx +6 -6
  156. package/src/utils/StreamVideoRN/index.ts +40 -30
  157. package/src/utils/StreamVideoRN/types.ts +65 -25
  158. package/src/utils/internal/callingx/audioSessionPromise.ts +65 -0
  159. package/src/utils/internal/callingx/callingx.ts +165 -0
  160. package/src/utils/internal/registerSDKGlobals.ts +47 -4
  161. package/src/utils/keepCallAliveHeadlessTask.ts +54 -0
  162. package/src/utils/push/android.ts +196 -311
  163. package/src/utils/push/internal/ios.ts +28 -44
  164. package/src/utils/push/internal/rxSubjects.ts +0 -61
  165. package/src/utils/push/internal/utils.ts +104 -63
  166. package/src/utils/push/ios.ts +1 -6
  167. package/src/utils/push/libs/callingx.ts +93 -0
  168. package/src/utils/push/libs/index.ts +1 -2
  169. package/src/utils/push/libs/notifee/index.ts +0 -27
  170. package/src/utils/push/setupCallingExpEvents.ts +135 -0
  171. package/src/utils/push/setupIosVoipPushEvents.ts +11 -7
  172. package/src/version.ts +1 -1
  173. package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +0 -95
  174. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -160
  175. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  176. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +0 -67
  177. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +0 -1
  178. package/dist/commonjs/utils/push/libs/callkeep.js +0 -17
  179. package/dist/commonjs/utils/push/libs/callkeep.js.map +0 -1
  180. package/dist/commonjs/utils/push/libs/voipPushNotification.js +0 -17
  181. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +0 -1
  182. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +0 -205
  183. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +0 -1
  184. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -153
  185. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  186. package/dist/module/hooks/push/useProcessPushCallEffect.js +0 -60
  187. package/dist/module/hooks/push/useProcessPushCallEffect.js.map +0 -1
  188. package/dist/module/utils/push/libs/callkeep.js +0 -11
  189. package/dist/module/utils/push/libs/callkeep.js.map +0 -1
  190. package/dist/module/utils/push/libs/voipPushNotification.js +0 -11
  191. package/dist/module/utils/push/libs/voipPushNotification.js.map +0 -1
  192. package/dist/module/utils/push/setupIosCallKeepEvents.js +0 -199
  193. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +0 -1
  194. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +0 -5
  195. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +0 -1
  196. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts +0 -8
  197. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts.map +0 -1
  198. package/dist/typescript/utils/push/libs/callkeep.d.ts +0 -3
  199. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +0 -1
  200. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +0 -3
  201. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +0 -1
  202. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +0 -6
  203. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +0 -1
  204. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +0 -235
  205. package/src/hooks/push/useProcessPushCallEffect.ts +0 -108
  206. package/src/utils/push/libs/callkeep.ts +0 -16
  207. package/src/utils/push/libs/voipPushNotification.ts +0 -17
  208. package/src/utils/push/setupIosCallKeepEvents.ts +0 -252
@@ -1,199 +0,0 @@
1
- import { pushAcceptedIncomingCallCId$, voipCallkeepAcceptedCallOnNativeDialerMap$, voipCallkeepCallOnForegroundMap$, voipPushNotificationCallCId$ } from './internal/rxSubjects';
2
- import { RxUtils, videoLoggerSystem } from '@stream-io/video-client';
3
- import { getCallKeepLib, getVoipPushNotificationLib } from './libs';
4
- import { clearPushWSEventSubscriptions, processCallFromPushInBackground } from './internal/utils';
5
- import { AppState, NativeModules, Platform } from 'react-native';
6
- import { RTCAudioSession } from '@stream-io/react-native-webrtc';
7
- import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
8
- /**
9
- * This hook is used to listen to callkeep events and do the necessary actions
10
- */
11
- export function setupIosCallKeepEvents(pushConfig) {
12
- if (Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName) {
13
- return;
14
- }
15
- if (!pushConfig.android.incomingCallChannel) {
16
- // TODO: remove this check and find a better way once we have telecom integration for android
17
- videoLoggerSystem.getLogger('setupIosCallKeepEvents').debug('android incomingCallChannel is not defined, so skipping the setupIosCallKeepEvents');
18
- return;
19
- }
20
- const logger = videoLoggerSystem.getLogger('setupIosCallKeepEvents');
21
- const callkeep = getCallKeepLib();
22
- async function getCallCid(callUUID) {
23
- try {
24
- const call_cid = await NativeModules.StreamVideoReactNative.getIncomingCallCid(callUUID);
25
- // in a case that voipPushNotificationCallCId$ is empty (this should not happen as voipPushNotificationCallCId$ is updated in push reception)]
26
- // update it with this call_cid
27
- const voipPushNotificationCallCId = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
28
- if (!voipPushNotificationCallCId) {
29
- logger.debug(`voipPushNotificationCallCId$ is empty, updating it with the call_cid: ${call_cid} for callUUID: ${callUUID}`);
30
- voipPushNotificationCallCId$.next(call_cid);
31
- }
32
- return call_cid;
33
- } catch {
34
- logger.debug(`Error in getting call cid from native module for callUUID: ${callUUID} - probably the call was already processed, so ignoring this callkeep event`);
35
- }
36
- return undefined;
37
- }
38
- function answerCall(callUUID) {
39
- getCallCid(callUUID).then(call_cid => {
40
- logger.debug(`answerCall event with call_cid: ${call_cid}`);
41
- iosCallkeepAcceptCall(call_cid, callUUID);
42
- });
43
- }
44
- function endCall(callUUID) {
45
- getCallCid(callUUID).then(call_cid => {
46
- logger.debug(`endCall event with call_cid: ${call_cid}`);
47
- iosCallkeepRejectCall(call_cid, callUUID, pushConfig);
48
- });
49
- }
50
-
51
- /**
52
- * CallKeep / CallKit audio-session events -> WebRTC (iOS)
53
- *
54
- * iOS CallKit is the authority that *activates* and *deactivates* the underlying `AVAudioSession`
55
- * when a call is answered/ended from the system UI (lock screen, Call UI, Bluetooth, etc).
56
- *
57
- * WebRTC on iOS wraps `AVAudioSession` with `RTCAudioSession` and its AudioDeviceModule relies on
58
- * being notified of those lifecycle transitions to correctly start/stop audio I/O and keep its
59
- * internal activation state consistent (e.g. activation count, playout/recording start).
60
- *
61
- * If these callbacks don’t reach WebRTC, answering via the native dialer UI can result in:
62
- * - no microphone capture / one-way audio
63
- * - silent playout until the app forces an audio reconfiguration
64
- * - flaky audio routing (speaker/earpiece/Bluetooth) across subsequent calls
65
- *
66
- * We forward CallKeep’s `didActivateAudioSession` / `didDeactivateAudioSession` events to WebRTC’s
67
- * `RTCAudioSession.audioSessionDidActivate()` / `audioSessionDidDeactivate()` methods.
68
- */
69
- function didActivateAudioSession() {
70
- logger.debug('didActivateAudioSession');
71
- RTCAudioSession.audioSessionDidActivate();
72
- }
73
- function didDeactivateAudioSession() {
74
- logger.debug('didDeactivateAudioSession');
75
- RTCAudioSession.audioSessionDidDeactivate();
76
- }
77
- function didDisplayIncomingCall(callUUID, payload) {
78
- const voipPushNotification = getVoipPushNotificationLib();
79
- // @ts-expect-error - call_cid is not part of RNCallKeepEventPayload
80
- const call_cid = payload?.call_cid;
81
- logger.debug(`didDisplayIncomingCall event with callUUID: ${callUUID} call_cid: ${call_cid}`);
82
- if (call_cid) {
83
- if (AppState.currentState === 'background') {
84
- processCallFromPushInBackground(pushConfig, call_cid, 'backgroundDelivered');
85
- }
86
- voipCallkeepCallOnForegroundMap$.next({
87
- uuid: callUUID,
88
- cid: call_cid
89
- });
90
- }
91
- voipPushNotification.onVoipNotificationCompleted(callUUID);
92
- }
93
- const {
94
- remove: removeAnswerCall
95
- } = callkeep.addEventListener('answerCall', ({
96
- callUUID
97
- }) => {
98
- answerCall(callUUID);
99
- });
100
- const {
101
- remove: removeEndCall
102
- } = callkeep.addEventListener('endCall', ({
103
- callUUID
104
- }) => {
105
- endCall(callUUID);
106
- });
107
- const {
108
- remove: removeDisplayIncomingCall
109
- } = callkeep.addEventListener('didDisplayIncomingCall', ({
110
- callUUID,
111
- payload
112
- }) => {
113
- didDisplayIncomingCall(callUUID, payload);
114
- });
115
- const {
116
- remove: removeDidActivateAudioSession
117
- } = callkeep.addEventListener('didActivateAudioSession', () => {
118
- didActivateAudioSession();
119
- });
120
- const {
121
- remove: removeDidDeactivateAudioSession
122
- } = callkeep.addEventListener('didDeactivateAudioSession', () => {
123
- didDeactivateAudioSession();
124
- });
125
- const {
126
- remove: removeDidLoadWithEvents
127
- } = callkeep.addEventListener('didLoadWithEvents', events => {
128
- if (!events || !Array.isArray(events) || events.length < 1) {
129
- return;
130
- }
131
- events.forEach(event => {
132
- const {
133
- name,
134
- data
135
- } = event;
136
- if (name === 'RNCallKeepDidDisplayIncomingCall') {
137
- didDisplayIncomingCall(data.callUUID, data.payload);
138
- } else if (name === 'RNCallKeepPerformAnswerCallAction') {
139
- answerCall(data.callUUID);
140
- } else if (name === 'RNCallKeepPerformEndCallAction') {
141
- endCall(data.callUUID);
142
- } else if (name === 'RNCallKeepDidActivateAudioSession') {
143
- didActivateAudioSession();
144
- } else if (name === 'RNCallKeepDidDeactivateAudioSession') {
145
- didDeactivateAudioSession();
146
- }
147
- });
148
- });
149
- setPushLogoutCallback(async () => {
150
- removeAnswerCall();
151
- removeEndCall();
152
- removeDisplayIncomingCall();
153
- removeDidActivateAudioSession();
154
- removeDidDeactivateAudioSession();
155
- removeDidLoadWithEvents();
156
- });
157
- }
158
- const iosCallkeepAcceptCall = (call_cid, callUUIDFromCallkeep) => {
159
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
160
- return;
161
- }
162
- clearPushWSEventSubscriptions(call_cid);
163
- // to call end callkeep later if ended in app and not through callkeep
164
- voipCallkeepAcceptedCallOnNativeDialerMap$.next({
165
- uuid: callUUIDFromCallkeep,
166
- cid: call_cid
167
- });
168
- // to process the call in the app
169
- pushAcceptedIncomingCallCId$.next(call_cid);
170
- // no need to keep these references anymore
171
- voipCallkeepCallOnForegroundMap$.next(undefined);
172
- };
173
- const iosCallkeepRejectCall = async (call_cid, callUUIDFromCallkeep, pushConfig) => {
174
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
175
- return;
176
- }
177
- clearPushWSEventSubscriptions(call_cid);
178
- // remove the references if the call_cid matches
179
- const voipPushNotificationCallCId = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
180
- if (voipPushNotificationCallCId === call_cid) {
181
- voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
182
- voipCallkeepCallOnForegroundMap$.next(undefined);
183
- voipPushNotificationCallCId$.next(undefined);
184
- }
185
- await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
186
- await NativeModules.StreamVideoReactNative?.removeIncomingCall(call_cid);
187
- };
188
-
189
- /**
190
- * Helper function to determine if the answer/end call event from callkeep must be processed
191
- * Just checks if we have a valid call_cid and acts as a type guard for call_cid
192
- */
193
- const shouldProcessCallFromCallkeep = (call_cid, callUUIDFromCallkeep) => {
194
- if (!call_cid || !callUUIDFromCallkeep) {
195
- return false;
196
- }
197
- return true;
198
- };
199
- //# sourceMappingURL=setupIosCallKeepEvents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["pushAcceptedIncomingCallCId$","voipCallkeepAcceptedCallOnNativeDialerMap$","voipCallkeepCallOnForegroundMap$","voipPushNotificationCallCId$","RxUtils","videoLoggerSystem","getCallKeepLib","getVoipPushNotificationLib","clearPushWSEventSubscriptions","processCallFromPushInBackground","AppState","NativeModules","Platform","RTCAudioSession","setPushLogoutCallback","setupIosCallKeepEvents","pushConfig","OS","ios","pushProviderName","android","incomingCallChannel","getLogger","debug","logger","callkeep","getCallCid","callUUID","call_cid","StreamVideoReactNative","getIncomingCallCid","voipPushNotificationCallCId","getCurrentValue","next","undefined","answerCall","then","iosCallkeepAcceptCall","endCall","iosCallkeepRejectCall","didActivateAudioSession","audioSessionDidActivate","didDeactivateAudioSession","audioSessionDidDeactivate","didDisplayIncomingCall","payload","voipPushNotification","currentState","uuid","cid","onVoipNotificationCompleted","remove","removeAnswerCall","addEventListener","removeEndCall","removeDisplayIncomingCall","removeDidActivateAudioSession","removeDidDeactivateAudioSession","removeDidLoadWithEvents","events","Array","isArray","length","forEach","event","name","data","callUUIDFromCallkeep","shouldProcessCallFromCallkeep","removeIncomingCall"],"sourceRoot":"../../../../src","sources":["utils/push/setupIosCallKeepEvents.ts"],"mappings":"AAAA,SACEA,4BAA4B,EAC5BC,0CAA0C,EAC1CC,gCAAgC,EAChCC,4BAA4B,QACvB,uBAAuB;AAC9B,SAASC,OAAO,EAAEC,iBAAiB,QAAQ,yBAAyB;AACpE,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,QAAQ;AAEnE,SACEC,6BAA6B,EAC7BC,+BAA+B,QAC1B,kBAAkB;AACzB,SAASC,QAAQ,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAChE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,qBAAqB,QAAQ,gCAAgC;AAItE;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,UAAkD,EAClD;EACA,IAAIJ,QAAQ,CAACK,EAAE,KAAK,KAAK,IAAI,CAACD,UAAU,CAACE,GAAG,CAACC,gBAAgB,EAAE;IAC7D;EACF;EACA,IAAI,CAACH,UAAU,CAACI,O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AAI,CAACC,SAAS,CAAC;IAChD/B,4BAA4B,CAAC8B,IAAI,CAACC,SAAS,CAAC;EAC9C;EAEA,MAAMzB,+BAA+B,CAACO,UAAU,EAAEY,QAAQ,EAAE,SAAS,CAAC;EACtE,MAAMjB,aAAa,CAACkB,sBAAsB,EAAEwC,kBAAkB,CAACzC,QAAQ,CAAC;AAC1E,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMwC,6BAA6B,GAAGA,CACpCxC,QAA4B,EAC5BuC,oBAA4B,KACL;EACvB,IAAI,CAACvC,QAAQ,IAAI,CAACuC,oBAAoB,EAAE;IACtC,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- /**
2
- * This hook is used to inform the callkeep library that the call has been joined or ended.
3
- */
4
- export declare const useIosCallkeepWithCallingStateEffect: () => void;
5
- //# sourceMappingURL=useIosCallkeepWithCallingStateEffect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIosCallkeepWithCallingStateEffect.d.ts","sourceRoot":"","sources":["../../../../src/hooks/push/useIosCallkeepWithCallingStateEffect.ts"],"names":[],"mappings":"AAmDA;;GAEG;AACH,eAAO,MAAM,oCAAoC,YAoLhD,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * This hook is used to process the incoming call data via push notifications using the relevant rxjs subjects
3
- * It either joins or leaves the call based on the user's action.
4
- * Note: this effect cannot work when push notifications are received when the app is in quit state or in other words when the client is not connected with a websocket.
5
- * So we essentially run this effect only when the client is connected with a websocket.
6
- */
7
- export declare const useProcessPushCallEffect: () => void;
8
- //# sourceMappingURL=useProcessPushCallEffect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useProcessPushCallEffect.d.ts","sourceRoot":"","sources":["../../../../src/hooks/push/useProcessPushCallEffect.ts"],"names":[],"mappings":"AAkBA;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,YAsDpC,CAAC"}
@@ -1,3 +0,0 @@
1
- export type RNCallKeepType = typeof import('react-native-callkeep').default;
2
- export declare function getCallKeepLib(): typeof import("react-native-callkeep").default;
3
- //# sourceMappingURL=callkeep.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"callkeep.d.ts","sourceRoot":"","sources":["../../../../../src/utils/push/libs/callkeep.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,cAAc,uBAAuB,EAAE,OAAO,CAAC;AAQ5E,wBAAgB,cAAc,mDAO7B"}
@@ -1,3 +0,0 @@
1
- export type VoipPushNotificationType = typeof import('react-native-voip-push-notification').default;
2
- export declare function getVoipPushNotificationLib(): typeof import("react-native-voip-push-notification").default;
3
- //# sourceMappingURL=voipPushNotification.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"voipPushNotification.d.ts","sourceRoot":"","sources":["../../../../../src/utils/push/libs/voipPushNotification.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAClC,cAAc,qCAAqC,EAAE,OAAO,CAAC;AAQ/D,wBAAgB,0BAA0B,iEAOzC"}
@@ -1,6 +0,0 @@
1
- import type { StreamVideoConfig } from '../StreamVideoRN/types';
2
- /**
3
- * This hook is used to listen to callkeep events and do the necessary actions
4
- */
5
- export declare function setupIosCallKeepEvents(pushConfig: NonNullable<StreamVideoConfig['push']>): void;
6
- //# sourceMappingURL=setupIosCallKeepEvents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupIosCallKeepEvents.d.ts","sourceRoot":"","sources":["../../../../src/utils/push/setupIosCallKeepEvents.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAWhE;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,QA4KnD"}
@@ -1,235 +0,0 @@
1
- import {
2
- CallingState,
3
- RxUtils,
4
- videoLoggerSystem,
5
- } from '@stream-io/video-client';
6
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
7
- import { NativeModules, Platform } from 'react-native';
8
- import { useEffect, useState } from 'react';
9
- import { StreamVideoRN } from '../../utils';
10
- import { getCallKeepLib } from '../../utils/push/libs';
11
- import {
12
- voipCallkeepAcceptedCallOnNativeDialerMap$,
13
- voipCallkeepCallOnForegroundMap$,
14
- voipPushNotificationCallCId$,
15
- } from '../../utils/push/internal/rxSubjects';
16
-
17
- const isNonActiveCallingState = (callingState: CallingState) => {
18
- return (
19
- callingState === CallingState.IDLE ||
20
- callingState === CallingState.UNKNOWN ||
21
- callingState === CallingState.LEFT
22
- );
23
- };
24
-
25
- const isAcceptedCallingState = (callingState: CallingState) => {
26
- return (
27
- callingState === CallingState.JOINING ||
28
- callingState === CallingState.JOINED
29
- );
30
- };
31
-
32
- const unsubscribeCallkeepEvents = async (activeCallCid: string | undefined) => {
33
- const voipPushNotificationCallCId = RxUtils.getCurrentValue(
34
- voipPushNotificationCallCId$,
35
- );
36
- if (activeCallCid && activeCallCid === voipPushNotificationCallCId) {
37
- // callkeep events should not be listened anymore so clear the call cid
38
- voipPushNotificationCallCId$.next(undefined);
39
- }
40
- return await NativeModules.StreamVideoReactNative?.removeIncomingCall(
41
- activeCallCid,
42
- );
43
- };
44
-
45
- const logger = videoLoggerSystem.getLogger(
46
- 'useIosCallkeepWithCallingStateEffect',
47
- );
48
- const log = (message: string) => {
49
- logger.warn(message);
50
- };
51
-
52
- /**
53
- * This hook is used to inform the callkeep library that the call has been joined or ended.
54
- */
55
- export const useIosCallkeepWithCallingStateEffect = () => {
56
- const activeCall = useCall();
57
- const { useCallCallingState } = useCallStateHooks();
58
- const callingState = useCallCallingState();
59
- const [acceptedForegroundCallkeepMap, setAcceptedForegroundCallkeepMap] =
60
- useState<{
61
- uuid: string;
62
- cid: string;
63
- }>();
64
-
65
- useEffect(() => {
66
- return () => {
67
- const pushConfig = StreamVideoRN.getConfig().push;
68
- if (
69
- Platform.OS !== 'ios' ||
70
- !pushConfig ||
71
- !pushConfig.ios?.pushProviderName
72
- ) {
73
- return;
74
- }
75
- if (!pushConfig.android.incomingCallChannel) {
76
- // TODO: remove this check and find a better way once we have telecom integration for android
77
- return;
78
- }
79
-
80
- const callkeep = getCallKeepLib();
81
- // if the component is unmounted and the callID was not reported to callkeep, then report it now
82
- if (acceptedForegroundCallkeepMap) {
83
- log(
84
- `Ending call in callkeep: ${acceptedForegroundCallkeepMap.cid}, reason: component unmounted and call was present in acceptedForegroundCallkeepMap`,
85
- );
86
- unsubscribeCallkeepEvents(acceptedForegroundCallkeepMap.cid).then(() =>
87
- callkeep.endCall(acceptedForegroundCallkeepMap.uuid),
88
- );
89
- }
90
- };
91
- }, [acceptedForegroundCallkeepMap]);
92
-
93
- const activeCallCid = activeCall?.cid;
94
-
95
- useEffect(() => {
96
- return () => {
97
- const pushConfig = StreamVideoRN.getConfig().push;
98
- if (
99
- Platform.OS !== 'ios' ||
100
- !pushConfig ||
101
- !pushConfig.ios?.pushProviderName ||
102
- !activeCallCid
103
- ) {
104
- return;
105
- }
106
- if (!pushConfig.android.incomingCallChannel) {
107
- // TODO: remove this check and find a better way once we have telecom integration for android
108
- return;
109
- }
110
- const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(
111
- voipCallkeepAcceptedCallOnNativeDialerMap$,
112
- );
113
- const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(
114
- voipCallkeepCallOnForegroundMap$,
115
- );
116
- const callkeep = getCallKeepLib();
117
- if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
118
- log(
119
- `Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in nativeDialerAcceptedCallMap`,
120
- );
121
- unsubscribeCallkeepEvents(activeCallCid).then(() =>
122
- callkeep.endCall(nativeDialerAcceptedCallMap.uuid),
123
- );
124
- // no need to keep this reference anymore
125
- voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
126
- } else if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
127
- log(
128
- `Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in foregroundIncomingCallkeepMap`,
129
- );
130
- unsubscribeCallkeepEvents(activeCallCid).then(() =>
131
- callkeep.endCall(foregroundIncomingCallkeepMap.uuid),
132
- );
133
- }
134
- };
135
- }, [activeCallCid]);
136
-
137
- const pushConfig = StreamVideoRN.getConfig().push;
138
- if (
139
- Platform.OS !== 'ios' ||
140
- !pushConfig ||
141
- !pushConfig.ios.pushProviderName ||
142
- !activeCallCid
143
- ) {
144
- return;
145
- }
146
- if (!pushConfig.android.incomingCallChannel) {
147
- // TODO: remove this check and find a better way once we have telecom integration for android
148
- return;
149
- }
150
-
151
- /**
152
- * Check if current call is still needed to be accepted in callkeep
153
- */
154
- if (
155
- isAcceptedCallingState(callingState) &&
156
- acceptedForegroundCallkeepMap?.cid !== activeCallCid
157
- ) {
158
- const callkeep = getCallKeepLib();
159
- // push notification was displayed
160
- // but the call has been accepted through the app and not through the native dialer
161
- const foregroundCallkeepMap = RxUtils.getCurrentValue(
162
- voipCallkeepCallOnForegroundMap$,
163
- );
164
- if (foregroundCallkeepMap && foregroundCallkeepMap.cid === activeCallCid) {
165
- log(
166
- // @ts-expect-error - types issue
167
- `Accepting call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundCallkeepMap`,
168
- );
169
- // no need to keep this reference anymore
170
- voipCallkeepCallOnForegroundMap$.next(undefined);
171
- NativeModules.StreamVideoReactNative?.removeIncomingCall(
172
- activeCallCid,
173
- ).then(() => callkeep.answerIncomingCall(foregroundCallkeepMap.uuid));
174
- // this call should be accepted in callkeep
175
- setAcceptedForegroundCallkeepMap(foregroundCallkeepMap);
176
- }
177
- }
178
-
179
- /**
180
- * Check if current call is still needed to be ended in callkeep
181
- */
182
- if (isNonActiveCallingState(callingState)) {
183
- const callkeep = getCallKeepLib();
184
-
185
- // this was a previously joined call which had push notification displayed
186
- // the call was accepted through the app and not through native dialer
187
- // the call was left using the leave button in the app and not through native dialer
188
- if (activeCallCid === acceptedForegroundCallkeepMap?.cid) {
189
- log(
190
- // @ts-expect-error - types issue
191
- `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in acceptedForegroundCallkeepMap`,
192
- );
193
- unsubscribeCallkeepEvents(activeCallCid).then(() =>
194
- callkeep.endCall(acceptedForegroundCallkeepMap.uuid),
195
- );
196
- setAcceptedForegroundCallkeepMap(undefined);
197
- return;
198
- }
199
- // this was a call which had push notification displayed but never joined
200
- // the user rejected in the app and not from native dialer
201
- const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(
202
- voipCallkeepCallOnForegroundMap$,
203
- );
204
- if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
205
- log(
206
- // @ts-expect-error - types issue
207
- `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundIncomingCallkeepMap`,
208
- );
209
- unsubscribeCallkeepEvents(activeCallCid).then(() =>
210
- callkeep.endCall(foregroundIncomingCallkeepMap.uuid),
211
- );
212
- // no need to keep this reference anymore
213
- voipCallkeepCallOnForegroundMap$.next(undefined);
214
- return;
215
- }
216
- // this was a previously joined call
217
- // it was an accepted call from native dialer and not from the app
218
- // the user left using the leave button in the app
219
- const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(
220
- voipCallkeepAcceptedCallOnNativeDialerMap$,
221
- );
222
- if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
223
- log(
224
- // @ts-expect-error - types issue
225
- `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in nativeDialerAcceptedCallMap`,
226
- );
227
- unsubscribeCallkeepEvents(activeCallCid).then(() =>
228
- callkeep.endCall(nativeDialerAcceptedCallMap.uuid),
229
- );
230
- // no need to keep this reference anymore
231
- voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
232
- return;
233
- }
234
- }
235
- };
@@ -1,108 +0,0 @@
1
- import {
2
- pushAcceptedIncomingCallCId$,
3
- pushAndroidBackgroundDeliveredIncomingCallCId$,
4
- pushRejectedIncomingCallCId$,
5
- pushTappedIncomingCallCId$,
6
- } from '../../utils/push/internal/rxSubjects';
7
- import { useEffect } from 'react';
8
- import { StreamVideoRN } from '../../utils';
9
- import {
10
- useConnectedUser,
11
- useStreamVideoClient,
12
- } from '@stream-io/video-react-bindings';
13
- import { BehaviorSubject } from 'rxjs';
14
- import { distinctUntilChanged, filter } from 'rxjs/operators';
15
- import { processCallFromPush } from '../../utils/push/internal/utils';
16
- import { StreamVideoClient, videoLoggerSystem } from '@stream-io/video-client';
17
- import type { StreamVideoConfig } from '../../utils/StreamVideoRN/types';
18
-
19
- /**
20
- * This hook is used to process the incoming call data via push notifications using the relevant rxjs subjects
21
- * It either joins or leaves the call based on the user's action.
22
- * Note: this effect cannot work when push notifications are received when the app is in quit state or in other words when the client is not connected with a websocket.
23
- * So we essentially run this effect only when the client is connected with a websocket.
24
- */
25
- export const useProcessPushCallEffect = () => {
26
- const client = useStreamVideoClient();
27
- const connectedUserId = useConnectedUser()?.id;
28
- // The Effect to join/reject call automatically when incoming call was received and processed from push notification
29
- useEffect(() => {
30
- const pushConfig = StreamVideoRN.getConfig().push;
31
- if (!pushConfig || !client || !connectedUserId) {
32
- return;
33
- }
34
-
35
- videoLoggerSystem
36
- .getLogger('useProcessPushCallEffect')
37
- .debug(
38
- `Adding subscriptions to process incoming call from push notification`,
39
- );
40
-
41
- // if the user accepts the call from push notification we join the call
42
- const acceptedCallSubscription = createCallSubscription(
43
- pushAcceptedIncomingCallCId$,
44
- client,
45
- pushConfig,
46
- 'accept',
47
- );
48
-
49
- // if the user rejects the call from push notification we leave the call
50
- const declinedCallSubscription = createCallSubscription(
51
- pushRejectedIncomingCallCId$,
52
- client,
53
- pushConfig,
54
- 'decline',
55
- );
56
-
57
- // if the user taps the call from push notification we do nothing as the only thing is to get the call which adds it to the client
58
- const pressedCallSubscription = createCallSubscription(
59
- pushTappedIncomingCallCId$,
60
- client,
61
- pushConfig,
62
- 'pressed',
63
- );
64
-
65
- const backgroundIncomingDeliveredCallSubscription = createCallSubscription(
66
- pushAndroidBackgroundDeliveredIncomingCallCId$,
67
- client,
68
- pushConfig,
69
- 'backgroundDelivered',
70
- );
71
-
72
- return () => {
73
- acceptedCallSubscription.unsubscribe();
74
- declinedCallSubscription.unsubscribe();
75
- pressedCallSubscription.unsubscribe();
76
- backgroundIncomingDeliveredCallSubscription.unsubscribe();
77
- };
78
- }, [client, connectedUserId]);
79
- };
80
-
81
- /**
82
- * A type guard to check if the cid is not undefined
83
- */
84
- function cidIsNotUndefined(cid: string | undefined): cid is string {
85
- return cid !== undefined;
86
- }
87
-
88
- /**
89
- * The common logic to create a subscription for the given call cid and action
90
- */
91
- const createCallSubscription = (
92
- behaviourSubjectWithCallCid: BehaviorSubject<string | undefined>,
93
- client: StreamVideoClient,
94
- pushConfig: NonNullable<StreamVideoConfig['push']>,
95
- action: 'accept' | 'decline' | 'pressed' | 'backgroundDelivered',
96
- ) => {
97
- return behaviourSubjectWithCallCid
98
- .pipe(distinctUntilChanged(), filter(cidIsNotUndefined))
99
- .subscribe(async (callCId) => {
100
- videoLoggerSystem
101
- .getLogger('useProcessPushCallEffect')
102
- .debug(
103
- `Processing call from push notification with action: ${action} and callCId: ${callCId}`,
104
- );
105
- await processCallFromPush(client, callCId, action, pushConfig);
106
- behaviourSubjectWithCallCid.next(undefined); // remove the current call id to avoid processing again
107
- });
108
- };
@@ -1,16 +0,0 @@
1
- export type RNCallKeepType = typeof import('react-native-callkeep').default;
2
-
3
- let callkeep: RNCallKeepType | undefined;
4
-
5
- try {
6
- callkeep = require('react-native-callkeep').default;
7
- } catch {}
8
-
9
- export function getCallKeepLib() {
10
- if (!callkeep) {
11
- throw Error(
12
- 'react-native-callkeep library is not installed. Please see https://github.com/react-native-webrtc/react-native-callkeep#Installation for installation instructions',
13
- );
14
- }
15
- return callkeep;
16
- }
@@ -1,17 +0,0 @@
1
- export type VoipPushNotificationType =
2
- typeof import('react-native-voip-push-notification').default;
3
-
4
- let voipPushNotification: VoipPushNotificationType | undefined;
5
-
6
- try {
7
- voipPushNotification = require('react-native-voip-push-notification').default;
8
- } catch {}
9
-
10
- export function getVoipPushNotificationLib() {
11
- if (!voipPushNotification) {
12
- throw Error(
13
- "react-native-voip-push-notification library is not installed. Please install it using 'yarn add react-native-voip-push-notification' or 'npm i react-native-voip-push-notification --save'",
14
- );
15
- }
16
- return voipPushNotification;
17
- }