@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,75 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* Internal utils for callingx library usage from video-client.
|
|
3
|
+
* See @./registerSDKGlobals.ts for more usage details.
|
|
4
|
+
*/
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
import { getCallingxLibIfAvailable } from '../push/libs/callingx';
|
|
7
|
+
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
8
|
+
import { waitForAudioSessionActivation } from './audioSessionPromise';
|
|
9
|
+
const CallingxModule = getCallingxLibIfAvailable();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gets the call display name. To be used for display in native call screen.
|
|
13
|
+
*/
|
|
14
|
+
export function getCallDisplayName(callMembers, participants, currentUserId) {
|
|
15
|
+
if (!callMembers || !participants || !currentUserId) {
|
|
16
|
+
return 'Call';
|
|
17
|
+
}
|
|
18
|
+
let names = [];
|
|
19
|
+
if (callMembers.length > 0) {
|
|
20
|
+
// for ringing calls, members array contains all call members from the very early state and participants array is empty in the beginning
|
|
21
|
+
names = callMembers.filter(member => member.user.id !== currentUserId).map(member => member.user.name).filter(name => name !== undefined);
|
|
22
|
+
} else if (participants.length > 0) {
|
|
23
|
+
// for non-ringing calls, members array is empty and we rely on participants array there
|
|
24
|
+
names = participants.filter(participant => participant.userId !== currentUserId).map(participant => participant.name).filter(Boolean);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// if no names are found, we use the name of the current user
|
|
28
|
+
if (names.length === 0) {
|
|
29
|
+
names = [participants.find(participant => participant.userId === currentUserId)?.name ?? 'Call'];
|
|
30
|
+
}
|
|
31
|
+
return names.sort().join(', ');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Starts the call in the callingx library.
|
|
36
|
+
* Must be called for all outgoing calls
|
|
37
|
+
* and optionally for non-ringing calls when ongoing calls are enabled.
|
|
38
|
+
*/
|
|
39
|
+
export async function startCallingxCall(call) {
|
|
40
|
+
if (!CallingxModule || CallingxModule.isCallRegistered(call.cid)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const isOutcomingCall = call.ringing && call.isCreatedByMe;
|
|
44
|
+
if (isOutcomingCall || !call.ringing && CallingxModule.isOngoingCallsEnabled) {
|
|
45
|
+
const callDisplayName = getCallDisplayName(call.state.members, call.state.participants, call.currentUserId);
|
|
46
|
+
try {
|
|
47
|
+
await CallingxModule.startCall(call.cid,
|
|
48
|
+
// unique id for call
|
|
49
|
+
call.id,
|
|
50
|
+
// phone number for display in dialer (we use call id as phone number)
|
|
51
|
+
callDisplayName,
|
|
52
|
+
// display name for display in call screen
|
|
53
|
+
call.state.settings?.video?.enabled ?? false // is video call?
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Wait for audio session activation on iOS only
|
|
57
|
+
if (Platform.OS === 'ios') {
|
|
58
|
+
await waitForAudioSessionActivation();
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
videoLoggerSystem.getLogger('startCallingxCall').error(`Error starting call in callingx: ${call.cid}`, error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function endCallingxCall(call) {
|
|
66
|
+
if (!CallingxModule || !CallingxModule.isCallRegistered(call.cid)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
await CallingxModule.endCallWithReason(call.cid, 'local');
|
|
71
|
+
} catch (error) {
|
|
72
|
+
videoLoggerSystem.getLogger('endCallingxCall').error(`Error ending call in callingx: ${call.cid}`, error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=callingx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","getCallingxLibIfAvailable","videoLoggerSystem","waitForAudioSessionActivation","CallingxModule","getCallDisplayName","callMembers","participants","currentUserId","names","length","filter","member","user","id","map","name","undefined","participant","userId","Boolean","find","sort","join","startCallingxCall","call","isCallRegistered","cid","isOutcomingCall","ringing","isCreatedByMe","isOngoingCallsEnabled","callDisplayName","state","members","startCall","settings","video","enabled","OS","error","getLogger","endCallingxCall","endCallWithReason"],"sourceRoot":"../../../../src","sources":["utils/internal/callingx.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,17 +1,66 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import { getCallingxLibIfAvailable } from '../push/libs/callingx';
|
|
3
|
+
import { endCallingxCall, startCallingxCall } from './callingx';
|
|
2
4
|
const StreamInCallManagerNativeModule = NativeModules.StreamInCallManager;
|
|
5
|
+
const CallingxModule = getCallingxLibIfAvailable();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Checks if StreamInCallManager should be bypassed because CallKit is handling
|
|
9
|
+
* the audio session via CallingX.
|
|
10
|
+
*
|
|
11
|
+
* On iOS, when CallingX is set up and has a registered call, the audio session
|
|
12
|
+
* is managed by CallKit through CallingxImpl.swift.
|
|
13
|
+
* In this case, StreamInCallManager should not run to avoid conflicting audio
|
|
14
|
+
* session configurations.
|
|
15
|
+
*/
|
|
16
|
+
const shouldBypassForCallKit = ({
|
|
17
|
+
isRingingTypeCall
|
|
18
|
+
}) => {
|
|
19
|
+
if (Platform.OS !== 'ios') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (!CallingxModule) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const bypass = CallingxModule.isSetup && (isRingingTypeCall || CallingxModule.isOngoingCallsEnabled);
|
|
26
|
+
return bypass;
|
|
27
|
+
};
|
|
3
28
|
const streamRNVideoSDKGlobals = {
|
|
29
|
+
callingX: {
|
|
30
|
+
startCall: startCallingxCall,
|
|
31
|
+
endCall: endCallingxCall
|
|
32
|
+
},
|
|
4
33
|
callManager: {
|
|
5
34
|
setup: ({
|
|
6
|
-
defaultDevice
|
|
35
|
+
defaultDevice,
|
|
36
|
+
isRingingTypeCall
|
|
7
37
|
}) => {
|
|
38
|
+
if (shouldBypassForCallKit({
|
|
39
|
+
isRingingTypeCall
|
|
40
|
+
})) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
8
43
|
StreamInCallManagerNativeModule.setDefaultAudioDeviceEndpointType(defaultDevice);
|
|
9
44
|
StreamInCallManagerNativeModule.setup();
|
|
10
45
|
},
|
|
11
|
-
start: (
|
|
46
|
+
start: ({
|
|
47
|
+
isRingingTypeCall
|
|
48
|
+
}) => {
|
|
49
|
+
if (shouldBypassForCallKit({
|
|
50
|
+
isRingingTypeCall
|
|
51
|
+
})) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
12
54
|
StreamInCallManagerNativeModule.start();
|
|
13
55
|
},
|
|
14
|
-
stop: (
|
|
56
|
+
stop: ({
|
|
57
|
+
isRingingTypeCall
|
|
58
|
+
}) => {
|
|
59
|
+
if (shouldBypassForCallKit({
|
|
60
|
+
isRingingTypeCall
|
|
61
|
+
})) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
15
64
|
StreamInCallManagerNativeModule.stop();
|
|
16
65
|
}
|
|
17
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","StreamInCallManagerNativeModule","StreamInCallManager","streamRNVideoSDKGlobals","callManager","setup","defaultDevice","setDefaultAudioDeviceEndpointType","start","stop","registerSDKGlobals","global","streamRNVideoSDK"],"sourceRoot":"../../../../src","sources":["utils/internal/registerSDKGlobals.ts"],"mappings":"AACA,SAASA,aAAa,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","getCallingxLibIfAvailable","endCallingxCall","startCallingxCall","StreamInCallManagerNativeModule","StreamInCallManager","CallingxModule","shouldBypassForCallKit","isRingingTypeCall","OS","bypass","isSetup","isOngoingCallsEnabled","streamRNVideoSDKGlobals","callingX","startCall","endCall","callManager","setup","defaultDevice","setDefaultAudioDeviceEndpointType","start","stop","registerSDKGlobals","global","streamRNVideoSDK"],"sourceRoot":"../../../../src","sources":["utils/internal/registerSDKGlobals.ts"],"mappings":"AACA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,yBAAyB,QAAQ,uBAAuB;AACjE,SAASC,eAAe,EAAEC,iBAAiB,QAAQ,YAAY;AAE/D,MAAMC,+BAA+B,GAAGL,aAAa,CAACM,mBAAmB;AAEzE,MAAMC,cAAc,GAAGL,yBAAyB,CAAC,CAAC;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,sBAAsB,GAAGA,CAAC;EAC9BC;AAGF,CAAC,KAAc;EACb,IAAIR,QAAQ,CAACS,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO,KAAK;EACd;EACA,IAAI,CAACH,cAAc,EAAE;IACnB,OAAO,KAAK;EACd;EACA,MAAMI,MAAM,GACVJ,cAAc,CAACK,OAAO,KACrBH,iBAAiB,IAAIF,cAAc,CAACM,qBAAqB,CAAC;EAC7D,OAAOF,MAAM;AACf,CAAC;AAED,MAAMG,uBAAgD,GAAG;EACvDC,QAAQ,EAAE;IACRC,SAAS,EAAEZ,iBAAiB;IAC5Ba,OAAO,EAAEd;EACX,CAAC;EACDe,WAAW,EAAE;IACXC,KAAK,EAAEA,CAAC;MAAEC,aAAa;MAAEX;IAAkB,CAAC,KAAK;MAC/C,IAAID,sBAAsB,CAAC;QAAEC;MAAkB,CAAC,CAAC,EAAE;QACjD;MACF;MACAJ,+BAA+B,CAACgB,iCAAiC,CAC/DD,aACF,CAAC;MACDf,+BAA+B,CAACc,KAAK,CAAC,CAAC;IACzC,CAAC;IACDG,KAAK,EAAEA,CAAC;MAAEb;IAAkB,CAAC,KAAK;MAChC,IAAID,sBAAsB,CAAC;QAAEC;MAAkB,CAAC,CAAC,EAAE;QACjD;MACF;MACAJ,+BAA+B,CAACiB,KAAK,CAAC,CAAC;IACzC,CAAC;IACDC,IAAI,EAAEA,CAAC;MAAEd;IAAkB,CAAC,KAAK;MAC/B,IAAID,sBAAsB,CAAC;QAAEC;MAAkB,CAAC,CAAC,EAAE;QACjD;MACF;MACAJ,+BAA+B,CAACkB,IAAI,CAAC,CAAC;IACxC;EACF;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,IAAI,CAACC,MAAM,CAACC,gBAAgB,EAAE;IAC5BD,MAAM,CAACC,gBAAgB,GAAGZ,uBAAuB;EACnD;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AppRegistry, Platform } from 'react-native';
|
|
2
|
+
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
3
|
+
import { StreamVideoRN } from './StreamVideoRN';
|
|
4
|
+
export const KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = 'StreamVideoKeepCallAlive';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The keep-alive headless task needs access to the active `Call` instance.
|
|
8
|
+
* The keep-alive hook will set this reference before starting the native service.
|
|
9
|
+
*/
|
|
10
|
+
export const keepCallAliveCallRef = {
|
|
11
|
+
current: undefined
|
|
12
|
+
};
|
|
13
|
+
function registerKeepCallAliveHeadlessTaskOnce() {
|
|
14
|
+
if (Platform.OS !== 'android') return;
|
|
15
|
+
AppRegistry.registerHeadlessTask(KEEP_CALL_ALIVE_HEADLESS_TASK_NAME, () => async data => {
|
|
16
|
+
const logger = videoLoggerSystem.getLogger('KEEP_CALL_ALIVE_HEADLESS_TASK');
|
|
17
|
+
const callCid = data?.callCid;
|
|
18
|
+
const call = keepCallAliveCallRef.current;
|
|
19
|
+
if (!call) {
|
|
20
|
+
logger.warn('No active call instance available for keep-alive task; skipping.', {
|
|
21
|
+
callCid
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (callCid && call.cid && call.cid !== callCid) {
|
|
26
|
+
logger.warn('Keep-alive task callCid does not match active call; skipping.', {
|
|
27
|
+
callCid,
|
|
28
|
+
activeCallCid: call.cid
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const config = StreamVideoRN.getConfig();
|
|
33
|
+
const taskToRun = config.foregroundService.android.taskToRun;
|
|
34
|
+
try {
|
|
35
|
+
await taskToRun(call);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
logger.error('Keep-alive headless task failed', e);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
registerKeepCallAliveHeadlessTaskOnce();
|
|
42
|
+
//# sourceMappingURL=keepCallAliveHeadlessTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AppRegistry","Platform","videoLoggerSystem","StreamVideoRN","KEEP_CALL_ALIVE_HEADLESS_TASK_NAME","keepCallAliveCallRef","current","undefined","registerKeepCallAliveHeadlessTaskOnce","OS","registerHeadlessTask","data","logger","getLogger","callCid","call","warn","cid","activeCallCid","config","getConfig","taskToRun","foregroundService","android","e","error"],"sourceRoot":"../../../src","sources":["utils/keepCallAliveHeadlessTask.ts"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,cAAc;AAEpD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,MAAMC,kCAAkC,GAAG,0BAA0B;;AAE5E;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAmD,GAAG;EACjEC,OAAO,EAAEC;AACX,CAAC;AAED,SAASC,qCAAqCA,CAAA,EAAG;EAC/C,IAAIP,QAAQ,CAACQ,EAAE,KAAK,SAAS,EAAE;EAE/BT,WAAW,CAACU,oBAAoB,CAC9BN,kCAAkC,EAClC,MAAM,MAAOO,IAAsC,IAAK;IACtD,MAAMC,MAAM,GAAGV,iBAAiB,CAACW,SAAS,CACxC,+BACF,CAAC;IACD,MAAMC,OAAO,GAAGH,IAAI,EAAEG,OAAO;IAE7B,MAAMC,IAAI,GAAGV,oBAAoB,CAACC,OAAO;IACzC,IAAI,CAACS,IAAI,EAAE;MACTH,MAAM,CAACI,IAAI,CACT,kEAAkE,EAClE;QAAEF;MAAQ,CACZ,CAAC;MACD;IACF;IACA,IAAIA,OAAO,IAAIC,IAAI,CAACE,GAAG,IAAIF,IAAI,CAACE,GAAG,KAAKH,OAAO,EAAE;MAC/CF,MAAM,CAACI,IAAI,CACT,+DAA+D,EAC/D;QAAEF,OAAO;QAAEI,aAAa,EAAEH,IAAI,CAACE;MAAI,CACrC,CAAC;MACD;IACF;IAEA,MAAME,MAAM,GAAGhB,aAAa,CAACiB,SAAS,CAAC,CAAC;IACxC,MAAMC,SAAS,GAAGF,MAAM,CAACG,iBAAiB,CAACC,OAAO,CAACF,SAAS;IAC5D,IAAI;MACF,MAAMA,SAAS,CAACN,IAAI,CAAC;IACvB,CAAC,CAAC,OAAOS,CAAC,EAAE;MACVZ,MAAM,CAACa,KAAK,CAAC,iCAAiC,EAAED,CAAC,CAAC;IACpD;EACF,CACF,CAAC;AACH;AAEAhB,qCAAqC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
2
2
|
import { AppState, Platform } from 'react-native';
|
|
3
|
-
import { getExpoNotificationsLib, getExpoNotificationsLibNoThrow, getFirebaseMessagingLib, getFirebaseMessagingLibNoThrow,
|
|
4
|
-
import {
|
|
3
|
+
import { getExpoNotificationsLib, getExpoNotificationsLibNoThrow, getFirebaseMessagingLib, getFirebaseMessagingLibNoThrow, getNotifeeLibThrowIfNotInstalledForPush } from './libs';
|
|
4
|
+
import { pushNonRingingCallData$ } from './internal/rxSubjects';
|
|
5
5
|
import { pushUnsubscriptionCallbacks } from './internal/constants';
|
|
6
|
-
import {
|
|
6
|
+
import { canListenToWS, shouldCallBeClosed } from './internal/utils';
|
|
7
7
|
import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
|
|
8
|
-
import { getAndroidDefaultRingtoneUrl } from '../getAndroidDefaultRingtoneUrl';
|
|
9
8
|
import { StreamVideoRN } from '../StreamVideoRN';
|
|
10
|
-
|
|
11
|
-
const DECLINE_CALL_ACTION_ID = 'decline';
|
|
9
|
+
import { getCallingxLib } from './libs/callingx';
|
|
12
10
|
let lastFirebaseToken = {
|
|
13
11
|
token: '',
|
|
14
12
|
userId: ''
|
|
@@ -63,8 +61,7 @@ export async function initAndroidPushToken(client, pushConfig, setUnsubscribeLis
|
|
|
63
61
|
await setDeviceToken(token);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
const messaging = pushConfig.isExpo && !pushConfig.android.incomingCallChannel ? getFirebaseMessagingLibNoThrow(true) : getFirebaseMessagingLib();
|
|
64
|
+
const messaging = pushConfig.isExpo ? getFirebaseMessagingLibNoThrow(true) : getFirebaseMessagingLib();
|
|
68
65
|
if (messaging) {
|
|
69
66
|
logger.debug(`setting firebase token listeners`);
|
|
70
67
|
const unsubscribe = messaging().onTokenRefresh(refreshedToken => setDeviceToken(refreshedToken));
|
|
@@ -78,8 +75,8 @@ export async function initAndroidPushToken(client, pushConfig, setUnsubscribeLis
|
|
|
78
75
|
* Creates notification from the push message data.
|
|
79
76
|
* For Ringing and Non-Ringing calls.
|
|
80
77
|
*/
|
|
78
|
+
|
|
81
79
|
export const firebaseDataHandler = async data => {
|
|
82
|
-
if (Platform.OS !== 'android') return;
|
|
83
80
|
/* Example data from firebase
|
|
84
81
|
"message": {
|
|
85
82
|
"data": {
|
|
@@ -95,174 +92,167 @@ export const firebaseDataHandler = async data => {
|
|
|
95
92
|
// other stuff
|
|
96
93
|
}
|
|
97
94
|
*/
|
|
95
|
+
if (Platform.OS !== 'android') return;
|
|
96
|
+
const logger = videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
98
97
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
99
98
|
if (!pushConfig || !data || data.sender !== 'stream.video') {
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
102
|
-
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
103
|
-
const notifee = notifeeLib.default;
|
|
104
|
-
const settings = await notifee.getNotificationSettings();
|
|
105
|
-
if (settings.authorizationStatus !== 1) {
|
|
106
|
-
const logger = videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
107
|
-
logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
101
|
if (data.type === 'call.ring') {
|
|
111
102
|
const call_cid = data.call_cid;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
const
|
|
103
|
+
if (!call_cid) {
|
|
104
|
+
logger.debug(`call_cid is not provided, skipping the call.ring notification`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const callingx = getCallingxLib();
|
|
108
|
+
await callingx.checkPermissions();
|
|
109
|
+
if (!callingx.isNotificationsAllowed) {
|
|
110
|
+
logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
114
|
+
if (!client) {
|
|
115
|
+
logger.debug(`video client not found, skipping the call.ring notification`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const shouldRejectCallWhenBusy = client['rejectCallWhenBusy'] ?? false;
|
|
119
|
+
if (callingx.hasRegisteredCall() && shouldRejectCallWhenBusy) {
|
|
120
|
+
logger.debug(`registered call found, skipping the call.ring notification`);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
123
|
const asForegroundService = canListenToWS();
|
|
124
|
+
const callerName = data.created_by_display_name;
|
|
125
|
+
const hasVideo = data.video === 'true';
|
|
124
126
|
if (asForegroundService) {
|
|
125
127
|
// Listen to call events from WS through fg service
|
|
126
128
|
// note: this will replace the current empty fg service runner
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
129
|
+
//we need to start service (e.g. by calling display incoming call) and than launch bg task, consider making those steps independent
|
|
130
|
+
callingx.registerBackgroundTask((_, stopTask) => {
|
|
131
|
+
return new Promise(resolve => {
|
|
132
|
+
const finishBackgroundTask = () => {
|
|
133
|
+
callingx.log(`Finishing background task for callCid: ${call_cid}`, 'debug');
|
|
134
|
+
resolve(undefined);
|
|
135
|
+
stopTask();
|
|
136
|
+
};
|
|
137
|
+
(async () => {
|
|
138
|
+
try {
|
|
139
|
+
const _client = await pushConfig.createStreamVideoClient();
|
|
140
|
+
if (!_client) {
|
|
141
|
+
logger.debug(`Closing fg service as there is no client to create from push config`);
|
|
142
|
+
finishBackgroundTask();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const callFromPush = await _client.onRingingCall(call_cid);
|
|
146
|
+
if (shouldCallBeClosed(callFromPush, data)) {
|
|
147
|
+
logger.debug(`Closing fg service callCid: ${call_cid} shouldCallBeClosed`);
|
|
148
|
+
finishBackgroundTask();
|
|
149
|
+
callingx.log(`Ending call with callCid: ${call_cid} shouldCallBeClosed`, 'debug');
|
|
150
|
+
//TODO: think about sending appropriate reason for end call
|
|
151
|
+
callingx.endCallWithReason(call_cid, 'remote');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const unsubscribeFunctions = [];
|
|
155
|
+
// check if service needs to be closed if accept/decline event was done on another device
|
|
156
|
+
const unsubscribe = callFromPush.on('all', event => {
|
|
157
|
+
const _canListenToWS = canListenToWS();
|
|
158
|
+
if (!_canListenToWS) {
|
|
159
|
+
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, {
|
|
160
|
+
event
|
|
161
|
+
});
|
|
162
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
163
|
+
finishBackgroundTask();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (shouldCallBeClosed(callFromPush, data)) {
|
|
167
|
+
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed`, {
|
|
168
|
+
event
|
|
169
|
+
});
|
|
170
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
171
|
+
finishBackgroundTask();
|
|
172
|
+
//TODO: think about sending appropriate reason for end call
|
|
173
|
+
callingx.endCallWithReason(call_cid, 'rejected');
|
|
174
|
+
}
|
|
149
175
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
176
|
+
|
|
177
|
+
// check if service needs to be closed if call was left
|
|
178
|
+
const stateSubscription = callFromPush.state.callingState$.subscribe(callingState => {
|
|
179
|
+
if (callingState === CallingState.IDLE || callingState === CallingState.LEFT) {
|
|
180
|
+
logger.debug(`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`);
|
|
181
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
182
|
+
|
|
183
|
+
//TODO: think about sending appropriate reason for end call
|
|
184
|
+
callingx.log(`Ending call with callCid: ${call_cid} callingState: ${callingState}`, 'debug');
|
|
185
|
+
finishBackgroundTask();
|
|
186
|
+
callingx.endCallWithReason(call_cid, 'remote');
|
|
187
|
+
}
|
|
158
188
|
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
189
|
+
const endCallSubscription = callingx.addEventListener('endCall', async ({
|
|
190
|
+
callId
|
|
191
|
+
}) => {
|
|
192
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
193
|
+
try {
|
|
194
|
+
await callFromPush.leave({
|
|
195
|
+
reject: true,
|
|
196
|
+
reason: 'decline'
|
|
197
|
+
});
|
|
198
|
+
} catch (error) {
|
|
199
|
+
logger.error(`Failed to leave call with callCid: ${call_cid} error: ${error}`);
|
|
200
|
+
} finally {
|
|
201
|
+
callingx.log(`Ending call with callCid: ${call_cid} callId: ${callId}`, 'debug');
|
|
202
|
+
finishBackgroundTask();
|
|
203
|
+
callingx.endCallWithReason(callId, 'rejected');
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
//stop background task when app comes to foreground
|
|
208
|
+
const appStateSubscription = AppState.addEventListener('change', nextAppState => {
|
|
209
|
+
const _canListenToWS = canListenToWS();
|
|
210
|
+
callingx.log(`AppState changed to: ${nextAppState} for callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, 'debug');
|
|
211
|
+
if (!_canListenToWS) {
|
|
212
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
213
|
+
finishBackgroundTask();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
unsubscribeFunctions.push(unsubscribe);
|
|
218
|
+
unsubscribeFunctions.push(() => stateSubscription.unsubscribe());
|
|
219
|
+
unsubscribeFunctions.push(() => endCallSubscription.remove());
|
|
220
|
+
unsubscribeFunctions.push(() => appStateSubscription.remove());
|
|
221
|
+
pushUnsubscriptionCallbacks.get(call_cid)?.forEach(cb => cb());
|
|
222
|
+
pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
callingx.log(`Failed to start background task with callCid: ${call_cid} error: ${error}`, 'error');
|
|
225
|
+
finishBackgroundTask();
|
|
169
226
|
}
|
|
170
|
-
});
|
|
171
|
-
unsubscribeFunctions.push(unsubscribe);
|
|
172
|
-
unsubscribeFunctions.push(() => subscription.unsubscribe());
|
|
173
|
-
pushUnsubscriptionCallbacks.get(call_cid)?.forEach(cb => cb());
|
|
174
|
-
pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
|
|
227
|
+
})();
|
|
175
228
|
});
|
|
176
229
|
});
|
|
177
230
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (!incomingCallChannel || !incomingCallNotificationTextGetters) {
|
|
181
|
-
const logger = videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler');
|
|
182
|
-
logger.error("Can't show incoming call notification as either or both incomingCallChannel and incomingCallNotificationTextGetters were not provided");
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
/*
|
|
186
|
-
* Sound has to be set on channel level for android 8 and above and cant be updated later after creation!
|
|
187
|
-
* For android 7 and below, sound should be set on notification level
|
|
188
|
-
*/
|
|
189
|
-
// set default ringtone if not provided
|
|
190
|
-
if (!incomingCallChannel.sound) {
|
|
191
|
-
incomingCallChannel.sound = await getAndroidDefaultRingtoneUrl();
|
|
192
|
-
}
|
|
193
|
-
await notifee.createChannel(incomingCallChannel);
|
|
194
|
-
const {
|
|
195
|
-
getTitle,
|
|
196
|
-
getBody,
|
|
197
|
-
getAcceptButtonTitle,
|
|
198
|
-
getDeclineButtonTitle
|
|
199
|
-
} = incomingCallNotificationTextGetters;
|
|
200
|
-
const createdUserName = data.created_by_display_name;
|
|
201
|
-
const title = getTitle(createdUserName);
|
|
202
|
-
const body = getBody(createdUserName);
|
|
203
|
-
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Displaying incoming call notification with callCid: ${call_cid} title: ${title} body: ${body} asForegroundService: ${asForegroundService}`);
|
|
204
|
-
const channelId = incomingCallChannel.id;
|
|
205
|
-
await notifee.displayNotification({
|
|
206
|
-
id: call_cid,
|
|
207
|
-
title: getTitle(createdUserName),
|
|
208
|
-
body: getBody(createdUserName),
|
|
209
|
-
data,
|
|
210
|
-
android: {
|
|
211
|
-
channelId,
|
|
212
|
-
smallIcon: pushConfig.android.smallIcon,
|
|
213
|
-
importance: 4,
|
|
214
|
-
// high importance
|
|
215
|
-
foregroundServiceTypes: getIncomingCallForegroundServiceTypes(),
|
|
216
|
-
asForegroundService,
|
|
217
|
-
ongoing: true,
|
|
218
|
-
sound: incomingCallChannel.sound,
|
|
219
|
-
vibrationPattern: incomingCallChannel.vibrationPattern,
|
|
220
|
-
loopSound: true,
|
|
221
|
-
pressAction: {
|
|
222
|
-
id: 'default',
|
|
223
|
-
launchActivity: 'default' // open the app when the notification is pressed
|
|
224
|
-
},
|
|
225
|
-
actions: [{
|
|
226
|
-
title: getDeclineButtonTitle?.() ?? 'Decline',
|
|
227
|
-
pressAction: {
|
|
228
|
-
id: DECLINE_CALL_ACTION_ID
|
|
229
|
-
}
|
|
230
|
-
}, {
|
|
231
|
-
title: getAcceptButtonTitle?.() ?? 'Accept',
|
|
232
|
-
pressAction: {
|
|
233
|
-
id: ACCEPT_CALL_ACTION_ID,
|
|
234
|
-
launchActivity: 'default' // open the app when the notification is pressed
|
|
235
|
-
}
|
|
236
|
-
}],
|
|
237
|
-
category: notifeeLib.AndroidCategory.CALL,
|
|
238
|
-
fullScreenAction: {
|
|
239
|
-
id: 'stream_ringing_incoming_call'
|
|
240
|
-
},
|
|
241
|
-
timeoutAfter: 60000 // 60 seconds, after which the notification will be dismissed automatically
|
|
242
|
-
}
|
|
243
|
-
});
|
|
231
|
+
await callingx.displayIncomingCall(call_cid, call_cid, callerName, hasVideo);
|
|
232
|
+
logger.debug(`Displaying incoming call notification with callCid: ${call_cid} asForegroundService: ${asForegroundService}`);
|
|
244
233
|
if (asForegroundService) {
|
|
245
234
|
// no need to check if call has be closed as that will be handled by the fg service
|
|
246
235
|
return;
|
|
247
236
|
}
|
|
248
|
-
|
|
249
|
-
// check if call needs to be closed if accept/decline event was done
|
|
250
|
-
// before the notification was shown
|
|
251
|
-
const client = await pushConfig.createStreamVideoClient();
|
|
252
|
-
if (!client) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
237
|
const callFromPush = await client.onRingingCall(call_cid);
|
|
256
|
-
if (shouldCallBeClosed(callFromPush)) {
|
|
257
|
-
|
|
258
|
-
|
|
238
|
+
if (shouldCallBeClosed(callFromPush, data)) {
|
|
239
|
+
logger.debug(`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`);
|
|
240
|
+
//TODO: think about sending appropriate reason for end call
|
|
241
|
+
callingx.endCallWithReason(call_cid, 'remote');
|
|
259
242
|
}
|
|
260
243
|
} else {
|
|
244
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
245
|
+
const notifee = notifeeLib.default;
|
|
246
|
+
const settings = await notifee.getNotificationSettings();
|
|
247
|
+
if (settings.authorizationStatus !== 1) {
|
|
248
|
+
logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
261
252
|
// the other types are call.live_started and call.notification
|
|
262
253
|
const callChannel = pushConfig.android.callChannel;
|
|
263
254
|
const callNotificationTextGetters = pushConfig.android.callNotificationTextGetters;
|
|
264
255
|
if (!callChannel || !callNotificationTextGetters) {
|
|
265
|
-
const logger = videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler');
|
|
266
256
|
logger.debug("Can't show call notification as either or both callChannel and callNotificationTextGetters is not provided");
|
|
267
257
|
return;
|
|
268
258
|
}
|
|
@@ -277,7 +267,7 @@ export const firebaseDataHandler = async data => {
|
|
|
277
267
|
const type = data.type;
|
|
278
268
|
const title = getTitle(type, createdUserName);
|
|
279
269
|
const body = getBody(type, createdUserName);
|
|
280
|
-
|
|
270
|
+
logger.debug(`Displaying NonRingingPushEvent ${type} notification with title: ${title} body: ${body}`);
|
|
281
271
|
await notifee.displayNotification({
|
|
282
272
|
title: getTitle(type, createdUserName),
|
|
283
273
|
body: getBody(type, createdUserName),
|
|
@@ -304,8 +294,7 @@ export const firebaseDataHandler = async data => {
|
|
|
304
294
|
}
|
|
305
295
|
};
|
|
306
296
|
export const onAndroidNotifeeEvent = async ({
|
|
307
|
-
event
|
|
308
|
-
isBackground
|
|
297
|
+
event
|
|
309
298
|
}) => {
|
|
310
299
|
if (Platform.OS !== 'android') return;
|
|
311
300
|
const {
|
|
@@ -313,8 +302,7 @@ export const onAndroidNotifeeEvent = async ({
|
|
|
313
302
|
detail
|
|
314
303
|
} = event;
|
|
315
304
|
const {
|
|
316
|
-
notification
|
|
317
|
-
pressAction
|
|
305
|
+
notification
|
|
318
306
|
} = detail;
|
|
319
307
|
const notificationId = notification?.id;
|
|
320
308
|
const data = notification?.data;
|
|
@@ -325,53 +313,10 @@ export const onAndroidNotifeeEvent = async ({
|
|
|
325
313
|
|
|
326
314
|
// we can safely cast to string because the data is from "stream.video"
|
|
327
315
|
const call_cid = data.call_cid;
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const notifee = notifeeLib.default;
|
|
333
|
-
// Check if we need to decline the call
|
|
334
|
-
const didPressDecline = type === notifeeLib.EventType.ACTION_PRESS && pressAction?.id === DECLINE_CALL_ACTION_ID;
|
|
335
|
-
const didDismiss = type === notifeeLib.EventType.DISMISSED;
|
|
336
|
-
const mustDecline = didPressDecline || didDismiss;
|
|
337
|
-
// Check if we need to accept the call
|
|
338
|
-
const mustAccept = type === notifeeLib.EventType.ACTION_PRESS && pressAction?.id === ACCEPT_CALL_ACTION_ID;
|
|
339
|
-
if (mustAccept || mustDecline || type === notifeeLib.EventType.ACTION_PRESS) {
|
|
340
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`clearPushWSEventSubscriptions for callCId: ${call_cid} mustAccept: ${mustAccept} mustDecline: ${mustDecline}`);
|
|
341
|
-
clearPushWSEventSubscriptions(call_cid);
|
|
342
|
-
notifee.stopForegroundService();
|
|
343
|
-
}
|
|
344
|
-
if (mustAccept) {
|
|
345
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushAcceptedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
346
|
-
pushAcceptedIncomingCallCId$.next(call_cid);
|
|
347
|
-
// NOTE: accept will be handled by the app with rxjs observers as the app will go to foreground always
|
|
348
|
-
} else if (mustDecline) {
|
|
349
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushRejectedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
350
|
-
pushRejectedIncomingCallCId$.next(call_cid);
|
|
351
|
-
if (hasObservers) {
|
|
352
|
-
// if we had observers we can return here as the observers will handle the call as the app is in the foreground state
|
|
353
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`Skipped processCallFromPushInBackground for Declining call with callCId: ${call_cid} as the app is in the foreground state`);
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`start processCallFromPushInBackground - Declining call with callCId: ${call_cid}`);
|
|
357
|
-
await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
|
|
358
|
-
} else {
|
|
359
|
-
if (type === notifeeLib.EventType.PRESS) {
|
|
360
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushTappedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
361
|
-
pushTappedIncomingCallCId$.next(call_cid);
|
|
362
|
-
// pressed state will be handled by the app with rxjs observers as the app will go to foreground always
|
|
363
|
-
} else if (isBackground && type === notifeeLib.EventType.DELIVERED) {
|
|
364
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushAndroidBackgroundDeliveredIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
365
|
-
pushAndroidBackgroundDeliveredIncomingCallCId$.next(call_cid);
|
|
366
|
-
// background delivered state will be handled by the app with rxjs observers as processing needs to happen only when app is opened
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
} else {
|
|
370
|
-
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
371
|
-
if (type === notifeeLib.EventType.PRESS) {
|
|
372
|
-
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`onTapNonRingingCallNotification with callCId: ${call_cid}`);
|
|
373
|
-
pushConfig.onTapNonRingingCallNotification?.(call_cid, data.type);
|
|
374
|
-
}
|
|
316
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
317
|
+
if (type === notifeeLib.EventType.PRESS) {
|
|
318
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`onTapNonRingingCallNotification with callCId: ${call_cid}`);
|
|
319
|
+
pushConfig.onTapNonRingingCallNotification?.(call_cid, data.type);
|
|
375
320
|
}
|
|
376
321
|
};
|
|
377
322
|
//# sourceMappingURL=android.js.map
|