@stream-io/video-react-native-sdk 1.30.5 → 1.31.1-beta.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 +11 -0
- 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 +127 -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/android/src/main/java/com/streamvideo/reactnative/screenshare/ScreenAudioCapture.kt +111 -0
- package/dist/commonjs/components/Call/CallControls/ScreenShareToggleButton.js +3 -2
- package/dist/commonjs/components/Call/CallControls/ScreenShareToggleButton.js.map +1 -1
- package/dist/commonjs/hooks/index.js +11 -0
- package/dist/commonjs/hooks/index.js.map +1 -1
- 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 +144 -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/hooks/useScreenShareAudioMixing.js +126 -0
- package/dist/commonjs/hooks/useScreenShareAudioMixing.js.map +1 -0
- package/dist/commonjs/hooks/useScreenShareButton.js +57 -3
- package/dist/commonjs/hooks/useScreenShareButton.js.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/modules/ScreenShareAudioManager.js +54 -0
- package/dist/commonjs/modules/ScreenShareAudioManager.js.map +1 -0
- 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 +16 -6
- package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +35 -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 +150 -0
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -0
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +53 -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 +71 -53
- 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 +75 -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/components/Call/CallControls/ScreenShareToggleButton.js +3 -2
- package/dist/module/components/Call/CallControls/ScreenShareToggleButton.js.map +1 -1
- package/dist/module/hooks/index.js +1 -0
- package/dist/module/hooks/index.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 +137 -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/hooks/useScreenShareAudioMixing.js +119 -0
- package/dist/module/hooks/useScreenShareAudioMixing.js.map +1 -0
- package/dist/module/hooks/useScreenShareButton.js +57 -3
- package/dist/module/hooks/useScreenShareButton.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/modules/ScreenShareAudioManager.js +47 -0
- package/dist/module/modules/ScreenShareAudioManager.js.map +1 -0
- 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 +16 -6
- package/dist/module/providers/StreamCall/index.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +35 -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 +140 -0
- package/dist/module/utils/internal/callingx/callingx.js.map +1 -0
- package/dist/module/utils/internal/registerSDKGlobals.js +53 -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 +67 -50
- 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 +67 -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/components/Call/CallControls/ScreenShareToggleButton.d.ts +6 -1
- package/dist/typescript/components/Call/CallControls/ScreenShareToggleButton.d.ts.map +1 -1
- package/dist/typescript/hooks/index.d.ts +1 -0
- package/dist/typescript/hooks/index.d.ts.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/hooks/useScreenShareAudioMixing.d.ts +14 -0
- package/dist/typescript/hooks/useScreenShareAudioMixing.d.ts.map +1 -0
- package/dist/typescript/hooks/useScreenShareButton.d.ts +39 -2
- package/dist/typescript/hooks/useScreenShareButton.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/ScreenShareAudioManager.d.ts +28 -0
- package/dist/typescript/modules/ScreenShareAudioManager.d.ts.map +1 -0
- 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/providers/StreamCall/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +22 -2
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +59 -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 +18 -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/firebaseMessaging/index.d.ts +16 -2
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
- 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 +282 -86
- package/package.json +13 -18
- package/src/components/Call/CallControls/ScreenShareToggleButton.tsx +11 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/push/index.ts +0 -2
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +189 -0
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +94 -120
- package/src/hooks/useScreenShareAudioMixing.ts +130 -0
- package/src/hooks/useScreenShareButton.ts +87 -2
- package/src/index.ts +1 -0
- package/src/modules/ScreenShareAudioManager.ts +49 -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 +17 -6
- package/src/utils/StreamVideoRN/index.ts +42 -30
- package/src/utils/StreamVideoRN/types.ts +61 -25
- package/src/utils/internal/callingx/audioSessionPromise.ts +65 -0
- package/src/utils/internal/callingx/callingx.ts +194 -0
- package/src/utils/internal/registerSDKGlobals.ts +52 -4
- package/src/utils/keepCallAliveHeadlessTask.ts +54 -0
- package/src/utils/push/android.ts +198 -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 +108 -64
- package/src/utils/push/ios.ts +1 -6
- package/src/utils/push/libs/callingx.ts +89 -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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { Call, CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
2
|
+
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { filter, take } from 'rxjs/operators';
|
|
5
|
+
import { getCallDisplayName } from '../../utils/internal/callingx/callingx';
|
|
6
|
+
import { getCallingxLibIfAvailable } from '../../utils/push/libs/callingx';
|
|
7
|
+
|
|
8
|
+
const logger = videoLoggerSystem.getLogger('callingx');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This hook is used to inform sync call state with CallKit/Telecom (i.e. start call, end call, mute/unmute call).
|
|
12
|
+
*/
|
|
13
|
+
export const useCallingExpWithCallingStateEffect = () => {
|
|
14
|
+
const { useMicrophoneState, useParticipants, useCallMembers } =
|
|
15
|
+
useCallStateHooks();
|
|
16
|
+
|
|
17
|
+
const activeCall = useCall();
|
|
18
|
+
const { isMute, microphone } = useMicrophoneState();
|
|
19
|
+
const callMembers = useCallMembers();
|
|
20
|
+
const participants = useParticipants();
|
|
21
|
+
|
|
22
|
+
const activeCallCid = activeCall?.cid;
|
|
23
|
+
const currentUserId = activeCall?.currentUserId;
|
|
24
|
+
const isIncoming =
|
|
25
|
+
(activeCall?.ringing && !activeCall?.isCreatedByMe) || false;
|
|
26
|
+
|
|
27
|
+
const callDisplayName = useMemo(
|
|
28
|
+
() => getCallDisplayName(callMembers, participants, currentUserId),
|
|
29
|
+
[callMembers, participants, currentUserId],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const callingx = getCallingxLibIfAvailable();
|
|
34
|
+
if (!callingx?.isSetup || !activeCall) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// need to capture RINGING -> Joining -> Joined state change for the first time
|
|
38
|
+
// and inform callingx that the call is active
|
|
39
|
+
const shouldMakeCallActive = (call: Call): boolean => {
|
|
40
|
+
// only for outgoing calls or non-ringing ongoing calls in callingx
|
|
41
|
+
// Note: incoming calls are handled by callingx pending states instead
|
|
42
|
+
return (
|
|
43
|
+
(call.ringing && call.isCreatedByMe) ||
|
|
44
|
+
(!call.ringing && callingx.isOngoingCallsEnabled)
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
const subscription = activeCall.state.callingState$
|
|
48
|
+
.pipe(
|
|
49
|
+
filter(
|
|
50
|
+
(callingState) =>
|
|
51
|
+
shouldMakeCallActive(activeCall) &&
|
|
52
|
+
callingState === CallingState.JOINED &&
|
|
53
|
+
callingx.isCallTracked(activeCall.cid),
|
|
54
|
+
),
|
|
55
|
+
take(1), // only need to capture the first joined state for outgoing calls
|
|
56
|
+
// then subscription completes and is automatically unsubscribed
|
|
57
|
+
)
|
|
58
|
+
.subscribe(() => {
|
|
59
|
+
callingx.setCurrentCallActive(activeCall.cid);
|
|
60
|
+
});
|
|
61
|
+
return () => {
|
|
62
|
+
subscription.unsubscribe();
|
|
63
|
+
};
|
|
64
|
+
}, [activeCall]);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
return () => {
|
|
68
|
+
const callingx = getCallingxLibIfAvailable();
|
|
69
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const isCallTracked = callingx.isCallTracked(activeCallCid);
|
|
74
|
+
if (!isCallTracked) {
|
|
75
|
+
logger.debug(
|
|
76
|
+
`useCallingExpWithCallingStateEffect:No active call cid to end in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked}`,
|
|
77
|
+
);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
//if incoming stream call was unmounted, we need to end the call in CallKit/Telecom
|
|
81
|
+
logger.debug(
|
|
82
|
+
`useCallingExpWithCallingStateEffect: Ending call in callingx: ${activeCallCid}`,
|
|
83
|
+
);
|
|
84
|
+
callingx
|
|
85
|
+
.endCallWithReason(activeCallCid, 'local')
|
|
86
|
+
.catch((error: unknown) => {
|
|
87
|
+
logger.error(
|
|
88
|
+
`useCallingExpWithCallingStateEffect: Error ending call in callingx: ${activeCallCid}`,
|
|
89
|
+
error,
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
}, [activeCallCid]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const callingx = getCallingxLibIfAvailable();
|
|
97
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const isCallTracked = callingx.isCallTracked(activeCallCid);
|
|
102
|
+
if (!isCallTracked) {
|
|
103
|
+
logger.debug(
|
|
104
|
+
`useCallingExpWithCallingStateEffect:No active call cid to update callingx: ${activeCallCid} isCallTracked: ${isCallTracked}`,
|
|
105
|
+
);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
callingx.updateDisplay(
|
|
110
|
+
activeCallCid,
|
|
111
|
+
activeCallCid,
|
|
112
|
+
callDisplayName,
|
|
113
|
+
isIncoming,
|
|
114
|
+
);
|
|
115
|
+
}, [activeCallCid, callDisplayName, isIncoming]);
|
|
116
|
+
|
|
117
|
+
// Sync microphone mute state from app → CallKit
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
const callingx = getCallingxLibIfAvailable();
|
|
120
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const isCallTracked = callingx.isCallTracked(activeCallCid);
|
|
125
|
+
if (!isCallTracked) {
|
|
126
|
+
logger.debug(
|
|
127
|
+
`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked}`,
|
|
128
|
+
);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
callingx.setMutedCall(activeCallCid, isMute);
|
|
133
|
+
}, [activeCallCid, isMute]);
|
|
134
|
+
|
|
135
|
+
// Sync mute state from CallKit → app (only for system-initiated mute actions)
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
const callingx = getCallingxLibIfAvailable();
|
|
138
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
139
|
+
logger.debug(
|
|
140
|
+
`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} callingx isSetup: ${callingx?.isSetup}`,
|
|
141
|
+
);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Listen to mic toggle events from CallKit/Telecom and update stream call microphone state.
|
|
146
|
+
// Only system-initiated mute actions (e.g. user tapped mute on the native CallKit UI)
|
|
147
|
+
// are sent here — app-initiated actions are filtered out on the native side to prevent
|
|
148
|
+
// the feedback loop: app mutes mic → setMutedCall → CallKit delegate → event to JS → loop.
|
|
149
|
+
const subscription = callingx.addEventListener(
|
|
150
|
+
'didPerformSetMutedCallAction',
|
|
151
|
+
async (event: { callId: string; muted: boolean }) => {
|
|
152
|
+
const { callId, muted } = event;
|
|
153
|
+
|
|
154
|
+
const isCallTracked = callingx.isCallTracked(activeCallCid);
|
|
155
|
+
if (!isCallTracked || callId !== activeCallCid) {
|
|
156
|
+
logger.debug(
|
|
157
|
+
`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked} callId: ${callId}`,
|
|
158
|
+
);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const isCurrentlyMuted = microphone.state.status === 'disabled';
|
|
163
|
+
if (isCurrentlyMuted === muted) {
|
|
164
|
+
logger.debug(
|
|
165
|
+
`useCallingExpWithCallingStateEffect: Mic toggle is already in the desired state: ${muted} for call: ${activeCallCid}`,
|
|
166
|
+
);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
if (muted) {
|
|
172
|
+
await microphone.disable();
|
|
173
|
+
} else {
|
|
174
|
+
await microphone.enable();
|
|
175
|
+
}
|
|
176
|
+
} catch (error: unknown) {
|
|
177
|
+
logger.error(
|
|
178
|
+
`useCallingExpWithCallingStateEffect: Error toggling mic in calling exp: ${activeCallCid}`,
|
|
179
|
+
error,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return () => {
|
|
186
|
+
subscription.remove();
|
|
187
|
+
};
|
|
188
|
+
}, [activeCallCid, microphone]);
|
|
189
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { type MutableRefObject, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { getVoipPushNotificationLib } from '../../utils/push/libs';
|
|
3
|
-
|
|
4
2
|
import { Platform } from 'react-native';
|
|
5
3
|
import { StreamVideoRN } from '../../utils';
|
|
6
4
|
import { onVoipNotificationReceived } from '../../utils/push/internal/ios';
|
|
@@ -10,6 +8,7 @@ import {
|
|
|
10
8
|
} from '@stream-io/video-react-bindings';
|
|
11
9
|
import { setPushLogoutCallback } from '../../utils/internal/pushLogoutCallback';
|
|
12
10
|
import { StreamVideoClient, videoLoggerSystem } from '@stream-io/video-client';
|
|
11
|
+
import { getCallingxLibIfAvailable } from '../../utils/push/libs';
|
|
13
12
|
|
|
14
13
|
const logger = videoLoggerSystem.getLogger('useIosVoipPushEventsSetupEffect');
|
|
15
14
|
|
|
@@ -28,6 +27,7 @@ function setLogoutCallback(
|
|
|
28
27
|
lastVoipTokenRef.current = { token: '', userId: '' };
|
|
29
28
|
try {
|
|
30
29
|
await client.removeDevice(token);
|
|
30
|
+
logger.debug('PushLogoutCallback - Removed voip token', token);
|
|
31
31
|
} catch (err) {
|
|
32
32
|
logger.warn('PushLogoutCallback - Failed to remove voip token', err);
|
|
33
33
|
}
|
|
@@ -89,24 +89,12 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
89
89
|
useEffect(() => {
|
|
90
90
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
91
91
|
const pushProviderName = pushConfig?.ios.pushProviderName;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!pushConfig.android.incomingCallChannel) {
|
|
96
|
-
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
97
|
-
logger.debug(
|
|
98
|
-
'android incomingCallChannel is not defined, so skipping the useIosVoipPushEventsSetupEffect',
|
|
99
|
-
);
|
|
92
|
+
const callingx = getCallingxLibIfAvailable();
|
|
93
|
+
|
|
94
|
+
if (Platform.OS !== 'ios' || !client || !pushProviderName || !callingx) {
|
|
100
95
|
return;
|
|
101
96
|
}
|
|
102
97
|
|
|
103
|
-
const voipPushNotification = getVoipPushNotificationLib();
|
|
104
|
-
|
|
105
|
-
// even though we do this natively, we have to still register here again
|
|
106
|
-
// natively this will make sure "register" event for JS is sent with the last push token
|
|
107
|
-
// Necessary if client changed before we got the event here or user logged out and logged in again
|
|
108
|
-
voipPushNotification.registerVoipToken();
|
|
109
|
-
|
|
110
98
|
const onTokenReceived = (token: string) => {
|
|
111
99
|
const userId = client.streamClient._user?.id ?? '';
|
|
112
100
|
if (client.streamClient.anonymous || !token || !userId) {
|
|
@@ -145,24 +133,24 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
145
133
|
});
|
|
146
134
|
};
|
|
147
135
|
// fired when PushKit give us the latest token
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
const voipRegisterListener = callingx.addEventListener(
|
|
137
|
+
'voipNotificationsRegistered',
|
|
138
|
+
({ token }) => {
|
|
139
|
+
onTokenReceived(token);
|
|
140
|
+
},
|
|
141
|
+
);
|
|
151
142
|
|
|
152
|
-
// this will
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const { name, data } = voipPushEvent;
|
|
159
|
-
if (name === 'RNVoipPushRemoteNotificationsRegisteredEvent') {
|
|
160
|
-
onTokenReceived(data);
|
|
161
|
-
} else if (name === 'RNVoipPushRemoteNotificationReceivedEvent') {
|
|
162
|
-
onVoipNotificationReceived(data, pushConfig);
|
|
163
|
-
}
|
|
143
|
+
// this will return events that were fired before js bridge initialized
|
|
144
|
+
callingx.getInitialVoipEvents().forEach(({ eventName, params }) => {
|
|
145
|
+
if (eventName === 'voipNotificationsRegistered' && 'token' in params) {
|
|
146
|
+
onTokenReceived(params.token);
|
|
147
|
+
} else if (eventName === 'voipNotificationReceived') {
|
|
148
|
+
onVoipNotificationReceived(params, pushConfig);
|
|
164
149
|
}
|
|
165
150
|
});
|
|
151
|
+
|
|
152
|
+
callingx.registerVoipToken();
|
|
153
|
+
|
|
166
154
|
lastListener.count += 1;
|
|
167
155
|
const currentListenerCount = lastListener.count;
|
|
168
156
|
|
|
@@ -175,8 +163,7 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
175
163
|
return;
|
|
176
164
|
}
|
|
177
165
|
logger.debug(`Voip event listeners are removed for user: ${userId}`);
|
|
178
|
-
|
|
179
|
-
voipPushNotification.removeEventListener('register');
|
|
166
|
+
voipRegisterListener.remove();
|
|
180
167
|
};
|
|
181
168
|
}, [client]);
|
|
182
169
|
};
|
|
@@ -5,76 +5,48 @@ import {
|
|
|
5
5
|
AppState,
|
|
6
6
|
type AppStateStatus,
|
|
7
7
|
NativeModules,
|
|
8
|
+
PermissionsAndroid,
|
|
8
9
|
Platform,
|
|
9
10
|
} from 'react-native';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from '../utils/push/libs/notifee';
|
|
11
|
+
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
12
|
+
import { keepCallAliveCallRef } from '../utils/keepCallAliveHeadlessTask';
|
|
13
|
+
import { getNotifeeLibNoThrowForKeepCallAlive } from '../utils/push/libs/notifee';
|
|
14
|
+
import { getCallingxLibIfAvailable } from '../utils/push/libs';
|
|
15
15
|
|
|
16
16
|
const notifeeLib = getNotifeeLibNoThrowForKeepCallAlive();
|
|
17
|
-
const callToPassToForegroundService: { current: Call | undefined } = {
|
|
18
|
-
current: undefined,
|
|
19
|
-
};
|
|
20
17
|
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
logger.info(
|
|
30
|
-
'KeepCallAlive is not configured. Skipping foreground service setup.',
|
|
31
|
-
);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
notifeeLib.default.registerForegroundService(() => {
|
|
35
|
-
const task = new Promise((resolve) => {
|
|
36
|
-
const logger = videoLoggerSystem.getLogger(
|
|
37
|
-
'setForegroundService method',
|
|
38
|
-
);
|
|
39
|
-
logger.info('Foreground service running for call in progress');
|
|
40
|
-
// any task to run from SDK in the foreground service must be added
|
|
41
|
-
resolve(true);
|
|
42
|
-
});
|
|
43
|
-
const videoConfig = StreamVideoRN.getConfig();
|
|
44
|
-
const foregroundServiceConfig = videoConfig.foregroundService;
|
|
45
|
-
const { taskToRun } = foregroundServiceConfig.android;
|
|
46
|
-
const call = callToPassToForegroundService.current;
|
|
47
|
-
if (!call) {
|
|
48
|
-
const logger = videoLoggerSystem.getLogger(
|
|
49
|
-
'setForegroundService method',
|
|
50
|
-
);
|
|
51
|
-
logger.warn('No call to pass to foreground service');
|
|
52
|
-
return task.then(() => new Promise(() => {}));
|
|
53
|
-
}
|
|
54
|
-
callToPassToForegroundService.current = undefined;
|
|
55
|
-
return task.then(() => taskToRun(call));
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
);
|
|
18
|
+
async function stopForegroundServiceNoThrow() {
|
|
19
|
+
const logger = videoLoggerSystem.getLogger('stopForegroundServiceNoThrow');
|
|
20
|
+
try {
|
|
21
|
+
await NativeModules.StreamVideoReactNative.stopKeepCallAliveService();
|
|
22
|
+
} catch (e) {
|
|
23
|
+
logger.warn('Failed to stop keep-call-alive foreground service', e);
|
|
24
|
+
}
|
|
59
25
|
}
|
|
60
26
|
|
|
61
27
|
async function startForegroundService(call_cid: string) {
|
|
62
|
-
const
|
|
63
|
-
|
|
28
|
+
const logger = videoLoggerSystem.getLogger('startForegroundService');
|
|
29
|
+
const isCallAliveConfigured = await (async () => {
|
|
30
|
+
try {
|
|
31
|
+
return await NativeModules.StreamVideoReactNative.isCallAliveConfigured();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
logger.warn('Failed to check whether KeepCallAlive is configured', e);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
64
37
|
if (!isCallAliveConfigured) {
|
|
65
|
-
const logger = videoLoggerSystem.getLogger('startForegroundService');
|
|
66
38
|
logger.info(
|
|
67
39
|
'KeepCallAlive is not configured. Skipping foreground service setup.',
|
|
68
40
|
);
|
|
69
41
|
return;
|
|
70
42
|
}
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
43
|
+
// Check for notification permission (Android 13+) before starting the service.
|
|
44
|
+
const hasPostNotificationsPermission =
|
|
45
|
+
Number(Platform.Version) < 33 ||
|
|
46
|
+
(await PermissionsAndroid.check(
|
|
47
|
+
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
|
|
48
|
+
));
|
|
49
|
+
if (!hasPostNotificationsPermission) {
|
|
78
50
|
logger.info(
|
|
79
51
|
'Notification permission not granted, can not start foreground service to keep the call alive',
|
|
80
52
|
);
|
|
@@ -83,38 +55,28 @@ async function startForegroundService(call_cid: string) {
|
|
|
83
55
|
const videoConfig = StreamVideoRN.getConfig();
|
|
84
56
|
const foregroundServiceConfig = videoConfig.foregroundService;
|
|
85
57
|
const notificationTexts = foregroundServiceConfig.android.notificationTexts;
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
);
|
|
90
|
-
const foregroundServiceTypes = await getKeepCallAliveForegroundServiceTypes();
|
|
58
|
+
const channel = foregroundServiceConfig.android.channel;
|
|
59
|
+
const smallIconName = videoConfig.push?.android.smallIcon;
|
|
60
|
+
|
|
91
61
|
// NOTE: we use requestAnimationFrame to ensure that the foreground service is started after all the current UI operations are done
|
|
92
62
|
// this is a workaround for the crash - android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground()
|
|
93
63
|
// this crash was reproducible only in some android devices
|
|
94
|
-
requestAnimationFrame(() => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
id: 'default',
|
|
108
|
-
launchActivity: 'default', // open the app when the notification is pressed
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
});
|
|
64
|
+
requestAnimationFrame(async () => {
|
|
65
|
+
try {
|
|
66
|
+
await NativeModules.StreamVideoReactNative.startKeepCallAliveService(
|
|
67
|
+
call_cid,
|
|
68
|
+
channel.id,
|
|
69
|
+
channel.name,
|
|
70
|
+
notificationTexts.title,
|
|
71
|
+
notificationTexts.body,
|
|
72
|
+
smallIconName ?? null,
|
|
73
|
+
);
|
|
74
|
+
} catch (e) {
|
|
75
|
+
logger.warn('Failed to start keep-call-alive foreground service', e);
|
|
76
|
+
}
|
|
112
77
|
});
|
|
113
78
|
}
|
|
114
79
|
|
|
115
|
-
// flag to check if setForegroundService has already been run once
|
|
116
|
-
let isSetForegroundServiceRan = false;
|
|
117
|
-
|
|
118
80
|
/**
|
|
119
81
|
* This hook is used to keep the call alive in the background for Android.
|
|
120
82
|
* It starts a foreground service to keep the call alive as soon as the call is joined
|
|
@@ -125,7 +87,7 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
125
87
|
const foregroundServiceStartedRef = useRef(false);
|
|
126
88
|
|
|
127
89
|
const call = useCall();
|
|
128
|
-
|
|
90
|
+
keepCallAliveCallRef.current = call;
|
|
129
91
|
const activeCallCid = call?.cid;
|
|
130
92
|
const { useCallCallingState } = useCallStateHooks();
|
|
131
93
|
const callingState = useCallCallingState();
|
|
@@ -133,6 +95,7 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
133
95
|
const isOutgoingCall =
|
|
134
96
|
callingState === CallingState.RINGING && call?.isCreatedByMe;
|
|
135
97
|
const isCallJoined = callingState === CallingState.JOINED;
|
|
98
|
+
const isRingingCall = call?.ringing;
|
|
136
99
|
|
|
137
100
|
const shouldStartForegroundService =
|
|
138
101
|
!foregroundServiceStartedRef.current && (isOutgoingCall || isCallJoined);
|
|
@@ -141,7 +104,14 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
141
104
|
if (Platform.OS === 'ios' || !activeCallCid) {
|
|
142
105
|
return undefined;
|
|
143
106
|
}
|
|
144
|
-
|
|
107
|
+
|
|
108
|
+
const callingx = getCallingxLibIfAvailable();
|
|
109
|
+
if (
|
|
110
|
+
callingx?.isSetup &&
|
|
111
|
+
(isRingingCall || (!isRingingCall && callingx?.isOngoingCallsEnabled))
|
|
112
|
+
) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
145
115
|
|
|
146
116
|
// start foreground service as soon as the call is joined
|
|
147
117
|
if (shouldStartForegroundService) {
|
|
@@ -149,23 +119,21 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
149
119
|
if (foregroundServiceStartedRef.current) {
|
|
150
120
|
return;
|
|
151
121
|
}
|
|
152
|
-
if
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
notifee.cancelDisplayedNotification(activeCallCid);
|
|
122
|
+
// Optional compatibility cleanup: if the app uses Notifee for ringing push,
|
|
123
|
+
// we might have an incoming call notification running as a foreground service.
|
|
124
|
+
if (notifeeLib) {
|
|
125
|
+
const notifee = notifeeLib.default;
|
|
126
|
+
const displayedNotifications =
|
|
127
|
+
await notifee.getDisplayedNotifications();
|
|
128
|
+
const activeCallNotification = displayedNotifications.find(
|
|
129
|
+
(notification) => notification.id === activeCallCid,
|
|
130
|
+
);
|
|
131
|
+
if (activeCallNotification) {
|
|
132
|
+
// this means that we have a incoming call notification shown as foreground service and we must stop it
|
|
133
|
+
notifee.stopForegroundService();
|
|
134
|
+
notifee.cancelDisplayedNotification(activeCallCid);
|
|
135
|
+
}
|
|
167
136
|
}
|
|
168
|
-
// check for notification permission and then start the foreground service
|
|
169
137
|
|
|
170
138
|
await startForegroundService(activeCallCid);
|
|
171
139
|
foregroundServiceStartedRef.current = true;
|
|
@@ -174,7 +142,6 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
174
142
|
// ensure that app is active before running the function
|
|
175
143
|
if (AppState.currentState === 'active') {
|
|
176
144
|
run();
|
|
177
|
-
return undefined;
|
|
178
145
|
}
|
|
179
146
|
const sub = AppState.addEventListener(
|
|
180
147
|
'change',
|
|
@@ -192,42 +159,49 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
192
159
|
return () => {
|
|
193
160
|
// cancel any notifee displayed notification when the call has transitioned out of ringing
|
|
194
161
|
// NOTE: cancels only the non fg service notifications
|
|
195
|
-
notifeeLib
|
|
162
|
+
if (notifeeLib) {
|
|
163
|
+
notifeeLib.default.cancelDisplayedNotification(activeCallCid);
|
|
164
|
+
}
|
|
196
165
|
};
|
|
197
166
|
} else if (
|
|
198
167
|
callingState === CallingState.IDLE ||
|
|
199
168
|
callingState === CallingState.LEFT
|
|
200
169
|
) {
|
|
201
170
|
if (foregroundServiceStartedRef.current) {
|
|
202
|
-
|
|
171
|
+
keepCallAliveCallRef.current = undefined;
|
|
203
172
|
// stop foreground service when the call is not active
|
|
204
|
-
|
|
173
|
+
stopForegroundServiceNoThrow();
|
|
205
174
|
foregroundServiceStartedRef.current = false;
|
|
206
175
|
} else {
|
|
207
|
-
notifeeLib
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
176
|
+
if (notifeeLib) {
|
|
177
|
+
notifeeLib.default
|
|
178
|
+
.getDisplayedNotifications()
|
|
179
|
+
.then((displayedNotifications) => {
|
|
180
|
+
const activeCallNotification = displayedNotifications.find(
|
|
181
|
+
(notification) => notification.id === activeCallCid,
|
|
182
|
+
);
|
|
183
|
+
if (activeCallNotification) {
|
|
184
|
+
// this means that we have a incoming call notification shown as foreground service and we must stop it
|
|
185
|
+
notifeeLib.default.stopForegroundService();
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
219
189
|
}
|
|
220
190
|
}
|
|
221
191
|
return undefined;
|
|
222
|
-
}, [
|
|
192
|
+
}, [
|
|
193
|
+
activeCallCid,
|
|
194
|
+
callingState,
|
|
195
|
+
shouldStartForegroundService,
|
|
196
|
+
isRingingCall,
|
|
197
|
+
]);
|
|
223
198
|
|
|
224
199
|
useEffect(() => {
|
|
225
200
|
return () => {
|
|
226
201
|
// stop foreground service when this effect is unmounted
|
|
227
202
|
if (foregroundServiceStartedRef.current) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
notifeeLib.default.stopForegroundService();
|
|
203
|
+
keepCallAliveCallRef.current = undefined;
|
|
204
|
+
stopForegroundServiceNoThrow();
|
|
231
205
|
foregroundServiceStartedRef.current = false;
|
|
232
206
|
}
|
|
233
207
|
};
|