@stream-io/video-react-native-sdk 1.28.1 → 1.29.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/keepalive/KeepAliveNotification.kt +83 -0
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +134 -0
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +235 -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 +60 -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 +20 -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/registerSDKGlobals.js +47 -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 +75 -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/module/hooks/push/useCallingExpWithCallingStateEffect.js +228 -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 +62 -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 +20 -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/registerSDKGlobals.js +48 -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 +69 -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/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.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/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/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.swift +4 -0
- package/ios/StreamVideoReactNative.h +7 -4
- package/ios/StreamVideoReactNative.m +191 -82
- package/package.json +10 -15
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +361 -0
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +95 -120
- package/src/index.ts +1 -0
- package/src/modules/call-manager/CallManager.ts +30 -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/registerSDKGlobals.ts +42 -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 +100 -0
- package/src/utils/push/setupIosVoipPushEvents.ts +11 -7
- package/CHANGELOG.md +0 -3089
- 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 @@
|
|
|
1
|
+
{"version":3,"names":["_rxSubjects","require","_videoClient","_utils","_pushLogoutCallback","_callingx","_reactNative","setupCallingExpEvents","pushConfig","hasPushProvider","Platform","OS","android","pushProviderName","ios","callingx","getCallingxLib","remove","removeAnswerCall","addEventListener","onAcceptCall","removeEndCall","onEndCall","events","getInitialEvents","forEach","event","eventName","params","videoLoggerSystem","getLogger","debug","callId","setPushLogoutCallback","call_cid","source","clearPushWSEventSubscriptions","pushAcceptedIncomingCallCId$","next","processCallFromPushInBackground"],"sourceRoot":"../../../../src","sources":["utils/push/setupCallingExpEvents.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAIA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;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C,CAAC;IAClBG,aAAa,CAAC,CAAC;EACjB,CAAC,CAAC;AACJ;AAEA,MAAMD,YAAY,GAAGA,CAAC;EACpBY,MAAM,EAAEE,QAAQ;EAChBC;AACyB,CAAC,KAAK;EAC/BN,8BAAiB,CACdC,SAAS,CAAC,sBAAsB,CAAC,CACjCC,KAAK,CAAC,sCAAsCG,QAAQ,YAAYC,MAAM,EAAE,CAAC;EAE5E,IAAIA,MAAM,KAAK,KAAK,IAAI,CAACD,QAAQ,EAAE;IACjC;IACA;EACF;EAEA,IAAAE,oCAA6B,EAACF,QAAQ,CAAC;EACvC;EACAG,wCAA4B,CAACC,IAAI,CAACJ,QAAQ,CAAC;AAC7C,CAAC;AAED,MAAMZ,SAAS,GACZd,UAAsB,IACvB,OAAO;EAAEwB,MAAM,EAAEE,QAAQ;EAAEC;AAA+B,CAAC,KAAK;EAC9DN,8BAAiB,CACdC,SAAS,CAAC,sBAAsB,CAAC,CACjCC,KAAK,CACJ,sCAAsCG,QAAQ,YAAYC,MAAM,EAClE,CAAC;EAEH,IAAIA,MAAM,KAAK,KAAK,IAAI,CAACD,QAAQ,EAAE;IACjC;IACA;EACF;EAEA,IAAAE,oCAA6B,EAACF,QAAQ,CAAC;EAEvC,MAAM,IAAAK,sCAA+B,EAAC/B,UAAU,EAAE0B,QAAQ,EAAE,SAAS,CAAC;AACxE,CAAC","ignoreList":[]}
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.setupIosVoipPushEvents = setupIosVoipPushEvents;
|
|
7
|
-
var _libs = require("./libs");
|
|
8
7
|
var _reactNative = require("react-native");
|
|
9
8
|
var _ios = require("./internal/ios");
|
|
10
9
|
var _pushLogoutCallback = require("../internal/pushLogoutCallback");
|
|
11
10
|
var _videoClient = require("@stream-io/video-client");
|
|
11
|
+
var _libs = require("./libs");
|
|
12
|
+
// import { getVoipPushNotificationLib } from './libs';
|
|
13
|
+
|
|
12
14
|
function setupIosVoipPushEvents(pushConfig) {
|
|
13
15
|
if (_reactNative.Platform.OS !== 'ios' || !pushConfig.ios?.pushProviderName) {
|
|
14
16
|
return;
|
|
@@ -19,14 +21,13 @@ function setupIosVoipPushEvents(pushConfig) {
|
|
|
19
21
|
logger.debug('ios pushProviderName is not defined, so skipping the setupIosVoipPushEvents');
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(0, _ios.onVoipNotificationReceived)(notification, pushConfig);
|
|
24
|
+
const callingx = (0, _libs.getCallingxLib)();
|
|
25
|
+
const voipNotificationReceivedListener = callingx.addEventListener('voipNotificationReceived', params => {
|
|
26
|
+
(0, _ios.onVoipNotificationReceived)(params, pushConfig);
|
|
26
27
|
});
|
|
27
28
|
(0, _pushLogoutCallback.setPushLogoutCallback)(async () => {
|
|
28
29
|
_videoClient.videoLoggerSystem.getLogger('setPushLogoutCallback').debug('notification event listener removed');
|
|
29
|
-
|
|
30
|
+
voipNotificationReceivedListener.remove();
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
//# sourceMappingURL=setupIosVoipPushEvents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_ios","_pushLogoutCallback","_videoClient","_libs","setupIosVoipPushEvents","pushConfig","Platform","OS","ios","pushProviderName","logger","videoLoggerSystem","getLogger","debug","callingx","getCallingxLib","voipNotificationReceivedListener","addEventListener","params","onVoipNotificationReceived","setPushLogoutCallback","remove"],"sourceRoot":"../../../../src","sources":["utils/push/setupIosVoipPushEvents.ts"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAPA;;AASO,SAASK,sBAAsBA,CACpCC,UAAkD,EAClD;EACA,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACF,UAAU,CAACG,GAAG,EAAEC,gBAAgB,EAAE;IAC9D;EACF;EACA,MAAMC,MAAM,GAAGC,8BAAiB,CAACC,SAAS,CAAC,wBAAwB,CAAC;EACpE,IAAI,CAACP,UAAU,CAACG,GAAG,CAACC,gBAAgB,EAAE;IACpC;IACAC,MAAM,CAACG,KAAK,CACV,6EACF,CAAC;IACD;EACF;EAEA,MAAMC,QAAQ,GAAG,IAAAC,oBAAc,EAAC,CAAC;EACjC,MAAMC,gCAAgC,GAAGF,QAAQ,CAACG,gBAAgB,CAChE,0BAA0B,EACzBC,MAAM,IAAK;IACV,IAAAC,+BAA0B,EAACD,MAAM,EAAEb,UAAU,CAAC;EAChD,CACF,CAAC;EAED,IAAAe,yCAAqB,EAAC,YAAY;IAChCT,8BAAiB,CACdC,SAAS,CAAC,uBAAuB,CAAC,CAClCC,KAAK,CAAC,qCAAqC,CAAC;IAC/CG,gCAAgC,CAACK,MAAM,CAAC,CAAC;EAC3C,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,228 @@
|
|
|
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 { getCallingxLibIfAvailable } from '../../utils/push/libs/callingx';
|
|
5
|
+
const logger = videoLoggerSystem.getLogger('useCallingExpWithCallingStateEffect');
|
|
6
|
+
|
|
7
|
+
//calling state methods are not exhaustive, so we need to add more methods to cover different cases
|
|
8
|
+
const canAcceptIncomingCall = (prevState, currentState) => {
|
|
9
|
+
if (!prevState && !currentState) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const isJoined = state => {
|
|
13
|
+
if (!state) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return state === CallingState.JOINING || state === CallingState.JOINED;
|
|
17
|
+
};
|
|
18
|
+
return !isJoined(prevState) && isJoined(currentState) || prevState === CallingState.JOINING && currentState === CallingState.JOINED;
|
|
19
|
+
};
|
|
20
|
+
const canEndCall = (prevState, currentState) => {
|
|
21
|
+
if (!prevState && !currentState) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return (prevState === CallingState.JOINED || prevState === CallingState.JOINING || prevState === CallingState.RINGING || prevState === CallingState.RECONNECTING || prevState === CallingState.MIGRATING || prevState === CallingState.OFFLINE) && (currentState === CallingState.LEFT || currentState === CallingState.RECONNECTING_FAILED || currentState === CallingState.IDLE);
|
|
25
|
+
};
|
|
26
|
+
const canStartCall = (prevState, currentState) => {
|
|
27
|
+
if (!prevState && !currentState) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return (!prevState || prevState === CallingState.IDLE || prevState === CallingState.UNKNOWN) && (currentState === CallingState.JOINED || currentState === CallingState.JOINING || currentState === CallingState.RINGING);
|
|
31
|
+
};
|
|
32
|
+
function getCallDisplayName(callMembers, participants, currentUserId) {
|
|
33
|
+
if (!callMembers || !participants || !currentUserId) {
|
|
34
|
+
return 'Call';
|
|
35
|
+
}
|
|
36
|
+
let names = [];
|
|
37
|
+
if (callMembers.length > 0) {
|
|
38
|
+
names = callMembers.filter(member => member.user.id !== currentUserId).map(member => member.user.name).filter(name => name !== undefined);
|
|
39
|
+
} else if (participants.length > 0) {
|
|
40
|
+
names = participants.filter(participant => participant.userId !== currentUserId).map(participant => participant.name).filter(Boolean);
|
|
41
|
+
}
|
|
42
|
+
return names.length > 0 ? names.sort().join(', ') : 'Call';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This hook is used to inform sync call state with CallKit/Telecom (i.e. start call, end call, mute/unmute call).
|
|
47
|
+
*/
|
|
48
|
+
export const useCallingExpWithCallingStateEffect = () => {
|
|
49
|
+
const {
|
|
50
|
+
useCallCallingState,
|
|
51
|
+
// useMicrophoneState,
|
|
52
|
+
useParticipants,
|
|
53
|
+
useCallMembers
|
|
54
|
+
} = useCallStateHooks();
|
|
55
|
+
const activeCall = useCall();
|
|
56
|
+
const callingState = useCallCallingState();
|
|
57
|
+
// const { isMute, microphone } = useMicrophoneState();
|
|
58
|
+
const callMembers = useCallMembers();
|
|
59
|
+
const participants = useParticipants();
|
|
60
|
+
const prevState = useRef(undefined);
|
|
61
|
+
const activeCallCid = activeCall?.cid;
|
|
62
|
+
const isIncomingCall = activeCall?.ringing && !activeCall?.isCreatedByMe;
|
|
63
|
+
const isOutcomingCall = activeCall?.ringing && activeCall?.isCreatedByMe;
|
|
64
|
+
const currentUserId = activeCall?.currentUserId;
|
|
65
|
+
const isVideoCall = activeCall?.state.settings?.video?.enabled ?? false;
|
|
66
|
+
const callDisplayName = useMemo(() => getCallDisplayName(callMembers, participants, currentUserId), [callMembers, participants, currentUserId]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
return () => {
|
|
69
|
+
const callingx = getCallingxLibIfAvailable();
|
|
70
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
74
|
+
if (!isCallRegistered) {
|
|
75
|
+
logger.debug(`No active call cid to end in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
//if incoming stream call was unmounted, we need to end the call in CallKit/Telecom
|
|
79
|
+
logger.debug(`Ending call in calling exp: ${activeCallCid}`);
|
|
80
|
+
callingx.endCallWithReason(activeCallCid, 'local').catch(error => {
|
|
81
|
+
logger.error(`Error ending call in calling exp: ${activeCallCid}`, error);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
}, [activeCallCid]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const callingx = getCallingxLibIfAvailable();
|
|
87
|
+
if (!callingx?.isSetup || !activeCallCid || prevState.current === callingState) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//tells if call is registered in CallKit/Telecom
|
|
92
|
+
const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
93
|
+
logger.debug(`useEffect: ${activeCallCid} isCallRegistered: ${isCallRegistered}
|
|
94
|
+
isIncomingCall: ${isIncomingCall} isOutcomingCall: ${isOutcomingCall}
|
|
95
|
+
prevState: ${prevState.current}, currentState: ${callingState}
|
|
96
|
+
isOngoingCallsEnabled: ${callingx.isOngoingCallsEnabled}`);
|
|
97
|
+
if (isIncomingCall && isCallRegistered && canAcceptIncomingCall(prevState.current, callingState)) {
|
|
98
|
+
logger.debug(`Should accept call in callkeep: ${activeCallCid}`);
|
|
99
|
+
callingx.answerIncomingCall(activeCallCid).catch(error => {
|
|
100
|
+
logger.error(`Error answering call in calling exp: ${activeCallCid}`, error);
|
|
101
|
+
});
|
|
102
|
+
} else if ((isOutcomingCall || !isIncomingCall && callingx.isOngoingCallsEnabled) &&
|
|
103
|
+
//we register call in case if is outcoming ringing call or it is non-ringing call and ongoing calls are enabled
|
|
104
|
+
!isCallRegistered && canStartCall(prevState.current, callingState)) {
|
|
105
|
+
logger.debug(`Should register call in callkeep: ${activeCallCid}`);
|
|
106
|
+
//we request start call action from CallKit/Telecom, next step is to make call active when we receive call started event
|
|
107
|
+
callingx.startCall(activeCallCid, activeCallCid, callDisplayName, isVideoCall).catch(error => {
|
|
108
|
+
logger.error(`Error starting call in calling exp: ${activeCallCid}`, error);
|
|
109
|
+
});
|
|
110
|
+
} else if (isCallRegistered && canEndCall(prevState.current, callingState)) {
|
|
111
|
+
//in case call was registered as incoming and state changed to "not joined", we need to end the call and clear rxjs subject
|
|
112
|
+
logger.debug(`Should end call in callkeep: ${activeCallCid}`);
|
|
113
|
+
//TODO: think about sending appropriate reason for end call
|
|
114
|
+
callingx.endCallWithReason(activeCallCid, 'local').catch(error => {
|
|
115
|
+
logger.error(`Error ending call in calling exp: ${activeCallCid}`, error);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
prevState.current = callingState;
|
|
119
|
+
}, [activeCallCid, callingState, callDisplayName, isIncomingCall, isOutcomingCall, isVideoCall]);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
const callingx = getCallingxLibIfAvailable();
|
|
122
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
123
|
+
logger.debug(`No active call cid to listen to start call action in calling exp: ${activeCallCid} callingx is not setup`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!isOutcomingCall && !(!isIncomingCall && callingx.isOngoingCallsEnabled)) {
|
|
127
|
+
logger.debug(`Call is not outcoming or ongoing calls are not enabled for non-ringing calls`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//listen to start call action from CallKit/Telecom and set the current call active
|
|
132
|
+
const subscription = callingx.addEventListener('didReceiveStartCallAction', ({
|
|
133
|
+
callId
|
|
134
|
+
}) => {
|
|
135
|
+
if (callId === activeCallCid) {
|
|
136
|
+
logger.debug(`Received start call action for call: ${activeCallCid}`);
|
|
137
|
+
callingx.setCurrentCallActive(activeCallCid).catch(error => {
|
|
138
|
+
logger.error(`Error answering call in calling exp: ${activeCallCid}`, error);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return () => {
|
|
143
|
+
subscription.remove();
|
|
144
|
+
};
|
|
145
|
+
}, [activeCallCid, isOutcomingCall, isIncomingCall]);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
const callingx = getCallingxLibIfAvailable();
|
|
148
|
+
if (!callingx?.isSetup || !activeCallCid) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
152
|
+
if (!isCallRegistered) {
|
|
153
|
+
logger.debug(`No active call cid to update calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
callingx.updateDisplay(activeCallCid, activeCallCid, callDisplayName);
|
|
157
|
+
}, [activeCallCid, callDisplayName]);
|
|
158
|
+
|
|
159
|
+
// useEffect(() => {
|
|
160
|
+
// const callingx = getCallingxLibIfAvailable();
|
|
161
|
+
// if (!callingx?.isSetup || !activeCallCid) {
|
|
162
|
+
// return;
|
|
163
|
+
// }
|
|
164
|
+
|
|
165
|
+
// const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
166
|
+
// if (!isCallRegistered) {
|
|
167
|
+
// logger.debug(
|
|
168
|
+
// `No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
|
|
169
|
+
// );
|
|
170
|
+
// return;
|
|
171
|
+
// }
|
|
172
|
+
|
|
173
|
+
// callingx.setMutedCall(activeCallCid, isMute);
|
|
174
|
+
// }, [activeCallCid, isMute]);
|
|
175
|
+
|
|
176
|
+
// useEffect(() => {
|
|
177
|
+
// const callingx = getCallingxLibIfAvailable();
|
|
178
|
+
// if (!callingx?.isSetup || !activeCallCid) {
|
|
179
|
+
// return;
|
|
180
|
+
// }
|
|
181
|
+
|
|
182
|
+
// const isCallRegistered = callingx.isCallRegistered(activeCallCid);
|
|
183
|
+
// if (!isCallRegistered) {
|
|
184
|
+
// logger.debug(
|
|
185
|
+
// `No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`,
|
|
186
|
+
// );
|
|
187
|
+
// return;
|
|
188
|
+
// }
|
|
189
|
+
|
|
190
|
+
// //listen to mic toggle events from CallKit/Telecom and update stream call microphone state
|
|
191
|
+
// const subscription = callingx.addEventListener(
|
|
192
|
+
// 'didPerformSetMutedCallAction',
|
|
193
|
+
// async (event: { callId: string; muted: boolean }) => {
|
|
194
|
+
// const { callId, muted } = event;
|
|
195
|
+
|
|
196
|
+
// if (callId === activeCallCid) {
|
|
197
|
+
// const isCurrentlyMuted =
|
|
198
|
+
// RxUtils.getCurrentValue(microphone.state.status$) === 'disabled';
|
|
199
|
+
// if (isCurrentlyMuted === muted) {
|
|
200
|
+
// logger.debug(
|
|
201
|
+
// `Mic toggle is already in the desired state: ${muted} for call: ${activeCallCid}`,
|
|
202
|
+
// );
|
|
203
|
+
// //this check prevents mic toggle when state change was initiated from client and not from CallKit/Telecom
|
|
204
|
+
// return;
|
|
205
|
+
// }
|
|
206
|
+
|
|
207
|
+
// try {
|
|
208
|
+
// if (muted) {
|
|
209
|
+
// await microphone.disable();
|
|
210
|
+
// } else {
|
|
211
|
+
// await microphone.enable();
|
|
212
|
+
// }
|
|
213
|
+
// } catch (error: unknown) {
|
|
214
|
+
// logger.error(
|
|
215
|
+
// `Error toggling mic in calling exp: ${activeCallCid}`,
|
|
216
|
+
// error,
|
|
217
|
+
// );
|
|
218
|
+
// }
|
|
219
|
+
// }
|
|
220
|
+
// },
|
|
221
|
+
// );
|
|
222
|
+
|
|
223
|
+
// return () => {
|
|
224
|
+
// subscription.remove();
|
|
225
|
+
// };
|
|
226
|
+
// }, [activeCallCid, microphone, isOutcomingCall, isIncomingCall]);
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=useCallingExpWithCallingStateEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CallingState","videoLoggerSystem","useCall","useCallStateHooks","useEffect","useMemo","useRef","getCallingxLibIfAvailable","logger","getLogger","canAcceptIncomingCall","prevState","currentState","isJoined","state","JOINING","JOINED","canEndCall","RINGING","RECONNECTING","MIGRATING","OFFLINE","LEFT","RECONNECTING_FAILED","IDLE","canStartCall","UNKNOWN","getCallDisplayName","callMembers","participants","currentUserId","names","length","filter","member","user","id","map","name","undefined","participant","userId","Boolean","sort","join","useCallingExpWithCallingStateEffect","useCallCallingState","useParticipants","useCallMembers","activeCall","callingState","activeCallCid","cid","isIncomingCall","ringing","isCreatedByMe","isOutcomingCall","isVideoCall","settings","video","enabled","callDisplayName","callingx","isSetup","isCallRegistered","debug","endCallWithReason","catch","error","current","isOngoingCallsEnabled","answerIncomingCall","startCall","subscription","addEventListener","callId","setCurrentCallActive","remove","updateDisplay"],"sourceRoot":"../../../../src","sources":["hooks/push/useCallingExpWithCallingStateEffect.ts"],"mappings":"AAAA,SACEA,YAAY,EAGZC,iBAAiB,QACZ,yBAAyB;AAChC,SAASC,OAAO,EAAEC,iBAAiB,QAAQ,iCAAiC;AAC5E,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,yBAAyB,QAAQ,gCAAgC;AAE1E,MAAMC,MAAM,GAAGP,iBAAiB,CAACQ,SAAS,CACxC,qCACF,CAAC;;AAED;AACA,MAAMC,qBAAqB,GAAGA,CAC5BC,SAAmC,EACnCC,YAAsC,KACnC;EACH,IAAI,CAACD,SAAS,IAAI,CAACC,YAAY,EAAE;IAC/B,OAAO,KAAK;EACd;EAEA,MAAMC,QAAQ,GAAIC,KAA+B,IAAK;IACpD,IAAI,CAACA,KAAK,EAAE;MACV,OAAO,KAAK;IACd;IAEA,OAAOA,KAAK,KAAKd,YAAY,CAACe,OAAO,IAAID,KAAK,KAAKd,YAAY,CAACgB,MAAM;EACxE,CAAC;EAED,OACG,CAACH,QAAQ,CAACF,SAAS,CAAC,IAAIE,QAAQ,CAACD,YAAY,CAAC,IAC9CD,SAAS,KAAKX,YAAY,CAACe,OAAO,IAAIH,YAAY,KAAKZ,YAAY,CAACgB,MAAO;AAEhF,CAAC;AAED,MAAMC,UAAU,GAAGA,CACjBN,SAAmC,EACnCC,YAAsC,KACnC;EACH,IAAI,CAACD,SAAS,IAAI,CAACC,YAAY,EAAE;IAC/B,OAAO,KAAK;EACd;EAEA,OACE,CAACD,SAAS,KAAKX,YAAY,CAACgB,MAAM,IAChCL,SAAS,KAAKX,YAAY,CAACe,OAAO,IAClCJ,SAAS,KAAKX,YAAY,CAACkB,OAAO,IAClCP,SAAS,KAAKX,YAAY,CAACmB,YAAY,IACvCR,SAAS,KAAKX,Y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,eAAe,CAAC,CAAC;;EAEpC;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { getVoipPushNotificationLib } from '../../utils/push/libs';
|
|
3
2
|
import { Platform } from 'react-native';
|
|
4
3
|
import { StreamVideoRN } from '../../utils';
|
|
5
4
|
import { onVoipNotificationReceived } from '../../utils/push/internal/ios';
|
|
6
5
|
import { useConnectedUser, useStreamVideoClient } from '@stream-io/video-react-bindings';
|
|
7
6
|
import { setPushLogoutCallback } from '../../utils/internal/pushLogoutCallback';
|
|
8
7
|
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
8
|
+
import { getCallingxLibIfAvailable } from '../../utils/push/libs';
|
|
9
9
|
const logger = videoLoggerSystem.getLogger('useIosVoipPushEventsSetupEffect');
|
|
10
10
|
|
|
11
11
|
/* VoipPushNotificationLib has support for only one listener type at a time
|
|
@@ -23,6 +23,7 @@ function setLogoutCallback(client, token, lastVoipTokenRef) {
|
|
|
23
23
|
};
|
|
24
24
|
try {
|
|
25
25
|
await client.removeDevice(token);
|
|
26
|
+
logger.debug('PushLogoutCallback - Removed voip token', token);
|
|
26
27
|
} catch (err) {
|
|
27
28
|
logger.warn('PushLogoutCallback - Failed to remove voip token', err);
|
|
28
29
|
}
|
|
@@ -77,20 +78,10 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
77
78
|
useEffect(() => {
|
|
78
79
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
79
80
|
const pushProviderName = pushConfig?.ios.pushProviderName;
|
|
80
|
-
|
|
81
|
+
const callingx = getCallingxLibIfAvailable();
|
|
82
|
+
if (Platform.OS !== 'ios' || !client || !pushProviderName || !callingx) {
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
|
-
if (!pushConfig.android.incomingCallChannel) {
|
|
84
|
-
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
85
|
-
logger.debug('android incomingCallChannel is not defined, so skipping the useIosVoipPushEventsSetupEffect');
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const voipPushNotification = getVoipPushNotificationLib();
|
|
89
|
-
|
|
90
|
-
// even though we do this natively, we have to still register here again
|
|
91
|
-
// natively this will make sure "register" event for JS is sent with the last push token
|
|
92
|
-
// Necessary if client changed before we got the event here or user logged out and logged in again
|
|
93
|
-
voipPushNotification.registerVoipToken();
|
|
94
85
|
const onTokenReceived = token => {
|
|
95
86
|
const userId = client.streamClient._user?.id ?? '';
|
|
96
87
|
if (client.streamClient.anonymous || !token || !userId) {
|
|
@@ -118,27 +109,24 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
118
109
|
});
|
|
119
110
|
};
|
|
120
111
|
// fired when PushKit give us the latest token
|
|
121
|
-
|
|
112
|
+
const voipRegisterListener = callingx.addEventListener('voipNotificationsRegistered', ({
|
|
113
|
+
token
|
|
114
|
+
}) => {
|
|
122
115
|
onTokenReceived(token);
|
|
123
116
|
});
|
|
124
117
|
|
|
125
|
-
// this will
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
} = voipPushEvent;
|
|
135
|
-
if (name === 'RNVoipPushRemoteNotificationsRegisteredEvent') {
|
|
136
|
-
onTokenReceived(data);
|
|
137
|
-
} else if (name === 'RNVoipPushRemoteNotificationReceivedEvent') {
|
|
138
|
-
onVoipNotificationReceived(data, pushConfig);
|
|
139
|
-
}
|
|
118
|
+
// this will return events that were fired before js bridge initialized
|
|
119
|
+
callingx.getInitialVoipEvents().forEach(({
|
|
120
|
+
eventName,
|
|
121
|
+
params
|
|
122
|
+
}) => {
|
|
123
|
+
if (eventName === 'voipNotificationsRegistered' && 'token' in params) {
|
|
124
|
+
onTokenReceived(params.token);
|
|
125
|
+
} else if (eventName === 'voipNotificationReceived') {
|
|
126
|
+
onVoipNotificationReceived(params, pushConfig);
|
|
140
127
|
}
|
|
141
128
|
});
|
|
129
|
+
callingx.registerVoipToken();
|
|
142
130
|
lastListener.count += 1;
|
|
143
131
|
const currentListenerCount = lastListener.count;
|
|
144
132
|
return () => {
|
|
@@ -148,8 +136,7 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
148
136
|
return;
|
|
149
137
|
}
|
|
150
138
|
logger.debug(`Voip event listeners are removed for user: ${userId}`);
|
|
151
|
-
|
|
152
|
-
voipPushNotification.removeEventListener('register');
|
|
139
|
+
voipRegisterListener.remove();
|
|
153
140
|
};
|
|
154
141
|
}, [client]);
|
|
155
142
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useState","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","Platform","StreamVideoRN","onVoipNotificationReceived","useConnectedUser","useStreamVideoClient","setPushLogoutCallback","videoLoggerSystem","getCallingxLibIfAvailable","logger","getLogger","lastListener","count","setLogoutCallback","client","token","lastVoipTokenRef","current","userId","removeDevice","debug","err","warn","useIosVoipPushEventsSetupEffect","connectedUserId","id","unsentToken","setUnsentToken","pushProviderName","getConfig","push","ios","tokenToSend","addVoipDevice","then","undefined","catch","error","pushConfig","callingx","OS","onTokenReceived","streamClient","_user","anonymous","reason","lastVoipToken","voipRegisterListener","addEventListener","getInitialVoipEvents","forEach","eventName","params","registerVoipToken","currentListenerCount","remove"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosVoipPushEventsSetupEffect.ts"],"mappings":"AA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