@stream-io/video-react-native-sdk 1.28.3 → 1.29.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/AndroidManifest.xml +8 -1
- package/android/src/main/AndroidManifestNew.xml +11 -0
- package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +42 -5
- package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +70 -6
- package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +6 -4
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +83 -0
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +134 -0
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js +3 -1
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js +5 -2
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
- package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js +6 -3
- package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
- package/dist/commonjs/components/Participant/FloatingParticipantView/index.js +3 -1
- package/dist/commonjs/components/Participant/FloatingParticipantView/index.js.map +1 -1
- package/dist/commonjs/components/Participant/ParticipantView/ParticipantView.js +3 -1
- package/dist/commonjs/components/Participant/ParticipantView/ParticipantView.js.map +1 -1
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/index.js +3 -2
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/index.js.map +1 -1
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +216 -0
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +64 -97
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/modules/call-manager/CallManager.js +26 -0
- package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
- package/dist/commonjs/providers/StreamCall/index.js +6 -6
- package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +33 -21
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/audioSessionPromise.js +46 -0
- package/dist/commonjs/utils/internal/audioSessionPromise.js.map +1 -0
- package/dist/commonjs/utils/internal/callingx.js +84 -0
- package/dist/commonjs/utils/internal/callingx.js.map +1 -0
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +52 -3
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +48 -0
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +1 -0
- package/dist/commonjs/utils/push/android.js +145 -200
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/ios.js +16 -34
- package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js +1 -20
- package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/commonjs/utils/push/internal/utils.js +17 -1
- 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 +97 -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/CallLayout/CallParticipantsGrid.js +3 -1
- package/dist/module/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
- package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js +5 -2
- package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
- package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js +6 -3
- package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
- package/dist/module/components/Participant/FloatingParticipantView/index.js +3 -1
- package/dist/module/components/Participant/FloatingParticipantView/index.js.map +1 -1
- package/dist/module/components/Participant/ParticipantView/ParticipantView.js +3 -1
- package/dist/module/components/Participant/ParticipantView/ParticipantView.js.map +1 -1
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/index.js +3 -2
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/index.js.map +1 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +209 -0
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +66 -99
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/modules/call-manager/CallManager.js +26 -0
- package/dist/module/modules/call-manager/CallManager.js.map +1 -1
- package/dist/module/providers/StreamCall/index.js +6 -6
- package/dist/module/providers/StreamCall/index.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +33 -21
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/audioSessionPromise.js +39 -0
- package/dist/module/utils/internal/audioSessionPromise.js.map +1 -0
- package/dist/module/utils/internal/callingx.js +75 -0
- package/dist/module/utils/internal/callingx.js.map +1 -0
- package/dist/module/utils/internal/registerSDKGlobals.js +53 -4
- 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 +147 -202
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/ios.js +16 -34
- package/dist/module/utils/push/internal/ios.js.map +1 -1
- package/dist/module/utils/push/internal/rxSubjects.js +0 -19
- package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/module/utils/push/internal/utils.js +14 -0
- 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 +91 -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/CallLayout/CallParticipantsGrid.d.ts +2 -2
- package/dist/typescript/components/Call/CallLayout/CallParticipantsGrid.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallLayout/CallParticipantsSpotlight.d.ts +2 -2
- package/dist/typescript/components/Call/CallLayout/CallParticipantsSpotlight.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallParticipantsList/CallParticipantsList.d.ts +6 -1
- package/dist/typescript/components/Call/CallParticipantsList/CallParticipantsList.d.ts.map +1 -1
- package/dist/typescript/components/Participant/FloatingParticipantView/index.d.ts +2 -2
- package/dist/typescript/components/Participant/FloatingParticipantView/index.d.ts.map +1 -1
- package/dist/typescript/components/Participant/ParticipantView/ParticipantView.d.ts +6 -1
- package/dist/typescript/components/Participant/ParticipantView/ParticipantView.d.ts.map +1 -1
- package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/index.d.ts +2 -2
- package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/index.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +5 -0
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -0
- package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +1 -0
- package/dist/typescript/index.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/CallManager.d.ts +5 -0
- package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +20 -2
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +54 -29
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/audioSessionPromise.d.ts +16 -0
- package/dist/typescript/utils/internal/audioSessionPromise.d.ts.map +1 -0
- package/dist/typescript/utils/internal/callingx.d.ts +13 -0
- package/dist/typescript/utils/internal/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 -12
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/utils.d.ts +4 -0
- 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 +20 -5
- package/ios/StreamVideoReactNative.h +7 -4
- package/ios/StreamVideoReactNative.m +191 -82
- package/package.json +10 -15
- package/src/components/Call/CallLayout/CallParticipantsGrid.tsx +3 -1
- package/src/components/Call/CallLayout/CallParticipantsSpotlight.tsx +4 -1
- package/src/components/Call/CallParticipantsList/CallParticipantsList.tsx +8 -0
- package/src/components/Participant/FloatingParticipantView/index.tsx +3 -1
- package/src/components/Participant/ParticipantView/ParticipantView.tsx +7 -0
- package/src/components/Participant/ParticipantView/VideoRenderer/index.tsx +7 -2
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +307 -0
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +94 -120
- package/src/index.ts +1 -0
- package/src/modules/call-manager/CallManager.ts +36 -0
- package/src/modules/call-manager/native-module.d.ts +7 -0
- package/src/providers/StreamCall/index.tsx +6 -6
- package/src/utils/StreamVideoRN/index.ts +40 -30
- package/src/utils/StreamVideoRN/types.ts +56 -29
- package/src/utils/internal/audioSessionPromise.ts +39 -0
- package/src/utils/internal/callingx.ts +108 -0
- package/src/utils/internal/registerSDKGlobals.ts +47 -4
- package/src/utils/keepCallAliveHeadlessTask.ts +54 -0
- package/src/utils/push/android.ts +223 -308
- package/src/utils/push/internal/ios.ts +25 -46
- package/src/utils/push/internal/rxSubjects.ts +0 -29
- package/src/utils/push/internal/utils.ts +25 -0
- package/src/utils/push/ios.ts +1 -6
- package/src/utils/push/libs/callingx.ts +90 -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 +117 -0
- package/src/utils/push/setupIosVoipPushEvents.ts +11 -7
- package/src/version.ts +1 -1
- package/CHANGELOG.md +0 -3103
- 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/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/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/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/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,307 @@
|
|
|
1
|
+
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
2
|
+
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
3
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { getCallDisplayName } from '../../utils/internal/callingx';
|
|
5
|
+
import { getCallingxLibIfAvailable } from '../../utils/push/libs/callingx';
|
|
6
|
+
|
|
7
|
+
const logger = videoLoggerSystem.getLogger(
|
|
8
|
+
'Callingx - useCallingExpWithCallingStateEffect',
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
//calling state methods are not exhaustive, so we need to add more methods to cover different cases
|
|
12
|
+
const canActivateCall = (
|
|
13
|
+
prevState: CallingState | undefined,
|
|
14
|
+
currentState: CallingState | undefined,
|
|
15
|
+
) => {
|
|
16
|
+
if (!prevState && !currentState) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const isJoined = (state: CallingState | undefined) => {
|
|
21
|
+
if (!state) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return state === CallingState.JOINING || state === CallingState.JOINED;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return !isJoined(prevState) && isJoined(currentState);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const canEndCall = (
|
|
32
|
+
prevState: CallingState | undefined,
|
|
33
|
+
currentState: CallingState | undefined,
|
|
34
|
+
) => {
|
|
35
|
+
if (!prevState && !currentState) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
(prevState === CallingState.JOINED ||
|
|
41
|
+
prevState === CallingState.JOINING ||
|
|
42
|
+
prevState === CallingState.RINGING ||
|
|
43
|
+
prevState === CallingState.RECONNECTING ||
|
|
44
|
+
prevState === CallingState.MIGRATING ||
|
|
45
|
+
prevState === CallingState.OFFLINE) &&
|
|
46
|
+
(currentState === CallingState.LEFT ||
|
|
47
|
+
currentState === CallingState.RECONNECTING_FAILED ||
|
|
48
|
+
currentState === CallingState.IDLE)
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This hook is used to inform sync call state with CallKit/Telecom (i.e. start call, end call, mute/unmute call).
|
|
54
|
+
*/
|
|
55
|
+
export const useCallingExpWithCallingStateEffect = () => {
|
|
56
|
+
const {
|
|
57
|
+
useCallCallingState,
|
|
58
|
+
// useMicrophoneState,
|
|
59
|
+
useParticipants,
|
|
60
|
+
useCallMembers,
|
|
61
|
+
} = useCallStateHooks();
|
|
62
|
+
|
|
63
|
+
const activeCall = useCall();
|
|
64
|
+
const callingState = useCallCallingState();
|
|
65
|
+
// const { isMute, microphone } = useMicrophoneState();
|
|
66
|
+
const callMembers = useCallMembers();
|
|
67
|
+
const participants = useParticipants();
|
|
68
|
+
|
|
69
|
+
const prevState = useRef<CallingState | undefined>(undefined);
|
|
70
|
+
|
|
71
|
+
const activeCallCid = activeCall?.cid;
|
|
72
|
+
const isIncomingCall = activeCall?.ringing && !activeCall?.isCreatedByMe;
|
|
73
|
+
const isOutcomingCall = activeCall?.ringing && activeCall?.isCreatedByMe;
|
|
74
|
+
const currentUserId = activeCall?.currentUserId;
|
|
75
|
+
const isVideoCall = activeCall?.state.settings?.video?.enabled ?? false;
|
|
76
|
+
|
|
77
|
+
const callDisplayName = useMemo(
|
|
78
|
+
() => getCallDisplayName(callMembers, participants, currentUserId),
|
|
79
|
+
[callMembers, participants, currentUserId],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
return () => {
|
|
84
|
+
const callingx = getCallingxLibIfAvailable();
|
|
85
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
90
|
+
if (!isCallRegistered) {
|
|
91
|
+
logger.debug(
|
|
92
|
+
`No active call cid to end in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
|
|
93
|
+
);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
//if incoming stream call was unmounted, we need to end the call in CallKit/Telecom
|
|
97
|
+
logger.debug(`Ending call in callingx: ${activeCallCid}`);
|
|
98
|
+
callingx
|
|
99
|
+
.endCallWithReason(activeCallCid, 'local')
|
|
100
|
+
.catch((error: unknown) => {
|
|
101
|
+
logger.error(
|
|
102
|
+
`Error ending call in callingx: ${activeCallCid}`,
|
|
103
|
+
error,
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
}, [activeCallCid]);
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
const callingx = getCallingxLibIfAvailable();
|
|
111
|
+
if (
|
|
112
|
+
!callingx?.isSetup ||
|
|
113
|
+
!activeCallCid ||
|
|
114
|
+
prevState.current === callingState
|
|
115
|
+
) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//tells if call is registered in CallKit/Telecom
|
|
120
|
+
const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
121
|
+
logger.debug(
|
|
122
|
+
`useEffect: ${activeCallCid} isCallRegistered: ${isCallRegistered}
|
|
123
|
+
isIncomingCall: ${isIncomingCall} isOutcomingCall: ${isOutcomingCall}
|
|
124
|
+
prevState: ${prevState.current}, currentState: ${callingState}
|
|
125
|
+
isOngoingCallsEnabled: ${callingx.isOngoingCallsEnabled}`,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
if (
|
|
129
|
+
isIncomingCall &&
|
|
130
|
+
isCallRegistered &&
|
|
131
|
+
canActivateCall(prevState.current, callingState)
|
|
132
|
+
) {
|
|
133
|
+
logger.debug(`Should accept call in callingx: ${activeCallCid}`);
|
|
134
|
+
callingx.answerIncomingCall(activeCallCid).catch((error: unknown) => {
|
|
135
|
+
logger.error(
|
|
136
|
+
`Error answering call in callingx: ${activeCallCid}`,
|
|
137
|
+
error,
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
} else if (
|
|
141
|
+
(isOutcomingCall || callingx.isOngoingCallsEnabled) &&
|
|
142
|
+
isCallRegistered &&
|
|
143
|
+
canActivateCall(prevState.current, callingState)
|
|
144
|
+
) {
|
|
145
|
+
logger.debug(`Should set call active in callingx: ${activeCallCid}`);
|
|
146
|
+
callingx.setCurrentCallActive(activeCallCid);
|
|
147
|
+
} else if (
|
|
148
|
+
isCallRegistered &&
|
|
149
|
+
canEndCall(prevState.current, callingState)
|
|
150
|
+
) {
|
|
151
|
+
//in case call was registered as incoming and state changed to "not joined", we need to end the call and clear rxjs subject
|
|
152
|
+
logger.debug(`Should end call in callingx: ${activeCallCid}`);
|
|
153
|
+
//TODO: think about sending appropriate reason for end call
|
|
154
|
+
callingx
|
|
155
|
+
.endCallWithReason(activeCallCid, 'local')
|
|
156
|
+
.catch((error: unknown) => {
|
|
157
|
+
logger.error(
|
|
158
|
+
`Error ending call in callingx: ${activeCallCid}`,
|
|
159
|
+
error,
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
prevState.current = callingState;
|
|
165
|
+
}, [
|
|
166
|
+
activeCallCid,
|
|
167
|
+
callingState,
|
|
168
|
+
callDisplayName,
|
|
169
|
+
isIncomingCall,
|
|
170
|
+
isOutcomingCall,
|
|
171
|
+
isVideoCall,
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
const callingx = getCallingxLibIfAvailable();
|
|
176
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
181
|
+
if (!isCallRegistered) {
|
|
182
|
+
logger.debug(
|
|
183
|
+
`No active call cid to update callingx: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
|
|
184
|
+
);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
callingx.updateDisplay(activeCallCid, activeCallCid, callDisplayName);
|
|
189
|
+
}, [activeCallCid, callDisplayName]);
|
|
190
|
+
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
const callingx = getCallingxLibIfAvailable();
|
|
193
|
+
if (!callingx?.isSetup || !activeCallCid || !isIncomingCall) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
let isUnsubscribed = false;
|
|
198
|
+
const subscription = callingx.addEventListener(
|
|
199
|
+
'didDisplayIncomingCall',
|
|
200
|
+
(event: { callId: string }) => {
|
|
201
|
+
if (event.callId === activeCallCid) {
|
|
202
|
+
//we need to report the call as answered only if user accepts the call from the app UI and push notification was delivered after that
|
|
203
|
+
const _callingState = activeCall?.state.callingState;
|
|
204
|
+
const shouldSkip =
|
|
205
|
+
_callingState !== CallingState.JOINING &&
|
|
206
|
+
_callingState !== CallingState.JOINED &&
|
|
207
|
+
_callingState !== CallingState.RECONNECTING &&
|
|
208
|
+
_callingState !== CallingState.MIGRATING;
|
|
209
|
+
if (shouldSkip) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
logger.debug(
|
|
214
|
+
`Reporting the incoming call as answered in callingx as already join() calledin the app: ${activeCallCid}`,
|
|
215
|
+
);
|
|
216
|
+
callingx
|
|
217
|
+
.answerIncomingCall(activeCallCid)
|
|
218
|
+
.catch((error: unknown) => {
|
|
219
|
+
logger.error(
|
|
220
|
+
`Error answering call in callingx: ${activeCallCid}`,
|
|
221
|
+
error,
|
|
222
|
+
);
|
|
223
|
+
})
|
|
224
|
+
.finally(() => {
|
|
225
|
+
subscription.remove();
|
|
226
|
+
isUnsubscribed = true;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
return () => {
|
|
233
|
+
if (!isUnsubscribed) {
|
|
234
|
+
subscription.remove();
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}, [activeCall, activeCallCid, isIncomingCall]);
|
|
238
|
+
|
|
239
|
+
// useEffect(() => {
|
|
240
|
+
// const callingx = getCallingxLibIfAvailable();
|
|
241
|
+
// if (!callingx?.isSetup || !activeCallCid) {
|
|
242
|
+
// return;
|
|
243
|
+
// }
|
|
244
|
+
|
|
245
|
+
// const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
246
|
+
// if (!isCallRegistered) {
|
|
247
|
+
// logger.debug(
|
|
248
|
+
// `No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
|
|
249
|
+
// );
|
|
250
|
+
// return;
|
|
251
|
+
// }
|
|
252
|
+
|
|
253
|
+
// callingx.setMutedCall(activeCallCid, isMute);
|
|
254
|
+
// }, [activeCallCid, isMute]);
|
|
255
|
+
|
|
256
|
+
// useEffect(() => {
|
|
257
|
+
// const callingx = getCallingxLibIfAvailable();
|
|
258
|
+
// if (!callingx?.isSetup || !activeCallCid) {
|
|
259
|
+
// return;
|
|
260
|
+
// }
|
|
261
|
+
|
|
262
|
+
// const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
263
|
+
// if (!isCallRegistered) {
|
|
264
|
+
// logger.debug(
|
|
265
|
+
// `No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
|
|
266
|
+
// );
|
|
267
|
+
// return;
|
|
268
|
+
// }
|
|
269
|
+
|
|
270
|
+
// //listen to mic toggle events from CallKit/Telecom and update stream call microphone state
|
|
271
|
+
// const subscription = callingx.addEventListener(
|
|
272
|
+
// 'didPerformSetMutedCallAction',
|
|
273
|
+
// async (event: { callId: string; muted: boolean }) => {
|
|
274
|
+
// const { callId, muted } = event;
|
|
275
|
+
|
|
276
|
+
// if (callId === activeCallCid) {
|
|
277
|
+
// const isCurrentlyMuted =
|
|
278
|
+
// RxUtils.getCurrentValue(microphone.state.status$) === 'disabled';
|
|
279
|
+
// if (isCurrentlyMuted === muted) {
|
|
280
|
+
// logger.debug(
|
|
281
|
+
// `Mic toggle is already in the desired state: ${muted} for call: ${activeCallCid}`,
|
|
282
|
+
// );
|
|
283
|
+
// //this check prevents mic toggle when state change was initiated from client and not from CallKit/Telecom
|
|
284
|
+
// return;
|
|
285
|
+
// }
|
|
286
|
+
|
|
287
|
+
// try {
|
|
288
|
+
// if (muted) {
|
|
289
|
+
// await microphone.disable();
|
|
290
|
+
// } else {
|
|
291
|
+
// await microphone.enable();
|
|
292
|
+
// }
|
|
293
|
+
// } catch (error: unknown) {
|
|
294
|
+
// logger.error(
|
|
295
|
+
// `Error toggling mic in calling exp: ${activeCallCid}`,
|
|
296
|
+
// error,
|
|
297
|
+
// );
|
|
298
|
+
// }
|
|
299
|
+
// }
|
|
300
|
+
// },
|
|
301
|
+
// );
|
|
302
|
+
|
|
303
|
+
// return () => {
|
|
304
|
+
// subscription.remove();
|
|
305
|
+
// };
|
|
306
|
+
// }, [activeCallCid, microphone, isOutcomingCall, isIncomingCall]);
|
|
307
|
+
};
|
|
@@ -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
|
};
|