@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.
- package/android/src/main/AndroidManifest.xml +8 -1
- package/android/src/main/AndroidManifestNew.xml +11 -0
- package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +42 -5
- package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +70 -6
- package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +6 -4
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +83 -0
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +149 -0
- package/dist/commonjs/hooks/push/index.js +0 -2
- package/dist/commonjs/hooks/push/index.js.map +1 -1
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +121 -0
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +64 -97
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/modules/call-manager/CallManager.js +26 -0
- package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
- package/dist/commonjs/providers/StreamCall/index.js +6 -6
- package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +33 -21
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +68 -0
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +1 -0
- package/dist/commonjs/utils/internal/callingx/callingx.js +123 -0
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -0
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +52 -3
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +48 -0
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +1 -0
- package/dist/commonjs/utils/push/android.js +135 -202
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/ios.js +17 -34
- package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js +1 -45
- package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/commonjs/utils/push/internal/utils.js +67 -52
- package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
- package/dist/commonjs/utils/push/ios.js.map +1 -1
- package/dist/commonjs/utils/push/libs/callingx.js +78 -0
- package/dist/commonjs/utils/push/libs/callingx.js.map +1 -0
- package/dist/commonjs/utils/push/libs/index.js +8 -19
- package/dist/commonjs/utils/push/libs/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/notifee/index.js +0 -19
- package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/commonjs/utils/push/setupCallingExpEvents.js +105 -0
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +7 -6
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/commonjs/version.js.map +1 -1
- package/dist/module/hooks/push/index.js +0 -2
- package/dist/module/hooks/push/index.js.map +1 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +114 -0
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +66 -99
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/modules/call-manager/CallManager.js +26 -0
- package/dist/module/modules/call-manager/CallManager.js.map +1 -1
- package/dist/module/providers/StreamCall/index.js +6 -6
- package/dist/module/providers/StreamCall/index.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +33 -21
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/callingx/audioSessionPromise.js +61 -0
- package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +1 -0
- package/dist/module/utils/internal/callingx/callingx.js +114 -0
- package/dist/module/utils/internal/callingx/callingx.js.map +1 -0
- package/dist/module/utils/internal/registerSDKGlobals.js +52 -3
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/keepCallAliveHeadlessTask.js +42 -0
- package/dist/module/utils/keepCallAliveHeadlessTask.js.map +1 -0
- package/dist/module/utils/push/android.js +137 -204
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/ios.js +17 -34
- package/dist/module/utils/push/internal/ios.js.map +1 -1
- package/dist/module/utils/push/internal/rxSubjects.js +0 -44
- package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/module/utils/push/internal/utils.js +63 -49
- package/dist/module/utils/push/internal/utils.js.map +1 -1
- package/dist/module/utils/push/ios.js.map +1 -1
- package/dist/module/utils/push/libs/callingx.js +70 -0
- package/dist/module/utils/push/libs/callingx.js.map +1 -0
- package/dist/module/utils/push/libs/index.js +1 -2
- package/dist/module/utils/push/libs/index.js.map +1 -1
- package/dist/module/utils/push/libs/notifee/index.js +0 -18
- package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/module/utils/push/setupCallingExpEvents.js +99 -0
- package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -0
- package/dist/module/utils/push/setupIosVoipPushEvents.js +7 -6
- package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/version.js.map +1 -1
- package/dist/typescript/hooks/push/index.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +5 -0
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -0
- package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +1 -0
- package/dist/typescript/index.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/CallManager.d.ts +5 -0
- package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +20 -2
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +63 -25
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +16 -0
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +1 -0
- package/dist/typescript/utils/internal/callingx/callingx.d.ts +17 -0
- package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +1 -0
- package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +10 -0
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +1 -0
- package/dist/typescript/utils/push/android.d.ts +1 -2
- package/dist/typescript/utils/push/android.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts +0 -33
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/utils.d.ts +14 -8
- package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
- package/dist/typescript/utils/push/ios.d.ts +1 -2
- package/dist/typescript/utils/push/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/callingx.d.ts +9 -0
- package/dist/typescript/utils/push/libs/callingx.d.ts.map +1 -0
- package/dist/typescript/utils/push/libs/index.d.ts +1 -2
- package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/notifee/index.d.ts +0 -1
- package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +8 -0
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/dist/typescript/version.d.ts.map +1 -1
- package/expo-config-plugin/dist/withAndroidManifest.js +1 -33
- package/expo-config-plugin/dist/withAndroidPermissions.js +2 -7
- package/expo-config-plugin/dist/withAppDelegate.js +19 -197
- package/expo-config-plugin/dist/withMainActivity.js +1 -1
- package/expo-config-plugin/dist/withiOSInfoPlist.js +2 -3
- package/ios/StreamInCallManager.m +2 -0
- package/ios/StreamInCallManager.swift +19 -7
- package/ios/StreamVideoReactNative.h +7 -4
- package/ios/StreamVideoReactNative.m +189 -82
- package/package.json +13 -18
- package/src/hooks/push/index.ts +0 -2
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +147 -0
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +94 -120
- package/src/index.ts +1 -0
- package/src/modules/call-manager/CallManager.ts +36 -0
- package/src/modules/call-manager/native-module.d.ts +7 -0
- package/src/providers/StreamCall/index.tsx +6 -6
- package/src/utils/StreamVideoRN/index.ts +40 -30
- package/src/utils/StreamVideoRN/types.ts +65 -25
- package/src/utils/internal/callingx/audioSessionPromise.ts +65 -0
- package/src/utils/internal/callingx/callingx.ts +165 -0
- package/src/utils/internal/registerSDKGlobals.ts +47 -4
- package/src/utils/keepCallAliveHeadlessTask.ts +54 -0
- package/src/utils/push/android.ts +196 -311
- package/src/utils/push/internal/ios.ts +28 -44
- package/src/utils/push/internal/rxSubjects.ts +0 -61
- package/src/utils/push/internal/utils.ts +104 -63
- package/src/utils/push/ios.ts +1 -6
- package/src/utils/push/libs/callingx.ts +93 -0
- package/src/utils/push/libs/index.ts +1 -2
- package/src/utils/push/libs/notifee/index.ts +0 -27
- package/src/utils/push/setupCallingExpEvents.ts +135 -0
- package/src/utils/push/setupIosVoipPushEvents.ts +11 -7
- package/src/version.ts +1 -1
- package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +0 -95
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -160
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +0 -67
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +0 -1
- package/dist/commonjs/utils/push/libs/callkeep.js +0 -17
- package/dist/commonjs/utils/push/libs/callkeep.js.map +0 -1
- package/dist/commonjs/utils/push/libs/voipPushNotification.js +0 -17
- package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +0 -1
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +0 -205
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +0 -1
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -153
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
- package/dist/module/hooks/push/useProcessPushCallEffect.js +0 -60
- package/dist/module/hooks/push/useProcessPushCallEffect.js.map +0 -1
- package/dist/module/utils/push/libs/callkeep.js +0 -11
- package/dist/module/utils/push/libs/callkeep.js.map +0 -1
- package/dist/module/utils/push/libs/voipPushNotification.js +0 -11
- package/dist/module/utils/push/libs/voipPushNotification.js.map +0 -1
- package/dist/module/utils/push/setupIosCallKeepEvents.js +0 -199
- package/dist/module/utils/push/setupIosCallKeepEvents.js.map +0 -1
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +0 -5
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +0 -1
- package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts +0 -8
- package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts.map +0 -1
- package/dist/typescript/utils/push/libs/callkeep.d.ts +0 -3
- package/dist/typescript/utils/push/libs/callkeep.d.ts.map +0 -1
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +0 -3
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +0 -1
- package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +0 -6
- package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +0 -1
- package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +0 -235
- package/src/hooks/push/useProcessPushCallEffect.ts +0 -108
- package/src/utils/push/libs/callkeep.ts +0 -16
- package/src/utils/push/libs/voipPushNotification.ts +0 -17
- package/src/utils/push/setupIosCallKeepEvents.ts +0 -252
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
pushAcceptedIncomingCallCId$,
|
|
3
|
-
voipCallkeepAcceptedCallOnNativeDialerMap$,
|
|
4
|
-
voipCallkeepCallOnForegroundMap$,
|
|
5
|
-
voipPushNotificationCallCId$,
|
|
6
|
-
} from './internal/rxSubjects';
|
|
7
|
-
import { RxUtils, videoLoggerSystem } from '@stream-io/video-client';
|
|
8
|
-
import { getCallKeepLib, getVoipPushNotificationLib } from './libs';
|
|
9
|
-
import type { StreamVideoConfig } from '../StreamVideoRN/types';
|
|
10
|
-
import {
|
|
11
|
-
clearPushWSEventSubscriptions,
|
|
12
|
-
processCallFromPushInBackground,
|
|
13
|
-
} from './internal/utils';
|
|
14
|
-
import { AppState, NativeModules, Platform } from 'react-native';
|
|
15
|
-
import { RTCAudioSession } from '@stream-io/react-native-webrtc';
|
|
16
|
-
import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
|
|
17
|
-
|
|
18
|
-
type PushConfig = NonNullable<StreamVideoConfig['push']>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* This hook is used to listen to callkeep events and do the necessary actions
|
|
22
|
-
*/
|
|
23
|
-
export function setupIosCallKeepEvents(
|
|
24
|
-
pushConfig: NonNullable<StreamVideoConfig['push']>,
|
|
25
|
-
) {
|
|
26
|
-
if (Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (!pushConfig.android.incomingCallChannel) {
|
|
30
|
-
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
31
|
-
videoLoggerSystem
|
|
32
|
-
.getLogger('setupIosCallKeepEvents')
|
|
33
|
-
.debug(
|
|
34
|
-
'android incomingCallChannel is not defined, so skipping the setupIosCallKeepEvents',
|
|
35
|
-
);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const logger = videoLoggerSystem.getLogger('setupIosCallKeepEvents');
|
|
39
|
-
const callkeep = getCallKeepLib();
|
|
40
|
-
|
|
41
|
-
async function getCallCid(callUUID: string): Promise<string | undefined> {
|
|
42
|
-
try {
|
|
43
|
-
const call_cid =
|
|
44
|
-
await NativeModules.StreamVideoReactNative.getIncomingCallCid(callUUID);
|
|
45
|
-
// in a case that voipPushNotificationCallCId$ is empty (this should not happen as voipPushNotificationCallCId$ is updated in push reception)]
|
|
46
|
-
// update it with this call_cid
|
|
47
|
-
const voipPushNotificationCallCId = RxUtils.getCurrentValue(
|
|
48
|
-
voipPushNotificationCallCId$,
|
|
49
|
-
);
|
|
50
|
-
if (!voipPushNotificationCallCId) {
|
|
51
|
-
logger.debug(
|
|
52
|
-
`voipPushNotificationCallCId$ is empty, updating it with the call_cid: ${call_cid} for callUUID: ${callUUID}`,
|
|
53
|
-
);
|
|
54
|
-
voipPushNotificationCallCId$.next(call_cid);
|
|
55
|
-
}
|
|
56
|
-
return call_cid;
|
|
57
|
-
} catch {
|
|
58
|
-
logger.debug(
|
|
59
|
-
`Error in getting call cid from native module for callUUID: ${callUUID} - probably the call was already processed, so ignoring this callkeep event`,
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function answerCall(callUUID: string) {
|
|
66
|
-
getCallCid(callUUID).then((call_cid) => {
|
|
67
|
-
logger.debug(`answerCall event with call_cid: ${call_cid}`);
|
|
68
|
-
iosCallkeepAcceptCall(call_cid, callUUID);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function endCall(callUUID: string) {
|
|
73
|
-
getCallCid(callUUID).then((call_cid) => {
|
|
74
|
-
logger.debug(`endCall event with call_cid: ${call_cid}`);
|
|
75
|
-
iosCallkeepRejectCall(call_cid, callUUID, pushConfig!);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* CallKeep / CallKit audio-session events -> WebRTC (iOS)
|
|
81
|
-
*
|
|
82
|
-
* iOS CallKit is the authority that *activates* and *deactivates* the underlying `AVAudioSession`
|
|
83
|
-
* when a call is answered/ended from the system UI (lock screen, Call UI, Bluetooth, etc).
|
|
84
|
-
*
|
|
85
|
-
* WebRTC on iOS wraps `AVAudioSession` with `RTCAudioSession` and its AudioDeviceModule relies on
|
|
86
|
-
* being notified of those lifecycle transitions to correctly start/stop audio I/O and keep its
|
|
87
|
-
* internal activation state consistent (e.g. activation count, playout/recording start).
|
|
88
|
-
*
|
|
89
|
-
* If these callbacks don’t reach WebRTC, answering via the native dialer UI can result in:
|
|
90
|
-
* - no microphone capture / one-way audio
|
|
91
|
-
* - silent playout until the app forces an audio reconfiguration
|
|
92
|
-
* - flaky audio routing (speaker/earpiece/Bluetooth) across subsequent calls
|
|
93
|
-
*
|
|
94
|
-
* We forward CallKeep’s `didActivateAudioSession` / `didDeactivateAudioSession` events to WebRTC’s
|
|
95
|
-
* `RTCAudioSession.audioSessionDidActivate()` / `audioSessionDidDeactivate()` methods.
|
|
96
|
-
*/
|
|
97
|
-
function didActivateAudioSession() {
|
|
98
|
-
logger.debug('didActivateAudioSession');
|
|
99
|
-
RTCAudioSession.audioSessionDidActivate();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function didDeactivateAudioSession() {
|
|
103
|
-
logger.debug('didDeactivateAudioSession');
|
|
104
|
-
RTCAudioSession.audioSessionDidDeactivate();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function didDisplayIncomingCall(callUUID: string, payload: object) {
|
|
108
|
-
const voipPushNotification = getVoipPushNotificationLib();
|
|
109
|
-
// @ts-expect-error - call_cid is not part of RNCallKeepEventPayload
|
|
110
|
-
const call_cid = payload?.call_cid as string | undefined;
|
|
111
|
-
logger.debug(
|
|
112
|
-
`didDisplayIncomingCall event with callUUID: ${callUUID} call_cid: ${call_cid}`,
|
|
113
|
-
);
|
|
114
|
-
if (call_cid) {
|
|
115
|
-
if (AppState.currentState === 'background') {
|
|
116
|
-
processCallFromPushInBackground(
|
|
117
|
-
pushConfig!,
|
|
118
|
-
call_cid,
|
|
119
|
-
'backgroundDelivered',
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
voipCallkeepCallOnForegroundMap$.next({
|
|
123
|
-
uuid: callUUID,
|
|
124
|
-
cid: call_cid,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
voipPushNotification.onVoipNotificationCompleted(callUUID);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const { remove: removeAnswerCall } = callkeep.addEventListener(
|
|
131
|
-
'answerCall',
|
|
132
|
-
({ callUUID }) => {
|
|
133
|
-
answerCall(callUUID);
|
|
134
|
-
},
|
|
135
|
-
);
|
|
136
|
-
const { remove: removeEndCall } = callkeep.addEventListener(
|
|
137
|
-
'endCall',
|
|
138
|
-
({ callUUID }) => {
|
|
139
|
-
endCall(callUUID);
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
const { remove: removeDisplayIncomingCall } = callkeep.addEventListener(
|
|
144
|
-
'didDisplayIncomingCall',
|
|
145
|
-
({ callUUID, payload }) => {
|
|
146
|
-
didDisplayIncomingCall(callUUID, payload);
|
|
147
|
-
},
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const { remove: removeDidActivateAudioSession } = callkeep.addEventListener(
|
|
151
|
-
'didActivateAudioSession',
|
|
152
|
-
() => {
|
|
153
|
-
didActivateAudioSession();
|
|
154
|
-
},
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
const { remove: removeDidDeactivateAudioSession } = callkeep.addEventListener(
|
|
158
|
-
'didDeactivateAudioSession',
|
|
159
|
-
() => {
|
|
160
|
-
didDeactivateAudioSession();
|
|
161
|
-
},
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
const { remove: removeDidLoadWithEvents } = callkeep.addEventListener(
|
|
165
|
-
'didLoadWithEvents',
|
|
166
|
-
(events) => {
|
|
167
|
-
if (!events || !Array.isArray(events) || events.length < 1) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
events.forEach((event) => {
|
|
172
|
-
const { name, data } = event;
|
|
173
|
-
if (name === 'RNCallKeepDidDisplayIncomingCall') {
|
|
174
|
-
didDisplayIncomingCall(data.callUUID, data.payload);
|
|
175
|
-
} else if (name === 'RNCallKeepPerformAnswerCallAction') {
|
|
176
|
-
answerCall(data.callUUID);
|
|
177
|
-
} else if (name === 'RNCallKeepPerformEndCallAction') {
|
|
178
|
-
endCall(data.callUUID);
|
|
179
|
-
} else if (name === 'RNCallKeepDidActivateAudioSession') {
|
|
180
|
-
didActivateAudioSession();
|
|
181
|
-
} else if (name === 'RNCallKeepDidDeactivateAudioSession') {
|
|
182
|
-
didDeactivateAudioSession();
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
},
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
setPushLogoutCallback(async () => {
|
|
189
|
-
removeAnswerCall();
|
|
190
|
-
removeEndCall();
|
|
191
|
-
removeDisplayIncomingCall();
|
|
192
|
-
removeDidActivateAudioSession();
|
|
193
|
-
removeDidDeactivateAudioSession();
|
|
194
|
-
removeDidLoadWithEvents();
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const iosCallkeepAcceptCall = (
|
|
199
|
-
call_cid: string | undefined,
|
|
200
|
-
callUUIDFromCallkeep: string,
|
|
201
|
-
) => {
|
|
202
|
-
if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
clearPushWSEventSubscriptions(call_cid);
|
|
206
|
-
// to call end callkeep later if ended in app and not through callkeep
|
|
207
|
-
voipCallkeepAcceptedCallOnNativeDialerMap$.next({
|
|
208
|
-
uuid: callUUIDFromCallkeep,
|
|
209
|
-
cid: call_cid,
|
|
210
|
-
});
|
|
211
|
-
// to process the call in the app
|
|
212
|
-
pushAcceptedIncomingCallCId$.next(call_cid);
|
|
213
|
-
// no need to keep these references anymore
|
|
214
|
-
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const iosCallkeepRejectCall = async (
|
|
218
|
-
call_cid: string | undefined,
|
|
219
|
-
callUUIDFromCallkeep: string,
|
|
220
|
-
pushConfig: PushConfig,
|
|
221
|
-
) => {
|
|
222
|
-
if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
clearPushWSEventSubscriptions(call_cid);
|
|
226
|
-
// remove the references if the call_cid matches
|
|
227
|
-
const voipPushNotificationCallCId = RxUtils.getCurrentValue(
|
|
228
|
-
voipPushNotificationCallCId$,
|
|
229
|
-
);
|
|
230
|
-
if (voipPushNotificationCallCId === call_cid) {
|
|
231
|
-
voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
232
|
-
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
233
|
-
voipPushNotificationCallCId$.next(undefined);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
|
|
237
|
-
await NativeModules.StreamVideoReactNative?.removeIncomingCall(call_cid);
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Helper function to determine if the answer/end call event from callkeep must be processed
|
|
242
|
-
* Just checks if we have a valid call_cid and acts as a type guard for call_cid
|
|
243
|
-
*/
|
|
244
|
-
const shouldProcessCallFromCallkeep = (
|
|
245
|
-
call_cid: string | undefined,
|
|
246
|
-
callUUIDFromCallkeep: string,
|
|
247
|
-
): call_cid is string => {
|
|
248
|
-
if (!call_cid || !callUUIDFromCallkeep) {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
return true;
|
|
252
|
-
};
|