@stream-io/video-react-native-sdk 1.29.0-beta.1 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3114 -0
- package/android/src/main/AndroidManifest.xml +1 -8
- package/android/src/main/AndroidManifestNew.xml +0 -11
- package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +5 -42
- package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +6 -70
- package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +4 -6
- package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +95 -0
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +97 -64
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/index.js +0 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/modules/call-manager/CallManager.js +0 -26
- 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 +21 -33
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +3 -52
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +200 -145
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/ios.js +34 -16
- package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js +20 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/commonjs/utils/push/internal/utils.js +1 -17
- 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/callkeep.js +17 -0
- package/dist/commonjs/utils/push/libs/callkeep.js.map +1 -0
- package/dist/commonjs/utils/push/libs/index.js +19 -8
- package/dist/commonjs/utils/push/libs/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/notifee/index.js +19 -0
- package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/voipPushNotification.js +17 -0
- package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +205 -0
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
- 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/useIosCallkeepWithCallingStateEffect.js +153 -0
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +99 -66
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/index.js +0 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/modules/call-manager/CallManager.js +0 -26
- 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 +21 -33
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/registerSDKGlobals.js +4 -53
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/push/android.js +202 -147
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/ios.js +34 -16
- package/dist/module/utils/push/internal/ios.js.map +1 -1
- package/dist/module/utils/push/internal/rxSubjects.js +19 -0
- package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/module/utils/push/internal/utils.js +0 -14
- 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/callkeep.js +11 -0
- package/dist/module/utils/push/libs/callkeep.js.map +1 -0
- package/dist/module/utils/push/libs/index.js +2 -1
- package/dist/module/utils/push/libs/index.js.map +1 -1
- package/dist/module/utils/push/libs/notifee/index.js +18 -0
- package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/module/utils/push/libs/voipPushNotification.js +11 -0
- package/dist/module/utils/push/libs/voipPushNotification.js.map +1 -0
- package/dist/module/utils/push/setupIosCallKeepEvents.js +199 -0
- package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
- 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/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.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 +0 -1
- package/dist/typescript/index.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
- package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -20
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +29 -54
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
- package/dist/typescript/utils/push/android.d.ts +2 -1
- 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 +12 -0
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/utils.d.ts +0 -4
- package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
- package/dist/typescript/utils/push/ios.d.ts +2 -1
- package/dist/typescript/utils/push/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
- package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +2 -16
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/index.d.ts +2 -1
- package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
- package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
- package/dist/typescript/utils/push/setupIosCallKeepEvents.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 +33 -1
- package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
- package/expo-config-plugin/dist/withAppDelegate.js +197 -19
- package/expo-config-plugin/dist/withMainActivity.js +1 -1
- package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
- package/ios/StreamInCallManager.m +0 -2
- package/ios/StreamInCallManager.swift +5 -20
- package/ios/StreamVideoReactNative.h +4 -7
- package/ios/StreamVideoReactNative.m +82 -191
- package/package.json +17 -12
- package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
- package/src/index.ts +0 -1
- package/src/modules/call-manager/CallManager.ts +0 -36
- package/src/modules/call-manager/native-module.d.ts +0 -7
- package/src/providers/StreamCall/index.tsx +6 -6
- package/src/utils/StreamVideoRN/index.ts +30 -40
- package/src/utils/StreamVideoRN/types.ts +29 -56
- package/src/utils/internal/registerSDKGlobals.ts +4 -47
- package/src/utils/push/android.ts +308 -223
- package/src/utils/push/internal/ios.ts +46 -25
- package/src/utils/push/internal/rxSubjects.ts +29 -0
- package/src/utils/push/internal/utils.ts +0 -25
- package/src/utils/push/ios.ts +6 -1
- package/src/utils/push/libs/callkeep.ts +16 -0
- package/src/utils/push/libs/index.ts +2 -1
- package/src/utils/push/libs/notifee/index.ts +27 -0
- package/src/utils/push/libs/voipPushNotification.ts +17 -0
- package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
- package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
- package/src/version.ts +1 -1
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -134
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -216
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/commonjs/utils/internal/audioSessionPromise.js +0 -46
- package/dist/commonjs/utils/internal/audioSessionPromise.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx.js +0 -84
- package/dist/commonjs/utils/internal/callingx.js.map +0 -1
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
- package/dist/commonjs/utils/push/libs/callingx.js +0 -75
- package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
- package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -97
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -209
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/module/utils/internal/audioSessionPromise.js +0 -39
- package/dist/module/utils/internal/audioSessionPromise.js.map +0 -1
- package/dist/module/utils/internal/callingx.js +0 -75
- package/dist/module/utils/internal/callingx.js.map +0 -1
- package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
- package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
- package/dist/module/utils/push/libs/callingx.js +0 -67
- package/dist/module/utils/push/libs/callingx.js.map +0 -1
- package/dist/module/utils/push/setupCallingExpEvents.js +0 -91
- package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
- package/dist/typescript/utils/internal/audioSessionPromise.d.ts +0 -16
- package/dist/typescript/utils/internal/audioSessionPromise.d.ts.map +0 -1
- package/dist/typescript/utils/internal/callingx.d.ts +0 -13
- package/dist/typescript/utils/internal/callingx.d.ts.map +0 -1
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
- package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
- package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -307
- package/src/utils/internal/audioSessionPromise.ts +0 -39
- package/src/utils/internal/callingx.ts +0 -108
- package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
- package/src/utils/push/libs/callingx.ts +0 -90
- package/src/utils/push/setupCallingExpEvents.ts +0 -117
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { AppRegistry, Platform } from 'react-native';
|
|
2
|
-
import type { Call } from '@stream-io/video-client';
|
|
3
|
-
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
4
|
-
import { StreamVideoRN } from './StreamVideoRN';
|
|
5
|
-
|
|
6
|
-
export const KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = 'StreamVideoKeepCallAlive';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The keep-alive headless task needs access to the active `Call` instance.
|
|
10
|
-
* The keep-alive hook will set this reference before starting the native service.
|
|
11
|
-
*/
|
|
12
|
-
export const keepCallAliveCallRef: { current: Call | undefined } = {
|
|
13
|
-
current: undefined,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function registerKeepCallAliveHeadlessTaskOnce() {
|
|
17
|
-
if (Platform.OS !== 'android') return;
|
|
18
|
-
|
|
19
|
-
AppRegistry.registerHeadlessTask(
|
|
20
|
-
KEEP_CALL_ALIVE_HEADLESS_TASK_NAME,
|
|
21
|
-
() => async (data: { callCid?: string } | undefined) => {
|
|
22
|
-
const logger = videoLoggerSystem.getLogger(
|
|
23
|
-
'KEEP_CALL_ALIVE_HEADLESS_TASK',
|
|
24
|
-
);
|
|
25
|
-
const callCid = data?.callCid;
|
|
26
|
-
|
|
27
|
-
const call = keepCallAliveCallRef.current;
|
|
28
|
-
if (!call) {
|
|
29
|
-
logger.warn(
|
|
30
|
-
'No active call instance available for keep-alive task; skipping.',
|
|
31
|
-
{ callCid },
|
|
32
|
-
);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (callCid && call.cid && call.cid !== callCid) {
|
|
36
|
-
logger.warn(
|
|
37
|
-
'Keep-alive task callCid does not match active call; skipping.',
|
|
38
|
-
{ callCid, activeCallCid: call.cid },
|
|
39
|
-
);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const config = StreamVideoRN.getConfig();
|
|
44
|
-
const taskToRun = config.foregroundService.android.taskToRun;
|
|
45
|
-
try {
|
|
46
|
-
await taskToRun(call);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
logger.error('Keep-alive headless task failed', e);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
registerKeepCallAliveHeadlessTaskOnce();
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { StreamVideoConfig } from '../../StreamVideoRN/types';
|
|
2
|
-
|
|
3
|
-
export type RNCallingxType =
|
|
4
|
-
import('@stream-io/react-native-callingx').ICallingxModule;
|
|
5
|
-
export type EventData = import('@stream-io/react-native-callingx').EventData;
|
|
6
|
-
export type EventParams =
|
|
7
|
-
import('@stream-io/react-native-callingx').EventParams;
|
|
8
|
-
export type CallingExpOptions =
|
|
9
|
-
import('@stream-io/react-native-callingx').CallingExpOptions;
|
|
10
|
-
|
|
11
|
-
let callingx: RNCallingxType | undefined;
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
callingx = require('@stream-io/react-native-callingx').CallingxModule;
|
|
15
|
-
} catch {}
|
|
16
|
-
|
|
17
|
-
export function getCallingxLib() {
|
|
18
|
-
if (!callingx) {
|
|
19
|
-
throw Error('react-native-callingx library is not installed.');
|
|
20
|
-
}
|
|
21
|
-
return callingx;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function getCallingxLibIfAvailable() {
|
|
25
|
-
return callingx ?? undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function extractCallingExpOptions(
|
|
29
|
-
config: StreamVideoConfig,
|
|
30
|
-
): CallingExpOptions {
|
|
31
|
-
const { push: pushConfig, foregroundService: foregroundServiceConfig } =
|
|
32
|
-
config;
|
|
33
|
-
const callingExpOptions: CallingExpOptions = {};
|
|
34
|
-
|
|
35
|
-
if (pushConfig?.ios) {
|
|
36
|
-
const iosOptions: CallingExpOptions['ios'] = {};
|
|
37
|
-
if (pushConfig.ios.supportsVideo !== undefined) {
|
|
38
|
-
iosOptions.supportsVideo = pushConfig.ios.supportsVideo;
|
|
39
|
-
}
|
|
40
|
-
if (pushConfig.ios.sound !== undefined) {
|
|
41
|
-
iosOptions.sound = pushConfig.ios.sound;
|
|
42
|
-
}
|
|
43
|
-
if (pushConfig.ios.imageName !== undefined) {
|
|
44
|
-
iosOptions.imageName = pushConfig.ios.imageName;
|
|
45
|
-
}
|
|
46
|
-
if (pushConfig.ios.callsHistory !== undefined) {
|
|
47
|
-
iosOptions.callsHistory = pushConfig.ios.callsHistory;
|
|
48
|
-
}
|
|
49
|
-
if (pushConfig.ios.displayCallTimeout !== undefined) {
|
|
50
|
-
iosOptions.displayCallTimeout = pushConfig.ios.displayCallTimeout;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (Object.keys(iosOptions).length > 0) {
|
|
54
|
-
callingExpOptions.ios = iosOptions;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const androidOptions: CallingExpOptions['android'] = {};
|
|
59
|
-
if (pushConfig?.android) {
|
|
60
|
-
if (pushConfig.android.incomingChannel) {
|
|
61
|
-
androidOptions.incomingChannel = pushConfig.android.incomingChannel;
|
|
62
|
-
}
|
|
63
|
-
if (pushConfig.android.titleTransformer) {
|
|
64
|
-
androidOptions.titleTransformer = pushConfig.android.titleTransformer;
|
|
65
|
-
}
|
|
66
|
-
if (pushConfig.android.subtitleTransformer) {
|
|
67
|
-
androidOptions.subtitleTransformer =
|
|
68
|
-
pushConfig.android.subtitleTransformer;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (foregroundServiceConfig.android.channel) {
|
|
73
|
-
androidOptions.ongoingChannel = foregroundServiceConfig.android.channel;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (Object.keys(androidOptions).length > 0) {
|
|
77
|
-
callingExpOptions.android = androidOptions;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (pushConfig?.shouldRejectCallWhenBusy !== undefined) {
|
|
81
|
-
callingExpOptions.shouldRejectCallWhenBusy =
|
|
82
|
-
pushConfig.shouldRejectCallWhenBusy;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (pushConfig?.enableOngoingCalls !== undefined) {
|
|
86
|
-
callingExpOptions.enableOngoingCalls = pushConfig?.enableOngoingCalls;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return callingExpOptions;
|
|
90
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { pushAcceptedIncomingCallCId$ } from './internal/rxSubjects';
|
|
2
|
-
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
3
|
-
import type { StreamVideoConfig } from '../StreamVideoRN/types';
|
|
4
|
-
import {
|
|
5
|
-
clearPushWSEventSubscriptions,
|
|
6
|
-
processCallFromPushInBackground,
|
|
7
|
-
} from './internal/utils';
|
|
8
|
-
import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
|
|
9
|
-
import { resolvePendingAudioSession } from '../internal/audioSessionPromise';
|
|
10
|
-
import {
|
|
11
|
-
getCallingxLib,
|
|
12
|
-
type EventData,
|
|
13
|
-
type EventParams,
|
|
14
|
-
} from './libs/callingx';
|
|
15
|
-
import { Platform } from 'react-native';
|
|
16
|
-
|
|
17
|
-
type PushConfig = NonNullable<StreamVideoConfig['push']>;
|
|
18
|
-
|
|
19
|
-
const logger = videoLoggerSystem.getLogger('Callingx');
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* This hook is used to listen to callkeep events and do the necessary actions
|
|
23
|
-
*/
|
|
24
|
-
export function setupCallingExpEvents(pushConfig: NonNullable<PushConfig>) {
|
|
25
|
-
const hasPushProvider =
|
|
26
|
-
(Platform.OS === 'android' && pushConfig.android?.pushProviderName) ||
|
|
27
|
-
(Platform.OS === 'ios' && pushConfig.ios?.pushProviderName);
|
|
28
|
-
|
|
29
|
-
if (!hasPushProvider) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const callingx = getCallingxLib();
|
|
34
|
-
|
|
35
|
-
const { remove: removeAnswerCall } = callingx.addEventListener(
|
|
36
|
-
'answerCall',
|
|
37
|
-
onAcceptCall,
|
|
38
|
-
);
|
|
39
|
-
const { remove: removeEndCall } = callingx.addEventListener(
|
|
40
|
-
'endCall',
|
|
41
|
-
onEndCall(pushConfig),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const { remove: removeDidActivateAudioSession } = callingx.addEventListener(
|
|
45
|
-
'didActivateAudioSession',
|
|
46
|
-
onDidActivateAudioSession,
|
|
47
|
-
);
|
|
48
|
-
const { remove: removeDidDeactivateAudioSession } = callingx.addEventListener(
|
|
49
|
-
'didDeactivateAudioSession',
|
|
50
|
-
onDidDeactivateAudioSession,
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
//NOTE: until getInitialEvents invocation, events are delayed and won't be sent to event listeners, this is a way to make sure none of required events are missed
|
|
54
|
-
//in most cases there will be no delayed answers or ends, but it we don't want to miss any of them
|
|
55
|
-
const events = callingx.getInitialEvents();
|
|
56
|
-
events.forEach((event: EventData) => {
|
|
57
|
-
const { eventName, params } = event;
|
|
58
|
-
if (eventName === 'answerCall') {
|
|
59
|
-
logger.debug(`answerCall delayed event callId: ${params?.callId}`);
|
|
60
|
-
onAcceptCall(params as EventParams['answerCall']);
|
|
61
|
-
} else if (eventName === 'endCall') {
|
|
62
|
-
logger.debug(`endCall delayed event callId: ${params?.callId}`);
|
|
63
|
-
onEndCall(pushConfig)(params as EventParams['endCall']);
|
|
64
|
-
} else if (eventName === 'didActivateAudioSession') {
|
|
65
|
-
onDidActivateAudioSession();
|
|
66
|
-
} else if (eventName === 'didDeactivateAudioSession') {
|
|
67
|
-
onDidDeactivateAudioSession();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
setPushLogoutCallback(async () => {
|
|
72
|
-
removeAnswerCall();
|
|
73
|
-
removeEndCall();
|
|
74
|
-
removeDidActivateAudioSession();
|
|
75
|
-
removeDidDeactivateAudioSession();
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const onDidActivateAudioSession = () => {
|
|
80
|
-
logger.debug('callingExpDidActivateAudioSession');
|
|
81
|
-
resolvePendingAudioSession();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const onDidDeactivateAudioSession = () => {
|
|
85
|
-
logger.debug('callingExpDidDeactivateAudioSession');
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const onAcceptCall = ({
|
|
89
|
-
callId: call_cid,
|
|
90
|
-
source,
|
|
91
|
-
}: EventParams['answerCall']) => {
|
|
92
|
-
logger.debug(`onAcceptCall event callId: ${call_cid} source: ${source}`);
|
|
93
|
-
|
|
94
|
-
if (source === 'app' || !call_cid) {
|
|
95
|
-
//we only need to process the call if the call was answered from the system
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
clearPushWSEventSubscriptions(call_cid);
|
|
100
|
-
// to process the call in the app
|
|
101
|
-
pushAcceptedIncomingCallCId$.next(call_cid);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const onEndCall =
|
|
105
|
-
(pushConfig: PushConfig) =>
|
|
106
|
-
async ({ callId: call_cid, source }: EventParams['endCall']) => {
|
|
107
|
-
logger.debug(`onEndCall event callId: ${call_cid} source: ${source}`);
|
|
108
|
-
|
|
109
|
-
if (source === 'app' || !call_cid) {
|
|
110
|
-
//we only need to process the call if the call was rejected from the system
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
clearPushWSEventSubscriptions(call_cid);
|
|
115
|
-
|
|
116
|
-
await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
|
|
117
|
-
};
|