@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
@@ -0,0 +1,135 @@
1
+ import { videoLoggerSystem } from '@stream-io/video-client';
2
+ import type { StreamVideoConfig } from '../StreamVideoRN/types';
3
+ import {
4
+ clearPushWSEventSubscriptions,
5
+ processCallFromPushInBackground,
6
+ } from './internal/utils';
7
+ import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
8
+ import { resolvePendingAudioSession } from '../internal/callingx/audioSessionPromise';
9
+ import {
10
+ getCallingxLib,
11
+ type EventData,
12
+ type EventParams,
13
+ } from './libs/callingx';
14
+ import { Platform } from 'react-native';
15
+
16
+ type PushConfig = NonNullable<StreamVideoConfig['push']>;
17
+
18
+ const logger = videoLoggerSystem.getLogger('callingx');
19
+
20
+ /**
21
+ * Sets up callingx event listeners for handling call actions from the native calling UI.
22
+ */
23
+ export function setupCallingExpEvents(pushConfig: NonNullable<PushConfig>) {
24
+ const hasPushProvider =
25
+ (Platform.OS === 'android' && pushConfig.android?.pushProviderName) ||
26
+ (Platform.OS === 'ios' && pushConfig.ios?.pushProviderName);
27
+
28
+ if (!hasPushProvider) {
29
+ return;
30
+ }
31
+
32
+ const callingx = getCallingxLib();
33
+
34
+ const { remove: removeAnswerCall } = callingx.addEventListener(
35
+ 'answerCall',
36
+ (params) => {
37
+ onAcceptCall(pushConfig)(params);
38
+ },
39
+ );
40
+
41
+ const { remove: removeEndCall } = callingx.addEventListener(
42
+ 'endCall',
43
+ (params) => {
44
+ onEndCall(pushConfig)(params);
45
+ },
46
+ );
47
+
48
+ const { remove: removeDidActivateAudioSession } = callingx.addEventListener(
49
+ 'didActivateAudioSession',
50
+ onDidActivateAudioSession,
51
+ );
52
+ const { remove: removeDidDeactivateAudioSession } = callingx.addEventListener(
53
+ 'didDeactivateAudioSession',
54
+ onDidDeactivateAudioSession,
55
+ );
56
+
57
+ //NOTE: until getInitialEvents invocation, events are delayed and won't be sent to event listeners, this is a way to make sure none of required events are missed
58
+ //in most cases there will be no delayed answers or ends, but if so we don't want to miss any of them
59
+ const events = callingx.getInitialEvents();
60
+ events.forEach((event: EventData) => {
61
+ const { eventName, params } = event;
62
+ if (eventName === 'answerCall') {
63
+ logger.debug(`answerCall delayed event callId: ${params?.callId}`);
64
+ onAcceptCall(pushConfig)(params as EventParams['answerCall']);
65
+ } else if (eventName === 'endCall') {
66
+ logger.debug(`endCall delayed event callId: ${params?.callId}`);
67
+ onEndCall(pushConfig)(params as EventParams['endCall']);
68
+ } else if (eventName === 'didActivateAudioSession') {
69
+ onDidActivateAudioSession();
70
+ } else if (eventName === 'didDeactivateAudioSession') {
71
+ onDidDeactivateAudioSession();
72
+ }
73
+ });
74
+
75
+ setPushLogoutCallback(async () => {
76
+ removeAnswerCall();
77
+ removeEndCall();
78
+ removeDidActivateAudioSession();
79
+ removeDidDeactivateAudioSession();
80
+ });
81
+ }
82
+
83
+ const onDidActivateAudioSession = () => {
84
+ logger.debug('callingExpDidActivateAudioSession');
85
+ resolvePendingAudioSession();
86
+ };
87
+
88
+ const onDidDeactivateAudioSession = () => {
89
+ logger.debug('callingExpDidDeactivateAudioSession');
90
+ };
91
+
92
+ const onAcceptCall =
93
+ (pushConfig: PushConfig) =>
94
+ ({ callId: call_cid, source }: EventParams['answerCall']) => {
95
+ logger.debug(`onAcceptCall event call_cid: ${call_cid} source: ${source}`);
96
+
97
+ if (source === 'app' || !call_cid) {
98
+ // App-initiated actions are fulfilled on the native side immediately — nothing to do here
99
+ return;
100
+ }
101
+
102
+ const callingx = getCallingxLib();
103
+ clearPushWSEventSubscriptions(call_cid);
104
+
105
+ processCallFromPushInBackground(
106
+ pushConfig,
107
+ call_cid,
108
+ 'accept',
109
+ (didFail) => {
110
+ callingx.fulfillAnswerCallAction(call_cid, didFail);
111
+ },
112
+ );
113
+ };
114
+
115
+ const onEndCall =
116
+ (pushConfig: PushConfig) =>
117
+ ({ callId: call_cid, source }: EventParams['endCall']) => {
118
+ logger.debug(`onEndCall event call_cid: ${call_cid} source: ${source}`);
119
+
120
+ if (source === 'app' || !call_cid) {
121
+ // App-initiated actions are fulfilled on the native side immediately — nothing to do here
122
+ return;
123
+ }
124
+
125
+ const callingx = getCallingxLib();
126
+ clearPushWSEventSubscriptions(call_cid);
127
+ processCallFromPushInBackground(
128
+ pushConfig,
129
+ call_cid,
130
+ 'decline',
131
+ (didFail) => {
132
+ callingx.fulfillEndCallAction(call_cid, didFail);
133
+ },
134
+ );
135
+ };
@@ -1,10 +1,11 @@
1
- import { getVoipPushNotificationLib } from './libs';
1
+ // import { getVoipPushNotificationLib } from './libs';
2
2
 
3
3
  import { Platform } from 'react-native';
4
4
  import { onVoipNotificationReceived } from './internal/ios';
5
5
  import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
6
6
  import { StreamVideoConfig } from '../StreamVideoRN/types';
7
7
  import { videoLoggerSystem } from '@stream-io/video-client';
8
+ import { getCallingxLib } from './libs';
8
9
 
9
10
  export function setupIosVoipPushEvents(
10
11
  pushConfig: NonNullable<StreamVideoConfig['push']>,
@@ -20,16 +21,19 @@ export function setupIosVoipPushEvents(
20
21
  );
21
22
  return;
22
23
  }
23
- const voipPushNotification = getVoipPushNotificationLib();
24
24
 
25
- logger.debug('notification event listener added');
26
- voipPushNotification.addEventListener('notification', (notification) => {
27
- onVoipNotificationReceived(notification, pushConfig);
28
- });
25
+ const callingx = getCallingxLib();
26
+ const voipNotificationReceivedListener = callingx.addEventListener(
27
+ 'voipNotificationReceived',
28
+ (params) => {
29
+ onVoipNotificationReceived(params, pushConfig);
30
+ },
31
+ );
32
+
29
33
  setPushLogoutCallback(async () => {
30
34
  videoLoggerSystem
31
35
  .getLogger('setPushLogoutCallback')
32
36
  .debug('notification event listener removed');
33
- voipPushNotification.removeEventListener('notification');
37
+ voipNotificationReceivedListener.remove();
34
38
  });
35
39
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.30.0';
1
+ export const version = '1.30.1-beta.1';
@@ -1,95 +0,0 @@
1
- package com.streamvideo.reactnative.util
2
-
3
- import android.content.ComponentName
4
- import android.content.pm.PackageManager
5
- import android.content.pm.ServiceInfo
6
- import android.os.Build
7
- import android.util.Log
8
- import androidx.annotation.RequiresApi
9
- import com.facebook.react.bridge.ReactApplicationContext
10
-
11
- @RequiresApi(api = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
12
- object CallAliveServiceChecker {
13
- private const val NAME = "StreamVideoReactNative"
14
-
15
- fun isForegroundServiceDeclared(context: ReactApplicationContext): Boolean {
16
- val packageManager = context.packageManager
17
- val packageName = context.packageName // Get the package name of your app
18
- val componentName = ComponentName(
19
- packageName,
20
- "app.notifee.core.ForegroundService"
21
- ) // Use service name string
22
-
23
- try {
24
- val serviceInfo =
25
- packageManager.getServiceInfo(componentName, PackageManager.GET_META_DATA)
26
-
27
- val expectedForegroundServiceTypes =
28
- ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE or
29
- ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK or
30
- ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA or
31
- ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
32
-
33
- val actualForegroundServiceTypes = serviceInfo.foregroundServiceType
34
-
35
- if (actualForegroundServiceTypes == expectedForegroundServiceTypes) {
36
- return true
37
- } else {
38
- Log.w(
39
- NAME,
40
- "android:foregroundServiceType does not match: expected=${
41
- foregroundServiceTypeToString(
42
- expectedForegroundServiceTypes
43
- )
44
- }, actual=${foregroundServiceTypeToString(actualForegroundServiceTypes)}"
45
- )
46
- return false
47
- }
48
-
49
- } catch (e: PackageManager.NameNotFoundException) {
50
- Log.d(NAME, "Service not found: " + e.message)
51
- return false // Service not declared
52
- }
53
- }
54
-
55
- private fun foregroundServiceTypeToString(foregroundServiceType: Int): String {
56
- val types = mutableListOf<String>()
57
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE != 0) {
58
- types.add("shortService")
59
- }
60
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC != 0) {
61
- types.add("dataSync")
62
- }
63
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA != 0) {
64
- types.add("camera")
65
- }
66
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE != 0) {
67
- types.add("microphone")
68
- }
69
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE != 0) {
70
- types.add("connectedDevice")
71
- }
72
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION != 0) {
73
- types.add("location")
74
- }
75
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK != 0) {
76
- types.add("mediaPlayback")
77
- }
78
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION != 0) {
79
- types.add("mediaProjection")
80
- }
81
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL != 0) {
82
- types.add("phoneCall")
83
- }
84
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_HEALTH != 0) {
85
- types.add("health")
86
- }
87
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING != 0) {
88
- types.add("remoteMessaging")
89
- }
90
- if (foregroundServiceType and ServiceInfo.FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED != 0) {
91
- types.add("systemExempted")
92
- }
93
- return types.joinToString("|")
94
- }
95
- }
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useIosCallkeepWithCallingStateEffect = void 0;
7
- var _videoClient = require("@stream-io/video-client");
8
- var _videoReactBindings = require("@stream-io/video-react-bindings");
9
- var _reactNative = require("react-native");
10
- var _react = require("react");
11
- var _utils = require("../../utils");
12
- var _libs = require("../../utils/push/libs");
13
- var _rxSubjects = require("../../utils/push/internal/rxSubjects");
14
- const isNonActiveCallingState = callingState => {
15
- return callingState === _videoClient.CallingState.IDLE || callingState === _videoClient.CallingState.UNKNOWN || callingState === _videoClient.CallingState.LEFT;
16
- };
17
- const isAcceptedCallingState = callingState => {
18
- return callingState === _videoClient.CallingState.JOINING || callingState === _videoClient.CallingState.JOINED;
19
- };
20
- const unsubscribeCallkeepEvents = async activeCallCid => {
21
- const voipPushNotificationCallCId = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipPushNotificationCallCId$);
22
- if (activeCallCid && activeCallCid === voipPushNotificationCallCId) {
23
- // callkeep events should not be listened anymore so clear the call cid
24
- _rxSubjects.voipPushNotificationCallCId$.next(undefined);
25
- }
26
- return await _reactNative.NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid);
27
- };
28
- const logger = _videoClient.videoLoggerSystem.getLogger('useIosCallkeepWithCallingStateEffect');
29
- const log = message => {
30
- logger.warn(message);
31
- };
32
-
33
- /**
34
- * This hook is used to inform the callkeep library that the call has been joined or ended.
35
- */
36
- const useIosCallkeepWithCallingStateEffect = () => {
37
- const activeCall = (0, _videoReactBindings.useCall)();
38
- const {
39
- useCallCallingState
40
- } = (0, _videoReactBindings.useCallStateHooks)();
41
- const callingState = useCallCallingState();
42
- const [acceptedForegroundCallkeepMap, setAcceptedForegroundCallkeepMap] = (0, _react.useState)();
43
- (0, _react.useEffect)(() => {
44
- return () => {
45
- const pushConfig = _utils.StreamVideoRN.getConfig().push;
46
- if (_reactNative.Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios?.pushProviderName) {
47
- return;
48
- }
49
- if (!pushConfig.android.incomingCallChannel) {
50
- // TODO: remove this check and find a better way once we have telecom integration for android
51
- return;
52
- }
53
- const callkeep = (0, _libs.getCallKeepLib)();
54
- // if the component is unmounted and the callID was not reported to callkeep, then report it now
55
- if (acceptedForegroundCallkeepMap) {
56
- log(`Ending call in callkeep: ${acceptedForegroundCallkeepMap.cid}, reason: component unmounted and call was present in acceptedForegroundCallkeepMap`);
57
- unsubscribeCallkeepEvents(acceptedForegroundCallkeepMap.cid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
58
- }
59
- };
60
- }, [acceptedForegroundCallkeepMap]);
61
- const activeCallCid = activeCall?.cid;
62
- (0, _react.useEffect)(() => {
63
- return () => {
64
- const pushConfig = _utils.StreamVideoRN.getConfig().push;
65
- if (_reactNative.Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios?.pushProviderName || !activeCallCid) {
66
- return;
67
- }
68
- if (!pushConfig.android.incomingCallChannel) {
69
- // TODO: remove this check and find a better way once we have telecom integration for android
70
- return;
71
- }
72
- const nativeDialerAcceptedCallMap = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$);
73
- const foregroundIncomingCallkeepMap = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipCallkeepCallOnForegroundMap$);
74
- const callkeep = (0, _libs.getCallKeepLib)();
75
- if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
76
- log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in nativeDialerAcceptedCallMap`);
77
- unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
78
- // no need to keep this reference anymore
79
- _rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
80
- } else if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
81
- log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in foregroundIncomingCallkeepMap`);
82
- unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
83
- }
84
- };
85
- }, [activeCallCid]);
86
- const pushConfig = _utils.StreamVideoRN.getConfig().push;
87
- if (_reactNative.Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios.pushProviderName || !activeCallCid) {
88
- return;
89
- }
90
- if (!pushConfig.android.incomingCallChannel) {
91
- // TODO: remove this check and find a better way once we have telecom integration for android
92
- return;
93
- }
94
-
95
- /**
96
- * Check if current call is still needed to be accepted in callkeep
97
- */
98
- if (isAcceptedCallingState(callingState) && acceptedForegroundCallkeepMap?.cid !== activeCallCid) {
99
- const callkeep = (0, _libs.getCallKeepLib)();
100
- // push notification was displayed
101
- // but the call has been accepted through the app and not through the native dialer
102
- const foregroundCallkeepMap = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipCallkeepCallOnForegroundMap$);
103
- if (foregroundCallkeepMap && foregroundCallkeepMap.cid === activeCallCid) {
104
- log(
105
- // @ts-expect-error - types issue
106
- `Accepting call in callkeep: ${activeCallCid}, reason: callingstate went to ${_videoClient.CallingState[callingState]} and call was present in foregroundCallkeepMap`);
107
- // no need to keep this reference anymore
108
- _rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
109
- _reactNative.NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid).then(() => callkeep.answerIncomingCall(foregroundCallkeepMap.uuid));
110
- // this call should be accepted in callkeep
111
- setAcceptedForegroundCallkeepMap(foregroundCallkeepMap);
112
- }
113
- }
114
-
115
- /**
116
- * Check if current call is still needed to be ended in callkeep
117
- */
118
- if (isNonActiveCallingState(callingState)) {
119
- const callkeep = (0, _libs.getCallKeepLib)();
120
-
121
- // this was a previously joined call which had push notification displayed
122
- // the call was accepted through the app and not through native dialer
123
- // the call was left using the leave button in the app and not through native dialer
124
- if (activeCallCid === acceptedForegroundCallkeepMap?.cid) {
125
- log(
126
- // @ts-expect-error - types issue
127
- `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${_videoClient.CallingState[callingState]} and call was present in acceptedForegroundCallkeepMap`);
128
- unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
129
- setAcceptedForegroundCallkeepMap(undefined);
130
- return;
131
- }
132
- // this was a call which had push notification displayed but never joined
133
- // the user rejected in the app and not from native dialer
134
- const foregroundIncomingCallkeepMap = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipCallkeepCallOnForegroundMap$);
135
- if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
136
- log(
137
- // @ts-expect-error - types issue
138
- `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${_videoClient.CallingState[callingState]} and call was present in foregroundIncomingCallkeepMap`);
139
- unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
140
- // no need to keep this reference anymore
141
- _rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
142
- return;
143
- }
144
- // this was a previously joined call
145
- // it was an accepted call from native dialer and not from the app
146
- // the user left using the leave button in the app
147
- const nativeDialerAcceptedCallMap = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$);
148
- if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
149
- log(
150
- // @ts-expect-error - types issue
151
- `Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${_videoClient.CallingState[callingState]} and call was present in nativeDialerAcceptedCallMap`);
152
- unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
153
- // no need to keep this reference anymore
154
- _rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
155
- return;
156
- }
157
- }
158
- };
159
- exports.useIosCallkeepWithCallingStateEffect = useIosCallkeepWithCallingStateEffect;
160
- //# sourceMappingURL=useIosCallkeepWithCallingStateEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_videoClient","require","_videoReactBindings","_reactNative","_react","_utils","_libs","_rxSubjects","isNonActiveCallingState","callingState","CallingState","IDLE","UNKNOWN","LEFT","isAcceptedCallingState","JOINING","JOINED","unsubscribeCallkeepEvents","activeCallCid","voipPushNotificationCallCId","RxUtils","getCurrentValue","voipPushNotificationCallCId$","next","undefined","NativeModules","StreamVideoReactNative","removeIncomingCall","logger","videoLoggerSystem","getLogger","log","message","warn","useIosCallkeepWithCallingStateEffect","activeCall","useCall","useCallCallingState","useCallStateHooks","acceptedForegroundCallkeepMap","setAcceptedForegroundCallkeepMap","useState","useEffect","pushConfig","StreamVideoRN","getConfig","push","Platform","OS","ios","pushProviderName","android","incomingCallChannel","callkeep","getCallKeepLib","cid","then","endCall","uuid","nativeDialerAcceptedCallMap","voipCallkeepAcceptedCallOnNativeDialerMap$","foregroundIncomingCallkeepMap","voipCallkeepCallOnForegroundMap$","foregroundCallkeepMap","answerIncomingCall","exports"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosCallkeepWithCallingStateEffect.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAMA,MAAMO,uBAAuB,GAAIC,YAA0B,IAAK;EAC9D,OACEA,YAAY,KAAKC,yBAAY,CAACC,IAAI,IAClCF,YAAY,KAAKC,yBAAY,CAACE,OAAO,IACrCH,YAAY,KAAKC,yBAAY,CAACG,IAAI;AAEtC,CAAC;AAED,MAAMC,sBAAsB,GAAIL,YAA0B,IAAK;EAC7D,OACEA,YAAY,KAAKC,yBAAY,CAACK,OAAO,IACrCN,YAAY,KAAKC,yBAAY,CAACM,MAAM;AAExC,CAAC;AAED,MAAMC,yBAAyB,GAAG,MAAOC,aAAiC,IAAK;EAC7E,MAAMC,2BAA2B,GAAGC,oBAAO,CAACC,eAAe,CACzDC,wCACF,CAAC;EACD,IAAIJ,aAAa,IAAIA,aAAa,KAAKC,2BAA2B,EAAE;IAClE;IACAG,wCAA4B,CAACC,IAAI,CAACC,SAAS,CAAC;EAC9C;E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lB,gCAAgC,CAAChB,SAAS,CAAC;MAC3C;IACF;IACA;IACA;IACA,MAAMqC,6BAA6B,GAAGzC,oBAAO,CAACC,eAAe,CAC3DyC,4CACF,CAAC;IACD,IAAI5C,aAAa,KAAK2C,6BAA6B,EAAEN,GAAG,EAAE;MACxDxB,GAAG;MACD;MACA,4BAA4Bb,aAAa,kCAAkCR,yBAAY,CAACD,YAAY,CAAC,wDACvG,CAAC;MACDQ,yBAAyB,CAACC,aAAa,CAAC,CAACsC,IAAI,CAAC,MAC5CH,QAAQ,CAACI,OAAO,CAACI,6BAA6B,CAACH,IAAI,CACrD,CAAC;MACD;MACAI,4CAAgC,CAACvC,IAAI,CAACC,SAAS,CAAC;MAChD;IACF;IACA;IACA;IACA;IACA,MAAMmC,2BAA2B,GAAGvC,oBAAO,CAACC,eAAe,CACzDuC,sDACF,CAAC;IACD,IAAI1C,aAAa,KAAKyC,2BAA2B,EAAEJ,GAAG,EAAE;MACtDxB,GAAG;MACD;MACA,4BAA4Bb,aAAa,kCAAkCR,yBAAY,CAACD,YAAY,CAAC,sDACvG,CAAC;MACDQ,yBAAyB,CAACC,aAAa,CAAC,CAACsC,IAAI,CAAC,MAC5CH,QAAQ,CAACI,OAAO,CAACE,2BAA2B,CAACD,IAAI,CACnD,CAAC;MACD;MACAE,sDAA0C,CAACrC,IAAI,CAACC,SAAS,CAAC;MAC1D;IACF;EACF;AACF,CAAC;AAACyC,OAAA,CAAA/B,oCAAA,GAAAA,oCAAA","ignoreList":[]}
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useProcessPushCallEffect = void 0;
7
- var _rxSubjects = require("../../utils/push/internal/rxSubjects");
8
- var _react = require("react");
9
- var _utils = require("../../utils");
10
- var _videoReactBindings = require("@stream-io/video-react-bindings");
11
- var _operators = require("rxjs/operators");
12
- var _utils2 = require("../../utils/push/internal/utils");
13
- var _videoClient = require("@stream-io/video-client");
14
- /**
15
- * This hook is used to process the incoming call data via push notifications using the relevant rxjs subjects
16
- * It either joins or leaves the call based on the user's action.
17
- * 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.
18
- * So we essentially run this effect only when the client is connected with a websocket.
19
- */
20
- const useProcessPushCallEffect = () => {
21
- const client = (0, _videoReactBindings.useStreamVideoClient)();
22
- const connectedUserId = (0, _videoReactBindings.useConnectedUser)()?.id;
23
- // The Effect to join/reject call automatically when incoming call was received and processed from push notification
24
- (0, _react.useEffect)(() => {
25
- const pushConfig = _utils.StreamVideoRN.getConfig().push;
26
- if (!pushConfig || !client || !connectedUserId) {
27
- return;
28
- }
29
- _videoClient.videoLoggerSystem.getLogger('useProcessPushCallEffect').debug(`Adding subscriptions to process incoming call from push notification`);
30
-
31
- // if the user accepts the call from push notification we join the call
32
- const acceptedCallSubscription = createCallSubscription(_rxSubjects.pushAcceptedIncomingCallCId$, client, pushConfig, 'accept');
33
-
34
- // if the user rejects the call from push notification we leave the call
35
- const declinedCallSubscription = createCallSubscription(_rxSubjects.pushRejectedIncomingCallCId$, client, pushConfig, 'decline');
36
-
37
- // 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
38
- const pressedCallSubscription = createCallSubscription(_rxSubjects.pushTappedIncomingCallCId$, client, pushConfig, 'pressed');
39
- const backgroundIncomingDeliveredCallSubscription = createCallSubscription(_rxSubjects.pushAndroidBackgroundDeliveredIncomingCallCId$, client, pushConfig, 'backgroundDelivered');
40
- return () => {
41
- acceptedCallSubscription.unsubscribe();
42
- declinedCallSubscription.unsubscribe();
43
- pressedCallSubscription.unsubscribe();
44
- backgroundIncomingDeliveredCallSubscription.unsubscribe();
45
- };
46
- }, [client, connectedUserId]);
47
- };
48
-
49
- /**
50
- * A type guard to check if the cid is not undefined
51
- */
52
- exports.useProcessPushCallEffect = useProcessPushCallEffect;
53
- function cidIsNotUndefined(cid) {
54
- return cid !== undefined;
55
- }
56
-
57
- /**
58
- * The common logic to create a subscription for the given call cid and action
59
- */
60
- const createCallSubscription = (behaviourSubjectWithCallCid, client, pushConfig, action) => {
61
- return behaviourSubjectWithCallCid.pipe((0, _operators.distinctUntilChanged)(), (0, _operators.filter)(cidIsNotUndefined)).subscribe(async callCId => {
62
- _videoClient.videoLoggerSystem.getLogger('useProcessPushCallEffect').debug(`Processing call from push notification with action: ${action} and callCId: ${callCId}`);
63
- await (0, _utils2.processCallFromPush)(client, callCId, action, pushConfig);
64
- behaviourSubjectWithCallCid.next(undefined); // remove the current call id to avoid processing again
65
- });
66
- };
67
- //# sourceMappingURL=useProcessPushCallEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_rxSubjects","require","_react","_utils","_videoReactBindings","_operators","_utils2","_videoClient","useProcessPushCallEffect","client","useStreamVideoClient","connectedUserId","useConnectedUser","id","useEffect","pushConfig","StreamVideoRN","getConfig","push","videoLoggerSystem","getLogger","debug","acceptedCallSubscription","createCallSubscription","pushAcceptedIncomingCallCId$","declinedCallSubscription","pushRejectedIncomingCallCId$","pressedCallSubscription","pushTappedIncomingCallCId$","backgroundIncomingDeliveredCallSubscription","pushAndroidBackgroundDeliveredIncomingCallCId$","unsubscribe","exports","cidIsNotUndefined","cid","undefined","behaviourSubjectWithCallCid","action","pipe","distinctUntilChanged","filter","subscribe","callCId","processCallFromPush","next"],"sourceRoot":"../../../../src","sources":["hooks/push/useProcessPushCallEffect.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAKA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMO,wBAAwB,GAAGA,CAAA,KAAM;EAC5C,MAAMC,MAAM,GAAG,IAAAC,wCAAoB,EAAC,CAAC;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DsB,MAAgE,KAC7D;EACH,OAAOD,2BAA2B,CAC/BE,IAAI,CAAC,IAAAC,+BAAoB,EAAC,CAAC,EAAE,IAAAC,iBAAM,EAACP,iBAAiB,CAAC,CAAC,CACvDQ,SAAS,CAAC,MAAOC,OAAO,IAAK;IAC5BvB,8BAAiB,CACdC,SAAS,CAAC,0BAA0B,CAAC,CACrCC,KAAK,CACJ,uDAAuDgB,MAAM,iBAAiBK,OAAO,EACvF,CAAC;IACH,MAAM,IAAAC,2BAAmB,EAAClC,MAAM,EAAEiC,OAAO,EAAEL,MAAM,EAAEtB,UAAU,CAAC;IAC9DqB,2BAA2B,CAACQ,IAAI,CAACT,SAAS,CAAC,CAAC,CAAC;EAC/C,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getCallKeepLib = getCallKeepLib;
7
- let callkeep;
8
- try {
9
- callkeep = require('react-native-callkeep').default;
10
- } catch {}
11
- function getCallKeepLib() {
12
- if (!callkeep) {
13
- throw Error('react-native-callkeep library is not installed. Please see https://github.com/react-native-webrtc/react-native-callkeep#Installation for installation instructions');
14
- }
15
- return callkeep;
16
- }
17
- //# sourceMappingURL=callkeep.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["callkeep","require","default","getCallKeepLib","Error"],"sourceRoot":"../../../../../src","sources":["utils/push/libs/callkeep.ts"],"mappings":";;;;;;AAEA,IAAIA,QAAoC;AAExC,IAAI;EACFA,QAAQ,GAAGC,OAAO,CAAC,uBAAuB,CAAC,CAACC,OAAO;AACrD,CAAC,CAAC,MAAM,CAAC;AAEF,SAASC,cAAcA,CAAA,EAAG;EAC/B,IAAI,CAACH,QAAQ,EAAE;IACb,MAAMI,KAAK,CACT,oKACF,CAAC;EACH;EACA,OAAOJ,QAAQ;AACjB","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getVoipPushNotificationLib = getVoipPushNotificationLib;
7
- let voipPushNotification;
8
- try {
9
- voipPushNotification = require('react-native-voip-push-notification').default;
10
- } catch {}
11
- function getVoipPushNotificationLib() {
12
- if (!voipPushNotification) {
13
- throw Error("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
- return voipPushNotification;
16
- }
17
- //# sourceMappingURL=voipPushNotification.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["voipPushNotification","require","default","getVoipPushNotificationLib","Error"],"sourceRoot":"../../../../../src","sources":["utils/push/libs/voipPushNotification.ts"],"mappings":";;;;;;AAGA,IAAIA,oBAA0D;AAE9D,IAAI;EACFA,oBAAoB,GAAGC,OAAO,CAAC,qCAAqC,CAAC,CAACC,OAAO;AAC/E,CAAC,CAAC,MAAM,CAAC;AAEF,SAASC,0BAA0BA,CAAA,EAAG;EAC3C,IAAI,CAACH,oBAAoB,EAAE;IACzB,MAAMI,KAAK,CACT,4LACF,CAAC;EACH;EACA,OAAOJ,oBAAoB;AAC7B","ignoreList":[]}