@stream-io/video-react-native-sdk 1.29.0-beta.3 → 1.29.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/CHANGELOG.md +3126 -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/components/Call/CallContent/CallContent.js +7 -2
- package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +8 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +3 -0
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
- 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 +15 -52
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +202 -155
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/ios.js +32 -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 +16 -28
- 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/components/Call/CallContent/CallContent.js +7 -2
- package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +8 -1
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipNative.js +3 -0
- package/dist/module/components/Call/CallContent/RTCViewPipNative.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 +16 -53
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/push/android.js +204 -157
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/ios.js +32 -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 +15 -25
- 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/components/Call/CallContent/CallContent.d.ts +2 -2
- package/dist/typescript/components/Call/CallContent/CallContent.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts +4 -0
- package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +9 -6
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.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 +1 -8
- 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/PictureInPicture/StreamAVPictureInPictureVideoCallViewController.swift +8 -0
- package/ios/PictureInPicture/StreamPictureInPictureController.swift +8 -0
- package/ios/PictureInPicture/StreamPictureInPictureVideoRenderer.swift +10 -0
- package/ios/RTCViewPip.swift +6 -0
- package/ios/RTCViewPipManager.mm +1 -0
- package/ios/StreamInCallManager.m +0 -2
- package/ios/StreamInCallManager.swift +7 -19
- package/ios/StreamVideoReactNative.h +4 -7
- package/ios/StreamVideoReactNative.m +102 -191
- package/package.json +19 -14
- package/src/components/Call/CallContent/CallContent.tsx +6 -1
- package/src/components/Call/CallContent/RTCViewPipIOS.tsx +18 -2
- package/src/components/Call/CallContent/RTCViewPipNative.tsx +4 -7
- 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 +23 -47
- package/src/utils/push/android.ts +309 -231
- package/src/utils/push/internal/ios.ts +42 -27
- package/src/utils/push/internal/rxSubjects.ts +29 -0
- package/src/utils/push/internal/utils.ts +15 -38
- 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 -121
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/commonjs/utils/internal/audioSessionPromise.js +0 -57
- package/dist/commonjs/utils/internal/audioSessionPromise.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx.js +0 -136
- 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 -114
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/module/utils/internal/audioSessionPromise.js +0 -50
- package/dist/module/utils/internal/audioSessionPromise.js.map +0 -1
- package/dist/module/utils/internal/callingx.js +0 -127
- 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 -147
- package/src/utils/internal/audioSessionPromise.ts +0 -52
- package/src/utils/internal/callingx.ts +0 -192
- package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
- package/src/utils/push/libs/callingx.ts +0 -90
- package/src/utils/push/setupCallingExpEvents.ts +0 -117
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CallingState,
|
|
3
|
+
RxUtils,
|
|
4
|
+
videoLoggerSystem,
|
|
5
|
+
} from '@stream-io/video-client';
|
|
6
|
+
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
7
|
+
import { NativeModules, Platform } from 'react-native';
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
9
|
+
import { StreamVideoRN } from '../../utils';
|
|
10
|
+
import { getCallKeepLib } from '../../utils/push/libs';
|
|
11
|
+
import {
|
|
12
|
+
voipCallkeepAcceptedCallOnNativeDialerMap$,
|
|
13
|
+
voipCallkeepCallOnForegroundMap$,
|
|
14
|
+
voipPushNotificationCallCId$,
|
|
15
|
+
} from '../../utils/push/internal/rxSubjects';
|
|
16
|
+
|
|
17
|
+
const isNonActiveCallingState = (callingState: CallingState) => {
|
|
18
|
+
return (
|
|
19
|
+
callingState === CallingState.IDLE ||
|
|
20
|
+
callingState === CallingState.UNKNOWN ||
|
|
21
|
+
callingState === CallingState.LEFT
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const isAcceptedCallingState = (callingState: CallingState) => {
|
|
26
|
+
return (
|
|
27
|
+
callingState === CallingState.JOINING ||
|
|
28
|
+
callingState === CallingState.JOINED
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const unsubscribeCallkeepEvents = async (activeCallCid: string | undefined) => {
|
|
33
|
+
const voipPushNotificationCallCId = RxUtils.getCurrentValue(
|
|
34
|
+
voipPushNotificationCallCId$,
|
|
35
|
+
);
|
|
36
|
+
if (activeCallCid && activeCallCid === voipPushNotificationCallCId) {
|
|
37
|
+
// callkeep events should not be listened anymore so clear the call cid
|
|
38
|
+
voipPushNotificationCallCId$.next(undefined);
|
|
39
|
+
}
|
|
40
|
+
return await NativeModules.StreamVideoReactNative?.removeIncomingCall(
|
|
41
|
+
activeCallCid,
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const logger = videoLoggerSystem.getLogger(
|
|
46
|
+
'useIosCallkeepWithCallingStateEffect',
|
|
47
|
+
);
|
|
48
|
+
const log = (message: string) => {
|
|
49
|
+
logger.warn(message);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This hook is used to inform the callkeep library that the call has been joined or ended.
|
|
54
|
+
*/
|
|
55
|
+
export const useIosCallkeepWithCallingStateEffect = () => {
|
|
56
|
+
const activeCall = useCall();
|
|
57
|
+
const { useCallCallingState } = useCallStateHooks();
|
|
58
|
+
const callingState = useCallCallingState();
|
|
59
|
+
const [acceptedForegroundCallkeepMap, setAcceptedForegroundCallkeepMap] =
|
|
60
|
+
useState<{
|
|
61
|
+
uuid: string;
|
|
62
|
+
cid: string;
|
|
63
|
+
}>();
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
return () => {
|
|
67
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
68
|
+
if (
|
|
69
|
+
Platform.OS !== 'ios' ||
|
|
70
|
+
!pushConfig ||
|
|
71
|
+
!pushConfig.ios?.pushProviderName
|
|
72
|
+
) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!pushConfig.android.incomingCallChannel) {
|
|
76
|
+
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const callkeep = getCallKeepLib();
|
|
81
|
+
// if the component is unmounted and the callID was not reported to callkeep, then report it now
|
|
82
|
+
if (acceptedForegroundCallkeepMap) {
|
|
83
|
+
log(
|
|
84
|
+
`Ending call in callkeep: ${acceptedForegroundCallkeepMap.cid}, reason: component unmounted and call was present in acceptedForegroundCallkeepMap`,
|
|
85
|
+
);
|
|
86
|
+
unsubscribeCallkeepEvents(acceptedForegroundCallkeepMap.cid).then(() =>
|
|
87
|
+
callkeep.endCall(acceptedForegroundCallkeepMap.uuid),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}, [acceptedForegroundCallkeepMap]);
|
|
92
|
+
|
|
93
|
+
const activeCallCid = activeCall?.cid;
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
return () => {
|
|
97
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
98
|
+
if (
|
|
99
|
+
Platform.OS !== 'ios' ||
|
|
100
|
+
!pushConfig ||
|
|
101
|
+
!pushConfig.ios?.pushProviderName ||
|
|
102
|
+
!activeCallCid
|
|
103
|
+
) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!pushConfig.android.incomingCallChannel) {
|
|
107
|
+
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(
|
|
111
|
+
voipCallkeepAcceptedCallOnNativeDialerMap$,
|
|
112
|
+
);
|
|
113
|
+
const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(
|
|
114
|
+
voipCallkeepCallOnForegroundMap$,
|
|
115
|
+
);
|
|
116
|
+
const callkeep = getCallKeepLib();
|
|
117
|
+
if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
|
|
118
|
+
log(
|
|
119
|
+
`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in nativeDialerAcceptedCallMap`,
|
|
120
|
+
);
|
|
121
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() =>
|
|
122
|
+
callkeep.endCall(nativeDialerAcceptedCallMap.uuid),
|
|
123
|
+
);
|
|
124
|
+
// no need to keep this reference anymore
|
|
125
|
+
voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
126
|
+
} else if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
|
|
127
|
+
log(
|
|
128
|
+
`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in foregroundIncomingCallkeepMap`,
|
|
129
|
+
);
|
|
130
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() =>
|
|
131
|
+
callkeep.endCall(foregroundIncomingCallkeepMap.uuid),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}, [activeCallCid]);
|
|
136
|
+
|
|
137
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
138
|
+
if (
|
|
139
|
+
Platform.OS !== 'ios' ||
|
|
140
|
+
!pushConfig ||
|
|
141
|
+
!pushConfig.ios.pushProviderName ||
|
|
142
|
+
!activeCallCid
|
|
143
|
+
) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (!pushConfig.android.incomingCallChannel) {
|
|
147
|
+
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Check if current call is still needed to be accepted in callkeep
|
|
153
|
+
*/
|
|
154
|
+
if (
|
|
155
|
+
isAcceptedCallingState(callingState) &&
|
|
156
|
+
acceptedForegroundCallkeepMap?.cid !== activeCallCid
|
|
157
|
+
) {
|
|
158
|
+
const callkeep = getCallKeepLib();
|
|
159
|
+
// push notification was displayed
|
|
160
|
+
// but the call has been accepted through the app and not through the native dialer
|
|
161
|
+
const foregroundCallkeepMap = RxUtils.getCurrentValue(
|
|
162
|
+
voipCallkeepCallOnForegroundMap$,
|
|
163
|
+
);
|
|
164
|
+
if (foregroundCallkeepMap && foregroundCallkeepMap.cid === activeCallCid) {
|
|
165
|
+
log(
|
|
166
|
+
// @ts-expect-error - types issue
|
|
167
|
+
`Accepting call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundCallkeepMap`,
|
|
168
|
+
);
|
|
169
|
+
// no need to keep this reference anymore
|
|
170
|
+
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
171
|
+
NativeModules.StreamVideoReactNative?.removeIncomingCall(
|
|
172
|
+
activeCallCid,
|
|
173
|
+
).then(() => callkeep.answerIncomingCall(foregroundCallkeepMap.uuid));
|
|
174
|
+
// this call should be accepted in callkeep
|
|
175
|
+
setAcceptedForegroundCallkeepMap(foregroundCallkeepMap);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Check if current call is still needed to be ended in callkeep
|
|
181
|
+
*/
|
|
182
|
+
if (isNonActiveCallingState(callingState)) {
|
|
183
|
+
const callkeep = getCallKeepLib();
|
|
184
|
+
|
|
185
|
+
// this was a previously joined call which had push notification displayed
|
|
186
|
+
// the call was accepted through the app and not through native dialer
|
|
187
|
+
// the call was left using the leave button in the app and not through native dialer
|
|
188
|
+
if (activeCallCid === acceptedForegroundCallkeepMap?.cid) {
|
|
189
|
+
log(
|
|
190
|
+
// @ts-expect-error - types issue
|
|
191
|
+
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in acceptedForegroundCallkeepMap`,
|
|
192
|
+
);
|
|
193
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() =>
|
|
194
|
+
callkeep.endCall(acceptedForegroundCallkeepMap.uuid),
|
|
195
|
+
);
|
|
196
|
+
setAcceptedForegroundCallkeepMap(undefined);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
// this was a call which had push notification displayed but never joined
|
|
200
|
+
// the user rejected in the app and not from native dialer
|
|
201
|
+
const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(
|
|
202
|
+
voipCallkeepCallOnForegroundMap$,
|
|
203
|
+
);
|
|
204
|
+
if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
|
|
205
|
+
log(
|
|
206
|
+
// @ts-expect-error - types issue
|
|
207
|
+
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundIncomingCallkeepMap`,
|
|
208
|
+
);
|
|
209
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() =>
|
|
210
|
+
callkeep.endCall(foregroundIncomingCallkeepMap.uuid),
|
|
211
|
+
);
|
|
212
|
+
// no need to keep this reference anymore
|
|
213
|
+
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// this was a previously joined call
|
|
217
|
+
// it was an accepted call from native dialer and not from the app
|
|
218
|
+
// the user left using the leave button in the app
|
|
219
|
+
const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(
|
|
220
|
+
voipCallkeepAcceptedCallOnNativeDialerMap$,
|
|
221
|
+
);
|
|
222
|
+
if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
|
|
223
|
+
log(
|
|
224
|
+
// @ts-expect-error - types issue
|
|
225
|
+
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in nativeDialerAcceptedCallMap`,
|
|
226
|
+
);
|
|
227
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() =>
|
|
228
|
+
callkeep.endCall(nativeDialerAcceptedCallMap.uuid),
|
|
229
|
+
);
|
|
230
|
+
// no need to keep this reference anymore
|
|
231
|
+
voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type MutableRefObject, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { getVoipPushNotificationLib } from '../../utils/push/libs';
|
|
3
|
+
|
|
2
4
|
import { Platform } from 'react-native';
|
|
3
5
|
import { StreamVideoRN } from '../../utils';
|
|
4
6
|
import { onVoipNotificationReceived } from '../../utils/push/internal/ios';
|
|
@@ -8,7 +10,6 @@ import {
|
|
|
8
10
|
} from '@stream-io/video-react-bindings';
|
|
9
11
|
import { setPushLogoutCallback } from '../../utils/internal/pushLogoutCallback';
|
|
10
12
|
import { StreamVideoClient, videoLoggerSystem } from '@stream-io/video-client';
|
|
11
|
-
import { getCallingxLibIfAvailable } from '../../utils/push/libs';
|
|
12
13
|
|
|
13
14
|
const logger = videoLoggerSystem.getLogger('useIosVoipPushEventsSetupEffect');
|
|
14
15
|
|
|
@@ -27,7 +28,6 @@ function setLogoutCallback(
|
|
|
27
28
|
lastVoipTokenRef.current = { token: '', userId: '' };
|
|
28
29
|
try {
|
|
29
30
|
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,12 +89,24 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
89
89
|
useEffect(() => {
|
|
90
90
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
91
91
|
const pushProviderName = pushConfig?.ios.pushProviderName;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
if (Platform.OS !== 'ios' || !client || !pushProviderName) {
|
|
93
|
+
return;
|
|
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
|
+
);
|
|
95
100
|
return;
|
|
96
101
|
}
|
|
97
102
|
|
|
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
|
+
|
|
98
110
|
const onTokenReceived = (token: string) => {
|
|
99
111
|
const userId = client.streamClient._user?.id ?? '';
|
|
100
112
|
if (client.streamClient.anonymous || !token || !userId) {
|
|
@@ -133,24 +145,24 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
133
145
|
});
|
|
134
146
|
};
|
|
135
147
|
// fired when PushKit give us the latest token
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
onTokenReceived(token);
|
|
140
|
-
},
|
|
141
|
-
);
|
|
148
|
+
voipPushNotification.addEventListener('register', (token) => {
|
|
149
|
+
onTokenReceived(token);
|
|
150
|
+
});
|
|
142
151
|
|
|
143
|
-
// this will
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
152
|
+
// this will fire when there are events occured before js bridge initialized
|
|
153
|
+
voipPushNotification.addEventListener('didLoadWithEvents', (events) => {
|
|
154
|
+
if (!events || !Array.isArray(events) || events.length < 1) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
for (const voipPushEvent of events) {
|
|
158
|
+
const { name, data } = voipPushEvent;
|
|
159
|
+
if (name === 'RNVoipPushRemoteNotificationsRegisteredEvent') {
|
|
160
|
+
onTokenReceived(data);
|
|
161
|
+
} else if (name === 'RNVoipPushRemoteNotificationReceivedEvent') {
|
|
162
|
+
onVoipNotificationReceived(data, pushConfig);
|
|
163
|
+
}
|
|
149
164
|
}
|
|
150
165
|
});
|
|
151
|
-
|
|
152
|
-
callingx.registerVoipToken();
|
|
153
|
-
|
|
154
166
|
lastListener.count += 1;
|
|
155
167
|
const currentListenerCount = lastListener.count;
|
|
156
168
|
|
|
@@ -163,7 +175,8 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
163
175
|
return;
|
|
164
176
|
}
|
|
165
177
|
logger.debug(`Voip event listeners are removed for user: ${userId}`);
|
|
166
|
-
|
|
178
|
+
voipPushNotification.removeEventListener('didLoadWithEvents');
|
|
179
|
+
voipPushNotification.removeEventListener('register');
|
|
167
180
|
};
|
|
168
181
|
}, [client]);
|
|
169
182
|
};
|
|
@@ -5,48 +5,76 @@ import {
|
|
|
5
5
|
AppState,
|
|
6
6
|
type AppStateStatus,
|
|
7
7
|
NativeModules,
|
|
8
|
-
PermissionsAndroid,
|
|
9
8
|
Platform,
|
|
10
9
|
} from 'react-native';
|
|
11
|
-
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import { Call, CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
11
|
+
import {
|
|
12
|
+
getKeepCallAliveForegroundServiceTypes,
|
|
13
|
+
getNotifeeLibNoThrowForKeepCallAlive,
|
|
14
|
+
} from '../utils/push/libs/notifee';
|
|
15
15
|
|
|
16
16
|
const notifeeLib = getNotifeeLibNoThrowForKeepCallAlive();
|
|
17
|
+
const callToPassToForegroundService: { current: Call | undefined } = {
|
|
18
|
+
current: undefined,
|
|
19
|
+
};
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
function setForegroundService() {
|
|
22
|
+
if (Platform.OS === 'ios' || !notifeeLib) return;
|
|
23
|
+
NativeModules.StreamVideoReactNative.isCallAliveConfigured().then(
|
|
24
|
+
(isConfigured: boolean) => {
|
|
25
|
+
if (!isConfigured) {
|
|
26
|
+
const logger = videoLoggerSystem.getLogger(
|
|
27
|
+
'setForegroundService method',
|
|
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
|
+
);
|
|
25
59
|
}
|
|
26
60
|
|
|
27
61
|
async function startForegroundService(call_cid: string) {
|
|
28
|
-
const
|
|
29
|
-
|
|
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
|
-
})();
|
|
62
|
+
const isCallAliveConfigured =
|
|
63
|
+
await NativeModules.StreamVideoReactNative.isCallAliveConfigured();
|
|
37
64
|
if (!isCallAliveConfigured) {
|
|
65
|
+
const logger = videoLoggerSystem.getLogger('startForegroundService');
|
|
38
66
|
logger.info(
|
|
39
67
|
'KeepCallAlive is not configured. Skipping foreground service setup.',
|
|
40
68
|
);
|
|
41
69
|
return;
|
|
42
70
|
}
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
// check for notification permission and then start the foreground service
|
|
72
|
+
if (!notifeeLib) return;
|
|
73
|
+
const settings = await notifeeLib.default.getNotificationSettings();
|
|
74
|
+
if (
|
|
75
|
+
settings.authorizationStatus !== notifeeLib.AuthorizationStatus.AUTHORIZED
|
|
76
|
+
) {
|
|
77
|
+
const logger = videoLoggerSystem.getLogger('startForegroundService');
|
|
50
78
|
logger.info(
|
|
51
79
|
'Notification permission not granted, can not start foreground service to keep the call alive',
|
|
52
80
|
);
|
|
@@ -55,28 +83,38 @@ async function startForegroundService(call_cid: string) {
|
|
|
55
83
|
const videoConfig = StreamVideoRN.getConfig();
|
|
56
84
|
const foregroundServiceConfig = videoConfig.foregroundService;
|
|
57
85
|
const notificationTexts = foregroundServiceConfig.android.notificationTexts;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
86
|
+
const channelId = foregroundServiceConfig.android.channel.id;
|
|
87
|
+
await notifeeLib.default.createChannel(
|
|
88
|
+
foregroundServiceConfig.android.channel,
|
|
89
|
+
);
|
|
90
|
+
const foregroundServiceTypes = await getKeepCallAliveForegroundServiceTypes();
|
|
61
91
|
// NOTE: we use requestAnimationFrame to ensure that the foreground service is started after all the current UI operations are done
|
|
62
92
|
// this is a workaround for the crash - android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground()
|
|
63
93
|
// this crash was reproducible only in some android devices
|
|
64
|
-
requestAnimationFrame(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
requestAnimationFrame(() => {
|
|
95
|
+
notifeeLib.default.displayNotification({
|
|
96
|
+
id: call_cid,
|
|
97
|
+
title: notificationTexts.title,
|
|
98
|
+
body: notificationTexts.body,
|
|
99
|
+
android: {
|
|
100
|
+
channelId,
|
|
101
|
+
smallIcon: videoConfig.push?.android.smallIcon,
|
|
102
|
+
foregroundServiceTypes,
|
|
103
|
+
asForegroundService: true,
|
|
104
|
+
ongoing: true, // user cannot dismiss the notification
|
|
105
|
+
colorized: true,
|
|
106
|
+
pressAction: {
|
|
107
|
+
id: 'default',
|
|
108
|
+
launchActivity: 'default', // open the app when the notification is pressed
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
77
112
|
});
|
|
78
113
|
}
|
|
79
114
|
|
|
115
|
+
// flag to check if setForegroundService has already been run once
|
|
116
|
+
let isSetForegroundServiceRan = false;
|
|
117
|
+
|
|
80
118
|
/**
|
|
81
119
|
* This hook is used to keep the call alive in the background for Android.
|
|
82
120
|
* It starts a foreground service to keep the call alive as soon as the call is joined
|
|
@@ -87,7 +125,7 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
87
125
|
const foregroundServiceStartedRef = useRef(false);
|
|
88
126
|
|
|
89
127
|
const call = useCall();
|
|
90
|
-
|
|
128
|
+
callToPassToForegroundService.current = call;
|
|
91
129
|
const activeCallCid = call?.cid;
|
|
92
130
|
const { useCallCallingState } = useCallStateHooks();
|
|
93
131
|
const callingState = useCallCallingState();
|
|
@@ -95,7 +133,6 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
95
133
|
const isOutgoingCall =
|
|
96
134
|
callingState === CallingState.RINGING && call?.isCreatedByMe;
|
|
97
135
|
const isCallJoined = callingState === CallingState.JOINED;
|
|
98
|
-
const isRingingCall = call?.ringing;
|
|
99
136
|
|
|
100
137
|
const shouldStartForegroundService =
|
|
101
138
|
!foregroundServiceStartedRef.current && (isOutgoingCall || isCallJoined);
|
|
@@ -104,14 +141,7 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
104
141
|
if (Platform.OS === 'ios' || !activeCallCid) {
|
|
105
142
|
return undefined;
|
|
106
143
|
}
|
|
107
|
-
|
|
108
|
-
const callingx = getCallingxLibIfAvailable();
|
|
109
|
-
if (
|
|
110
|
-
callingx?.isSetup &&
|
|
111
|
-
(isRingingCall || (!isRingingCall && callingx?.isOngoingCallsEnabled))
|
|
112
|
-
) {
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
144
|
+
if (!notifeeLib) return undefined;
|
|
115
145
|
|
|
116
146
|
// start foreground service as soon as the call is joined
|
|
117
147
|
if (shouldStartForegroundService) {
|
|
@@ -119,21 +149,23 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
119
149
|
if (foregroundServiceStartedRef.current) {
|
|
120
150
|
return;
|
|
121
151
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
152
|
+
if (!isSetForegroundServiceRan) {
|
|
153
|
+
isSetForegroundServiceRan = true;
|
|
154
|
+
setForegroundService();
|
|
155
|
+
}
|
|
156
|
+
const notifee = notifeeLib.default;
|
|
157
|
+
const displayedNotifications =
|
|
158
|
+
await notifee.getDisplayedNotifications();
|
|
159
|
+
const activeCallNotification = displayedNotifications.find(
|
|
160
|
+
(notification) => notification.id === activeCallCid,
|
|
161
|
+
);
|
|
162
|
+
if (activeCallNotification) {
|
|
163
|
+
callToPassToForegroundService.current = undefined;
|
|
164
|
+
// this means that we have a incoming call notification shown as foreground service and we must stop it
|
|
165
|
+
notifee.stopForegroundService();
|
|
166
|
+
notifee.cancelDisplayedNotification(activeCallCid);
|
|
136
167
|
}
|
|
168
|
+
// check for notification permission and then start the foreground service
|
|
137
169
|
|
|
138
170
|
await startForegroundService(activeCallCid);
|
|
139
171
|
foregroundServiceStartedRef.current = true;
|
|
@@ -142,6 +174,7 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
142
174
|
// ensure that app is active before running the function
|
|
143
175
|
if (AppState.currentState === 'active') {
|
|
144
176
|
run();
|
|
177
|
+
return undefined;
|
|
145
178
|
}
|
|
146
179
|
const sub = AppState.addEventListener(
|
|
147
180
|
'change',
|
|
@@ -159,49 +192,42 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
159
192
|
return () => {
|
|
160
193
|
// cancel any notifee displayed notification when the call has transitioned out of ringing
|
|
161
194
|
// NOTE: cancels only the non fg service notifications
|
|
162
|
-
|
|
163
|
-
notifeeLib.default.cancelDisplayedNotification(activeCallCid);
|
|
164
|
-
}
|
|
195
|
+
notifeeLib.default.cancelDisplayedNotification(activeCallCid);
|
|
165
196
|
};
|
|
166
197
|
} else if (
|
|
167
198
|
callingState === CallingState.IDLE ||
|
|
168
199
|
callingState === CallingState.LEFT
|
|
169
200
|
) {
|
|
170
201
|
if (foregroundServiceStartedRef.current) {
|
|
171
|
-
|
|
202
|
+
callToPassToForegroundService.current = undefined;
|
|
172
203
|
// stop foreground service when the call is not active
|
|
173
|
-
|
|
204
|
+
notifeeLib.default.stopForegroundService();
|
|
174
205
|
foregroundServiceStartedRef.current = false;
|
|
175
206
|
} else {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
207
|
+
notifeeLib.default
|
|
208
|
+
.getDisplayedNotifications()
|
|
209
|
+
.then((displayedNotifications) => {
|
|
210
|
+
const activeCallNotification = displayedNotifications.find(
|
|
211
|
+
(notification) => notification.id === activeCallCid,
|
|
212
|
+
);
|
|
213
|
+
if (activeCallNotification) {
|
|
214
|
+
callToPassToForegroundService.current = undefined;
|
|
215
|
+
// this means that we have a incoming call notification shown as foreground service and we must stop it
|
|
216
|
+
notifeeLib.default.stopForegroundService();
|
|
217
|
+
}
|
|
218
|
+
});
|
|
189
219
|
}
|
|
190
220
|
}
|
|
191
221
|
return undefined;
|
|
192
|
-
}, [
|
|
193
|
-
activeCallCid,
|
|
194
|
-
callingState,
|
|
195
|
-
shouldStartForegroundService,
|
|
196
|
-
isRingingCall,
|
|
197
|
-
]);
|
|
222
|
+
}, [activeCallCid, callingState, shouldStartForegroundService]);
|
|
198
223
|
|
|
199
224
|
useEffect(() => {
|
|
200
225
|
return () => {
|
|
201
226
|
// stop foreground service when this effect is unmounted
|
|
202
227
|
if (foregroundServiceStartedRef.current) {
|
|
203
|
-
|
|
204
|
-
|
|
228
|
+
if (!notifeeLib) return;
|
|
229
|
+
callToPassToForegroundService.current = undefined;
|
|
230
|
+
notifeeLib.default.stopForegroundService();
|
|
205
231
|
foregroundServiceStartedRef.current = false;
|
|
206
232
|
}
|
|
207
233
|
};
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { registerGlobals } from '@stream-io/react-native-webrtc';
|
|
|
9
9
|
import Logger from '@stream-io/react-native-webrtc/src/Logger';
|
|
10
10
|
import { Platform } from 'react-native';
|
|
11
11
|
import { registerSDKGlobals } from './utils/internal/registerSDKGlobals';
|
|
12
|
-
import './utils/keepCallAliveHeadlessTask';
|
|
13
12
|
|
|
14
13
|
// We're registering globals, because our video JS client is serving SDKs that use browser based webRTC functions.
|
|
15
14
|
// This will result in creation of 2 global objects: `window` and `navigator`
|