@stream-io/video-react-native-sdk 1.31.1-beta.0 → 1.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/android/src/main/AndroidManifest.xml +1 -8
- package/android/src/main/AndroidManifestNew.xml +0 -11
- package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +5 -42
- package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +6 -70
- package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +4 -6
- package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +95 -0
- package/dist/commonjs/components/Participant/ParticipantView/ParticipantLabel.js +2 -6
- package/dist/commonjs/components/Participant/ParticipantView/ParticipantLabel.js.map +1 -1
- package/dist/commonjs/hooks/push/index.js +2 -0
- package/dist/commonjs/hooks/push/index.js.map +1 -1
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +67 -0
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +1 -0
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +97 -64
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/index.js +0 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/modules/call-manager/CallManager.js +0 -26
- package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
- package/dist/commonjs/providers/StreamCall/index.js +6 -6
- package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +21 -35
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +3 -53
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +202 -135
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/ios.js +34 -17
- package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js +45 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/commonjs/utils/push/internal/utils.js +53 -71
- package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
- package/dist/commonjs/utils/push/ios.js.map +1 -1
- package/dist/commonjs/utils/push/libs/callkeep.js +17 -0
- package/dist/commonjs/utils/push/libs/callkeep.js.map +1 -0
- package/dist/commonjs/utils/push/libs/index.js +19 -8
- package/dist/commonjs/utils/push/libs/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/notifee/index.js +19 -0
- package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/voipPushNotification.js +17 -0
- package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +205 -0
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/commonjs/version.js.map +1 -1
- package/dist/module/components/Participant/ParticipantView/ParticipantLabel.js +2 -6
- package/dist/module/components/Participant/ParticipantView/ParticipantLabel.js.map +1 -1
- package/dist/module/hooks/push/index.js +2 -0
- package/dist/module/hooks/push/index.js.map +1 -1
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +153 -0
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/push/useProcessPushCallEffect.js +60 -0
- package/dist/module/hooks/push/useProcessPushCallEffect.js.map +1 -0
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +99 -66
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/index.js +0 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/modules/call-manager/CallManager.js +0 -26
- package/dist/module/modules/call-manager/CallManager.js.map +1 -1
- package/dist/module/providers/StreamCall/index.js +6 -6
- package/dist/module/providers/StreamCall/index.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +21 -35
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/registerSDKGlobals.js +3 -53
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/push/android.js +204 -137
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/ios.js +34 -17
- package/dist/module/utils/push/internal/ios.js.map +1 -1
- package/dist/module/utils/push/internal/rxSubjects.js +44 -0
- package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/module/utils/push/internal/utils.js +50 -67
- package/dist/module/utils/push/internal/utils.js.map +1 -1
- package/dist/module/utils/push/ios.js.map +1 -1
- package/dist/module/utils/push/libs/callkeep.js +11 -0
- package/dist/module/utils/push/libs/callkeep.js.map +1 -0
- package/dist/module/utils/push/libs/index.js +2 -1
- package/dist/module/utils/push/libs/index.js.map +1 -1
- package/dist/module/utils/push/libs/notifee/index.js +18 -0
- package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/module/utils/push/libs/voipPushNotification.js +11 -0
- package/dist/module/utils/push/libs/voipPushNotification.js.map +1 -0
- package/dist/module/utils/push/setupIosCallKeepEvents.js +199 -0
- package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/version.js.map +1 -1
- package/dist/typescript/components/Participant/ParticipantView/ParticipantLabel.d.ts.map +1 -1
- package/dist/typescript/hooks/push/index.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -0
- package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts +8 -0
- package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts.map +1 -0
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +0 -1
- package/dist/typescript/index.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
- package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -22
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +25 -59
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
- package/dist/typescript/utils/push/android.d.ts +2 -1
- package/dist/typescript/utils/push/android.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts +33 -0
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/utils.d.ts +8 -14
- package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
- package/dist/typescript/utils/push/ios.d.ts +2 -1
- package/dist/typescript/utils/push/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
- package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +2 -16
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/index.d.ts +2 -1
- package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
- package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
- package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/dist/typescript/version.d.ts.map +1 -1
- package/expo-config-plugin/dist/withAndroidManifest.js +33 -1
- package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
- package/expo-config-plugin/dist/withAppDelegate.js +197 -19
- package/expo-config-plugin/dist/withMainActivity.js +1 -1
- package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
- package/ios/StreamInCallManager.m +0 -2
- package/ios/StreamInCallManager.swift +7 -19
- package/ios/StreamVideoReactNative.h +4 -7
- package/ios/StreamVideoReactNative.m +82 -189
- package/package.json +16 -11
- package/src/components/Participant/ParticipantView/ParticipantLabel.tsx +2 -7
- package/src/hooks/push/index.ts +2 -0
- package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
- package/src/hooks/push/useProcessPushCallEffect.ts +108 -0
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
- package/src/index.ts +0 -1
- package/src/modules/call-manager/CallManager.ts +0 -36
- package/src/modules/call-manager/native-module.d.ts +0 -7
- package/src/providers/StreamCall/index.tsx +6 -6
- package/src/utils/StreamVideoRN/index.ts +30 -42
- package/src/utils/StreamVideoRN/types.ts +25 -61
- package/src/utils/internal/registerSDKGlobals.ts +4 -52
- package/src/utils/push/android.ts +311 -198
- package/src/utils/push/internal/ios.ts +44 -28
- package/src/utils/push/internal/rxSubjects.ts +61 -0
- package/src/utils/push/internal/utils.ts +64 -108
- package/src/utils/push/ios.ts +6 -1
- package/src/utils/push/libs/callkeep.ts +16 -0
- package/src/utils/push/libs/index.ts +2 -1
- package/src/utils/push/libs/notifee/index.ts +27 -0
- package/src/utils/push/libs/voipPushNotification.ts +17 -0
- package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
- package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
- package/src/version.ts +1 -1
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -149
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -144
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +0 -68
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +0 -150
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +0 -1
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
- package/dist/commonjs/utils/push/libs/callingx.js +0 -75
- package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
- package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -105
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -137
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/module/utils/internal/callingx/audioSessionPromise.js +0 -61
- package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/module/utils/internal/callingx/callingx.js +0 -140
- package/dist/module/utils/internal/callingx/callingx.js.map +0 -1
- package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
- package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
- package/dist/module/utils/push/libs/callingx.js +0 -67
- package/dist/module/utils/push/libs/callingx.js.map +0 -1
- package/dist/module/utils/push/setupCallingExpEvents.js +0 -99
- package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +0 -16
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +0 -1
- package/dist/typescript/utils/internal/callingx/callingx.d.ts +0 -18
- package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +0 -1
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
- package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
- package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -189
- package/src/utils/internal/callingx/audioSessionPromise.ts +0 -65
- package/src/utils/internal/callingx/callingx.ts +0 -194
- package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
- package/src/utils/push/libs/callingx.ts +0 -89
- package/src/utils/push/setupCallingExpEvents.ts +0 -135
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
1
|
+
import { AppState, NativeModules, Platform } from 'react-native';
|
|
2
|
+
import { getCallKeepLib, getVoipPushNotificationLib } from '../libs';
|
|
3
|
+
import { voipPushNotificationCallCId$ } from './rxSubjects';
|
|
2
4
|
import { pushUnsubscriptionCallbacks } from './constants';
|
|
3
|
-
import {
|
|
5
|
+
import { canAddPushWSSubscriptionsRef, shouldCallBeEnded } from './utils';
|
|
4
6
|
import { StreamVideoConfig } from '../../StreamVideoRN/types';
|
|
5
7
|
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
6
|
-
import { getCallingxLib } from '../libs/callingx';
|
|
7
8
|
|
|
8
9
|
export const onVoipNotificationReceived = async (
|
|
9
10
|
notification: any,
|
|
@@ -31,57 +32,71 @@ export const onVoipNotificationReceived = async (
|
|
|
31
32
|
"version": "v2"
|
|
32
33
|
}
|
|
33
34
|
} */
|
|
34
|
-
const logger = videoLoggerSystem.getLogger(
|
|
35
|
-
'callingx - onVoipNotificationReceived',
|
|
36
|
-
);
|
|
37
|
-
|
|
38
35
|
const sender = notification?.stream?.sender;
|
|
39
36
|
const type = notification?.stream?.type;
|
|
40
37
|
// do not process any other notifications other than stream.video or ringing
|
|
41
38
|
if (sender !== 'stream.video' && type !== 'call.ring') {
|
|
42
39
|
return;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
const call_cid = notification?.stream?.call_cid;
|
|
46
42
|
if (!call_cid || Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName) {
|
|
47
43
|
return;
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
const callingx = getCallingxLib();
|
|
51
|
-
if (callingx.isCallTracked(call_cid)) {
|
|
52
|
-
//same call_cid is already tracked, so we skip the notification
|
|
53
|
-
logger.debug(
|
|
54
|
-
`the same call_cid ${call_cid} is already tracked, skipping the call.ring notification`,
|
|
55
|
-
);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
45
|
+
const logger = videoLoggerSystem.getLogger('setupIosVoipPushEvents');
|
|
59
46
|
const client = await pushConfig.createStreamVideoClient();
|
|
47
|
+
|
|
60
48
|
if (!client) {
|
|
61
49
|
logger.debug(
|
|
62
50
|
'client not found, not processing call.ring voip push notification',
|
|
63
51
|
);
|
|
64
52
|
return;
|
|
65
53
|
}
|
|
66
|
-
|
|
54
|
+
const shouldRejectCallWhenBusy = client['rejectCallWhenBusy'] ?? false;
|
|
55
|
+
if (shouldRejectCallWhenBusy) {
|
|
56
|
+
// inform the iOS native module that we should reject call when busy
|
|
57
|
+
NativeModules.StreamVideoReactNative.setShouldRejectCallWhenBusy(
|
|
58
|
+
shouldRejectCallWhenBusy,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
67
61
|
const callFromPush = await client.onRingingCall(call_cid);
|
|
68
|
-
|
|
62
|
+
let uuid = '';
|
|
63
|
+
try {
|
|
64
|
+
uuid =
|
|
65
|
+
await NativeModules?.StreamVideoReactNative?.getIncomingCallUUid(
|
|
66
|
+
call_cid,
|
|
67
|
+
);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
logger.error('Error in getting call uuid from native module', error);
|
|
70
|
+
}
|
|
71
|
+
if (!uuid) {
|
|
72
|
+
logger.error(
|
|
73
|
+
`Not processing call.ring push notification, as no uuid found for call_cid: ${call_cid}`,
|
|
74
|
+
);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const created_by_id = notification?.stream?.created_by_id;
|
|
78
|
+
const receiver_id = notification?.stream?.receiver_id;
|
|
69
79
|
function closeCallIfNecessary() {
|
|
70
|
-
const { mustEndCall,
|
|
80
|
+
const { mustEndCall, callkeepReason } = shouldCallBeEnded(
|
|
71
81
|
callFromPush,
|
|
72
|
-
|
|
82
|
+
created_by_id,
|
|
83
|
+
receiver_id,
|
|
73
84
|
);
|
|
74
85
|
if (mustEndCall) {
|
|
86
|
+
const callkeep = getCallKeepLib();
|
|
75
87
|
logger.debug(
|
|
76
|
-
`
|
|
88
|
+
`callkeep.reportEndCallWithUUID for uuid: ${uuid}, call_cid: ${call_cid}, reason: ${callkeepReason}`,
|
|
77
89
|
);
|
|
78
|
-
|
|
90
|
+
callkeep.reportEndCallWithUUID(uuid, callkeepReason);
|
|
91
|
+
const voipPushNotification = getVoipPushNotificationLib();
|
|
92
|
+
voipPushNotification.onVoipNotificationCompleted(uuid);
|
|
79
93
|
return true;
|
|
80
94
|
}
|
|
81
95
|
return false;
|
|
82
96
|
}
|
|
83
|
-
|
|
84
97
|
const closed = closeCallIfNecessary();
|
|
98
|
+
const canListenToWS = () =>
|
|
99
|
+
canAddPushWSSubscriptionsRef.current && AppState.currentState !== 'active';
|
|
85
100
|
if (!closed && canListenToWS()) {
|
|
86
101
|
const unsubscribe = callFromPush.on('all', (event) => {
|
|
87
102
|
const _canListenToWS = canListenToWS();
|
|
@@ -106,9 +121,10 @@ export const onVoipNotificationReceived = async (
|
|
|
106
121
|
pushUnsubscriptionCallbacks.get(call_cid)?.forEach((cb) => cb());
|
|
107
122
|
pushUnsubscriptionCallbacks.set(call_cid, [unsubscribe]);
|
|
108
123
|
}
|
|
109
|
-
|
|
110
|
-
//
|
|
124
|
+
// send the info to this subject, it is listened by callkeep events
|
|
125
|
+
// callkeep events will then accept/reject the call
|
|
111
126
|
logger.debug(
|
|
112
|
-
`call_cid:${call_cid} received and processed from call.ring push notification`,
|
|
127
|
+
`call_cid:${call_cid} uuid:${uuid} received and processed from call.ring push notification`,
|
|
113
128
|
);
|
|
129
|
+
voipPushNotificationCallCId$.next(call_cid);
|
|
114
130
|
};
|
|
@@ -8,3 +8,64 @@ import type { NonRingingPushEvent } from '../../StreamVideoRN/types';
|
|
|
8
8
|
export const pushNonRingingCallData$ = new BehaviorSubject<
|
|
9
9
|
{ cid: string; type: NonRingingPushEvent } | undefined
|
|
10
10
|
>(undefined);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This rxjs subject is used to store the call cid of the accepted incoming call from push notification
|
|
14
|
+
* Note: it is should be subscribed only when a user has connected to the websocket of Stream
|
|
15
|
+
*/
|
|
16
|
+
export const pushAcceptedIncomingCallCId$ = new BehaviorSubject<
|
|
17
|
+
string | undefined
|
|
18
|
+
>(undefined);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This rxjs subject is used to store the call cid of the tapped incoming call from push notification it is neither accepted nor rejected yet
|
|
22
|
+
* Note: it should be subscribed only when a user has connected to the websocket of Stream
|
|
23
|
+
*/
|
|
24
|
+
export const pushTappedIncomingCallCId$ = new BehaviorSubject<
|
|
25
|
+
string | undefined
|
|
26
|
+
>(undefined);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This rxjs subject is used to store the call cid of the delivered incoming call from push notification it is neither accepted nor rejected yet
|
|
30
|
+
* Used so that the call is navigated to when app is open from being killed
|
|
31
|
+
* Note: it should be subscribed only when a user has connected to the websocket of Stream
|
|
32
|
+
*/
|
|
33
|
+
export const pushAndroidBackgroundDeliveredIncomingCallCId$ =
|
|
34
|
+
new BehaviorSubject<string | undefined>(undefined);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* This rxjs subject is used to store the call cid of the accepted incoming call from push notification
|
|
38
|
+
* Note: it should be subscribed only when a user has connected to the websocket of Stream
|
|
39
|
+
*/
|
|
40
|
+
export const pushRejectedIncomingCallCId$ = new BehaviorSubject<
|
|
41
|
+
string | undefined
|
|
42
|
+
>(undefined);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* This rxjs subject is used to store the call cid of the incoming call from ios voip pushkit notification
|
|
46
|
+
*/
|
|
47
|
+
export const voipPushNotificationCallCId$ = new BehaviorSubject<
|
|
48
|
+
string | undefined
|
|
49
|
+
>(undefined);
|
|
50
|
+
|
|
51
|
+
/** The pair of cid of a call and its corresponding uuid created in the native side */
|
|
52
|
+
type CallkeepMap = {
|
|
53
|
+
uuid: string;
|
|
54
|
+
cid: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
* This rxjs subject should only used to store the CallkeepMap
|
|
59
|
+
* for the incoming call when on foreground
|
|
60
|
+
* or in other words, when we get didDisplayIncomingCall from callkeep lib
|
|
61
|
+
*/
|
|
62
|
+
export const voipCallkeepCallOnForegroundMap$ = new BehaviorSubject<
|
|
63
|
+
CallkeepMap | undefined
|
|
64
|
+
>(undefined);
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* This rxjs subject should only used to store the CallkeepMap when it was accepted in the native dialer
|
|
68
|
+
*/
|
|
69
|
+
export const voipCallkeepAcceptedCallOnNativeDialerMap$ = new BehaviorSubject<
|
|
70
|
+
CallkeepMap | undefined
|
|
71
|
+
>(undefined);
|
|
@@ -10,12 +10,9 @@ import type {
|
|
|
10
10
|
} from '../../StreamVideoRN/types';
|
|
11
11
|
import { onNewCallNotification } from '../../internal/newNotificationCallbacks';
|
|
12
12
|
import { pushUnsubscriptionCallbacks } from './constants';
|
|
13
|
-
import { AppState } from 'react-native';
|
|
14
|
-
import type { EndCallReason } from '@stream-io/react-native-callingx';
|
|
15
13
|
|
|
16
14
|
type PushConfig = NonNullable<StreamVideoConfig['push']>;
|
|
17
15
|
|
|
18
|
-
const logger = videoLoggerSystem.getLogger('callingx');
|
|
19
16
|
type CanAddPushWSSubscriptionsRef = { current: boolean };
|
|
20
17
|
|
|
21
18
|
/**
|
|
@@ -27,40 +24,44 @@ export const shouldCallBeEnded = (
|
|
|
27
24
|
created_by_id: string | undefined,
|
|
28
25
|
receiver_id: string | undefined,
|
|
29
26
|
) => {
|
|
27
|
+
/* callkeep reasons for ending a call
|
|
28
|
+
FAILED: 1,
|
|
29
|
+
REMOTE_ENDED: 2,
|
|
30
|
+
UNANSWERED: 3,
|
|
31
|
+
ANSWERED_ELSEWHERE: 4,
|
|
32
|
+
DECLINED_ELSEWHERE: 5,
|
|
33
|
+
MISSED: 6
|
|
34
|
+
*/
|
|
30
35
|
const callSession = callFromPush.state.session;
|
|
31
36
|
const rejected_by = callSession?.rejected_by;
|
|
32
37
|
const accepted_by = callSession?.accepted_by;
|
|
33
38
|
let mustEndCall = false;
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
if (callFromPush.state.endedAt) {
|
|
37
|
-
mustEndCall = true;
|
|
38
|
-
endCallReason = 'remote';
|
|
39
|
-
} else if (created_by_id && rejected_by) {
|
|
39
|
+
let callkeepReason = 0;
|
|
40
|
+
if (created_by_id && rejected_by) {
|
|
40
41
|
if (rejected_by[created_by_id]) {
|
|
41
|
-
// call was cancelled by the caller
|
|
42
|
+
// call was cancelled by the caller
|
|
42
43
|
mustEndCall = true;
|
|
43
|
-
|
|
44
|
+
callkeepReason = 2;
|
|
44
45
|
}
|
|
45
46
|
} else if (receiver_id && rejected_by) {
|
|
46
47
|
if (rejected_by[receiver_id]) {
|
|
47
48
|
// call was rejected by the receiver in some other device
|
|
48
49
|
mustEndCall = true;
|
|
49
|
-
|
|
50
|
+
callkeepReason = 5;
|
|
50
51
|
}
|
|
51
52
|
} else if (receiver_id && accepted_by) {
|
|
52
53
|
if (accepted_by[receiver_id]) {
|
|
53
54
|
// call was accepted by the receiver in some other device
|
|
54
55
|
mustEndCall = true;
|
|
55
|
-
|
|
56
|
+
callkeepReason = 4;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
videoLoggerSystem
|
|
59
60
|
.getLogger('shouldCallBeEnded')
|
|
60
61
|
.debug(
|
|
61
|
-
`callCid: ${callFromPush.cid} mustEndCall: ${mustEndCall}
|
|
62
|
+
`callCid: ${callFromPush.cid} mustEndCall: ${mustEndCall} callkeepReason: ${callkeepReason}`,
|
|
62
63
|
);
|
|
63
|
-
return { mustEndCall,
|
|
64
|
+
return { mustEndCall, callkeepReason };
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
/* An action for the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
|
|
@@ -70,95 +71,71 @@ export const shouldCallBeEnded = (
|
|
|
70
71
|
export const processCallFromPushInBackground = async (
|
|
71
72
|
pushConfig: PushConfig,
|
|
72
73
|
call_cid: string,
|
|
73
|
-
action:
|
|
74
|
-
/**
|
|
75
|
-
* Callback to inform iOS CallKit that the action can be fulfilled
|
|
76
|
-
* Needed for iOS CallKit fullfillment of action
|
|
77
|
-
* as per ios docs "Instead, wait until you establish a connection and then fulfill the object."
|
|
78
|
-
* This means we wait until call.get() is done and call.join() or call.leave() is invoked (not completed) to fulfill the action
|
|
79
|
-
*/
|
|
80
|
-
onIOSActionCanBeFulfilled: (didFail: boolean) => void,
|
|
74
|
+
action: Parameters<typeof processCallFromPush>[2],
|
|
81
75
|
) => {
|
|
82
76
|
let videoClient: StreamVideoClient | undefined;
|
|
83
77
|
|
|
84
78
|
try {
|
|
85
79
|
videoClient = await pushConfig.createStreamVideoClient();
|
|
86
80
|
if (!videoClient) {
|
|
87
|
-
|
|
81
|
+
return;
|
|
88
82
|
}
|
|
89
83
|
} catch (e) {
|
|
90
|
-
logger.
|
|
91
|
-
'processCallFromPushInBackground
|
|
92
|
-
e,
|
|
84
|
+
const logger = videoLoggerSystem.getLogger(
|
|
85
|
+
'processCallFromPushInBackground',
|
|
93
86
|
);
|
|
94
|
-
|
|
87
|
+
logger.error('failed to create video client', e);
|
|
95
88
|
return;
|
|
96
89
|
}
|
|
90
|
+
await processCallFromPush(videoClient, call_cid, action, pushConfig);
|
|
91
|
+
};
|
|
97
92
|
|
|
93
|
+
/**
|
|
94
|
+
* This function is used process the call from push notifications due to incoming call
|
|
95
|
+
* It does the following steps:
|
|
96
|
+
* 1. Get the call from the client if present or create a new call
|
|
97
|
+
* 2. Fetch the latest state of the call from the server if its not already in ringing state
|
|
98
|
+
* 3. Join or leave the call based on the user's action.
|
|
99
|
+
*/
|
|
100
|
+
export const processCallFromPush = async (
|
|
101
|
+
client: StreamVideoClient,
|
|
102
|
+
call_cid: string,
|
|
103
|
+
action: 'accept' | 'decline' | 'pressed' | 'backgroundDelivered',
|
|
104
|
+
pushConfig: PushConfig,
|
|
105
|
+
) => {
|
|
98
106
|
let callFromPush: Call;
|
|
99
107
|
try {
|
|
100
|
-
callFromPush = await
|
|
108
|
+
callFromPush = await client.onRingingCall(call_cid);
|
|
101
109
|
} catch (e) {
|
|
102
|
-
logger.
|
|
103
|
-
|
|
104
|
-
e,
|
|
105
|
-
);
|
|
106
|
-
onIOSActionCanBeFulfilled(true);
|
|
110
|
+
const logger = videoLoggerSystem.getLogger('processCallFromPush');
|
|
111
|
+
logger.error('failed to fetch call from push notification', e);
|
|
107
112
|
return;
|
|
108
113
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
) {
|
|
121
|
-
logger.debug(
|
|
122
|
-
`skipping join call as it is not in ringing or idle state from push notification. callCid: ${callFromPush.cid}`,
|
|
123
|
-
);
|
|
124
|
-
onIOSActionCanBeFulfilled(true);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
try {
|
|
128
|
-
onIOSActionCanBeFulfilled(false);
|
|
114
|
+
// note: when action was pressed or delivered, we dont need to do anything as the only thing is to do is to get the call which adds it to the client
|
|
115
|
+
try {
|
|
116
|
+
if (action === 'accept') {
|
|
117
|
+
if (pushConfig.publishOptions) {
|
|
118
|
+
callFromPush.updatePublishOptions(pushConfig.publishOptions);
|
|
119
|
+
}
|
|
120
|
+
videoLoggerSystem
|
|
121
|
+
.getLogger('processCallFromPush')
|
|
122
|
+
.debug(
|
|
123
|
+
`joining call from push notification with callCid: ${callFromPush.cid}`,
|
|
124
|
+
);
|
|
129
125
|
await callFromPush.join();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
onIOSActionCanBeFulfilled(false);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const canReject =
|
|
143
|
-
callFromPush.state.callingState === CallingState.RINGING ||
|
|
144
|
-
callFromPush.state.callingState === CallingState.IDLE;
|
|
145
|
-
const isCurrentUserMember = callFromPush.state.members.some(
|
|
146
|
-
(member) => member.user_id === callFromPush.currentUserId,
|
|
147
|
-
);
|
|
148
|
-
const reject = canReject && isCurrentUserMember;
|
|
149
|
-
logger.debug(
|
|
150
|
-
`declining call from push notification with callCid: ${callFromPush.cid} reject: ${reject}`,
|
|
151
|
-
);
|
|
152
|
-
try {
|
|
153
|
-
await callFromPush.leave({ reject, reason: 'decline' });
|
|
154
|
-
onIOSActionCanBeFulfilled(false);
|
|
155
|
-
} catch (e) {
|
|
156
|
-
logger.warn(
|
|
157
|
-
'processCallFromPushInBackground: failed to decline call from push notification',
|
|
158
|
-
e,
|
|
159
|
-
);
|
|
160
|
-
onIOSActionCanBeFulfilled(true);
|
|
126
|
+
} else if (action === 'decline') {
|
|
127
|
+
const canReject =
|
|
128
|
+
callFromPush.state.callingState === CallingState.RINGING;
|
|
129
|
+
videoLoggerSystem
|
|
130
|
+
.getLogger('processCallFromPush')
|
|
131
|
+
.debug(
|
|
132
|
+
`declining call from push notification with callCid: ${callFromPush.cid} reject: ${canReject}`,
|
|
133
|
+
);
|
|
134
|
+
await callFromPush.leave({ reject: canReject, reason: 'decline' });
|
|
161
135
|
}
|
|
136
|
+
} catch (e) {
|
|
137
|
+
const logger = videoLoggerSystem.getLogger('processCallFromPush');
|
|
138
|
+
logger.warn(`failed to process ${action} call from push notification`, e);
|
|
162
139
|
}
|
|
163
140
|
};
|
|
164
141
|
|
|
@@ -186,13 +163,10 @@ export const processNonIncomingCallFromPush = async (
|
|
|
186
163
|
await callFromPush.get();
|
|
187
164
|
}
|
|
188
165
|
} catch (e) {
|
|
189
|
-
const
|
|
166
|
+
const logger = videoLoggerSystem.getLogger(
|
|
190
167
|
'processNonIncomingCallFromPush',
|
|
191
168
|
);
|
|
192
|
-
|
|
193
|
-
'failed to fetch call from push notification',
|
|
194
|
-
e,
|
|
195
|
-
);
|
|
169
|
+
logger.error('failed to fetch call from push notification', e);
|
|
196
170
|
return;
|
|
197
171
|
}
|
|
198
172
|
onNewCallNotification(callFromPush, nonRingingNotificationType);
|
|
@@ -217,21 +191,3 @@ export const clearPushWSEventSubscriptions = (call_cid: string) => {
|
|
|
217
191
|
export const canAddPushWSSubscriptionsRef: CanAddPushWSSubscriptionsRef = {
|
|
218
192
|
current: true,
|
|
219
193
|
};
|
|
220
|
-
|
|
221
|
-
export const canListenToWS = () =>
|
|
222
|
-
canAddPushWSSubscriptionsRef.current && AppState.currentState !== 'active';
|
|
223
|
-
|
|
224
|
-
export const shouldCallBeClosed = (
|
|
225
|
-
call: Call,
|
|
226
|
-
pushData: { [key: string]: string | object },
|
|
227
|
-
) => {
|
|
228
|
-
const created_by_id = pushData?.created_by_id as string;
|
|
229
|
-
const receiver_id = pushData?.receiver_id as string;
|
|
230
|
-
|
|
231
|
-
const { mustEndCall, endCallReason } = shouldCallBeEnded(
|
|
232
|
-
call,
|
|
233
|
-
created_by_id,
|
|
234
|
-
receiver_id,
|
|
235
|
-
);
|
|
236
|
-
return { mustEndCall, endCallReason };
|
|
237
|
-
};
|
package/src/utils/push/ios.ts
CHANGED
|
@@ -62,7 +62,12 @@ export const oniOSExpoNotificationEvent = (event: ExpoNotification) => {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
export const oniOSNotifeeEvent = ({
|
|
65
|
+
export const oniOSNotifeeEvent = ({
|
|
66
|
+
event,
|
|
67
|
+
}: {
|
|
68
|
+
event: Event;
|
|
69
|
+
isBackground: boolean;
|
|
70
|
+
}) => {
|
|
66
71
|
if (Platform.OS !== 'ios') return;
|
|
67
72
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
68
73
|
const { type, detail } = event;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type RNCallKeepType = typeof import('react-native-callkeep').default;
|
|
2
|
+
|
|
3
|
+
let callkeep: RNCallKeepType | undefined;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
callkeep = require('react-native-callkeep').default;
|
|
7
|
+
} catch {}
|
|
8
|
+
|
|
9
|
+
export function getCallKeepLib() {
|
|
10
|
+
if (!callkeep) {
|
|
11
|
+
throw Error(
|
|
12
|
+
'react-native-callkeep library is not installed. Please see https://github.com/react-native-webrtc/react-native-callkeep#Installation for installation instructions',
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return callkeep;
|
|
16
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from './expoNotifications';
|
|
2
2
|
export * from './firebaseMessaging';
|
|
3
3
|
export * from './iosPushNotification';
|
|
4
|
+
export * from './voipPushNotification';
|
|
5
|
+
export * from './callkeep';
|
|
4
6
|
export * from './notifee';
|
|
5
|
-
export * from './callingx';
|
|
6
7
|
|
|
7
8
|
/*
|
|
8
9
|
NOTE: must keep each libs in different files
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { PermissionsAndroid } from 'react-native';
|
|
1
2
|
import { lib, type Type } from './lib';
|
|
3
|
+
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
2
4
|
|
|
3
5
|
export type NotifeeLib = Type;
|
|
4
6
|
|
|
@@ -34,9 +36,34 @@ export function getNotifeeLibThrowIfNotInstalledForPush() {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export function getNotifeeLibNoThrowForKeepCallAlive() {
|
|
39
|
+
if (!lib) {
|
|
40
|
+
const logger = videoLoggerSystem.getLogger('getNotifeeLibNoThrow');
|
|
41
|
+
logger.info(
|
|
42
|
+
`${'@notifee/react-native library not installed. It is required to keep call alive in the background for Android. '}${INSTALLATION_INSTRUCTION}`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
37
45
|
return lib;
|
|
38
46
|
}
|
|
39
47
|
|
|
48
|
+
export async function getKeepCallAliveForegroundServiceTypes() {
|
|
49
|
+
const types: AndroidForegroundServiceType[] = [
|
|
50
|
+
AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK,
|
|
51
|
+
];
|
|
52
|
+
const hasCameraPermission = await PermissionsAndroid.check(
|
|
53
|
+
PermissionsAndroid.PERMISSIONS.CAMERA!,
|
|
54
|
+
);
|
|
55
|
+
if (hasCameraPermission) {
|
|
56
|
+
types.push(AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_CAMERA);
|
|
57
|
+
}
|
|
58
|
+
const hasMicrophonePermission = await PermissionsAndroid.check(
|
|
59
|
+
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO!,
|
|
60
|
+
);
|
|
61
|
+
if (hasMicrophonePermission) {
|
|
62
|
+
types.push(AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_MICROPHONE);
|
|
63
|
+
}
|
|
64
|
+
return types;
|
|
65
|
+
}
|
|
66
|
+
|
|
40
67
|
export function getIncomingCallForegroundServiceTypes() {
|
|
41
68
|
const types: AndroidForegroundServiceType[] = [
|
|
42
69
|
AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type VoipPushNotificationType =
|
|
2
|
+
typeof import('react-native-voip-push-notification').default;
|
|
3
|
+
|
|
4
|
+
let voipPushNotification: VoipPushNotificationType | undefined;
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
voipPushNotification = require('react-native-voip-push-notification').default;
|
|
8
|
+
} catch {}
|
|
9
|
+
|
|
10
|
+
export function getVoipPushNotificationLib() {
|
|
11
|
+
if (!voipPushNotification) {
|
|
12
|
+
throw Error(
|
|
13
|
+
"react-native-voip-push-notification library is not installed. Please install it using 'yarn add react-native-voip-push-notification' or 'npm i react-native-voip-push-notification --save'",
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return voipPushNotification;
|
|
17
|
+
}
|