@stream-io/video-react-native-sdk 1.43.0 → 1.45.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/CHANGELOG.md +44 -1
- package/dist/commonjs/components/Call/CallControls/internal/ReactionsPicker.js.map +1 -1
- package/dist/commonjs/components/Call/Lobby/Lobby.js +4 -9
- package/dist/commonjs/components/Call/Lobby/Lobby.js.map +1 -1
- package/dist/commonjs/components/Call/Lobby/LobbyCameraPreview.js +93 -0
- package/dist/commonjs/components/Call/Lobby/LobbyCameraPreview.js.map +1 -0
- package/dist/commonjs/components/Call/Lobby/index.js +11 -0
- package/dist/commonjs/components/Call/Lobby/index.js.map +1 -1
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js +4 -15
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js.map +1 -1
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/index.js +10 -4
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/index.js.map +1 -1
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +9 -5
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/commonjs/hooks/useLoopbackRecording.js +10 -127
- package/dist/commonjs/hooks/useLoopbackRecording.js.map +1 -1
- package/dist/commonjs/modules/call-manager/CallManager.js +37 -54
- package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +2 -0
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +28 -39
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/commonjs/utils/internal/registerMediaEngine.js +41 -0
- package/dist/commonjs/utils/internal/registerMediaEngine.js.map +1 -0
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +93 -35
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +13 -175
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/android.js +186 -0
- package/dist/commonjs/utils/push/internal/android.js.map +1 -0
- package/dist/commonjs/utils/push/libs/firebaseMessaging/index.js +8 -9
- package/dist/commonjs/utils/push/libs/firebaseMessaging/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/firebaseMessaging/lib.js +1 -1
- package/dist/commonjs/utils/push/libs/firebaseMessaging/lib.js.map +1 -1
- package/dist/commonjs/utils/push/setupAndroidPushEvents.js +25 -0
- package/dist/commonjs/utils/push/setupAndroidPushEvents.js.map +1 -0
- package/dist/commonjs/utils/push/setupCallingExpEvents.js +6 -2
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -1
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/commonjs/utils/push/utils.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/module/components/Call/CallControls/internal/ReactionsPicker.js.map +1 -1
- package/dist/module/components/Call/Lobby/Lobby.js +4 -9
- package/dist/module/components/Call/Lobby/Lobby.js.map +1 -1
- package/dist/module/components/Call/Lobby/LobbyCameraPreview.js +87 -0
- package/dist/module/components/Call/Lobby/LobbyCameraPreview.js.map +1 -0
- package/dist/module/components/Call/Lobby/index.js +1 -0
- package/dist/module/components/Call/Lobby/index.js.map +1 -1
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js +6 -17
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js.map +1 -1
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/index.js +11 -5
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/index.js.map +1 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +9 -5
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/module/hooks/useLoopbackRecording.js +10 -127
- package/dist/module/hooks/useLoopbackRecording.js.map +1 -1
- package/dist/module/modules/call-manager/CallManager.js +36 -53
- package/dist/module/modules/call-manager/CallManager.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +2 -0
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/callingx/callingx.js +27 -40
- package/dist/module/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/module/utils/internal/registerMediaEngine.js +37 -0
- package/dist/module/utils/internal/registerMediaEngine.js.map +1 -0
- package/dist/module/utils/internal/registerSDKGlobals.js +95 -37
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/push/android.js +16 -178
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/android.js +182 -0
- package/dist/module/utils/push/internal/android.js.map +1 -0
- package/dist/module/utils/push/libs/firebaseMessaging/index.js +8 -8
- package/dist/module/utils/push/libs/firebaseMessaging/index.js.map +1 -1
- package/dist/module/utils/push/libs/firebaseMessaging/lib.js +1 -1
- package/dist/module/utils/push/libs/firebaseMessaging/lib.js.map +1 -1
- package/dist/module/utils/push/setupAndroidPushEvents.js +21 -0
- package/dist/module/utils/push/setupAndroidPushEvents.js.map +1 -0
- package/dist/module/utils/push/setupCallingExpEvents.js +6 -2
- package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -1
- package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/module/utils/push/utils.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/components/Call/Lobby/Lobby.d.ts.map +1 -1
- package/dist/typescript/components/Call/Lobby/LobbyCameraPreview.d.ts +28 -0
- package/dist/typescript/components/Call/Lobby/LobbyCameraPreview.d.ts.map +1 -0
- package/dist/typescript/components/Call/Lobby/index.d.ts +1 -0
- package/dist/typescript/components/Call/Lobby/index.d.ts.map +1 -1
- package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.d.ts +11 -6
- package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.d.ts.map +1 -1
- package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/index.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useLoopbackRecording.d.ts +12 -69
- package/dist/typescript/hooks/useLoopbackRecording.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/CallManager.d.ts +28 -6
- package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/types.d.ts +0 -1
- package/dist/typescript/modules/call-manager/types.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +3 -0
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/callingx/callingx.d.ts +2 -0
- package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +1 -1
- package/dist/typescript/utils/internal/registerMediaEngine.d.ts +15 -0
- package/dist/typescript/utils/internal/registerMediaEngine.d.ts.map +1 -0
- package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
- package/dist/typescript/utils/push/android.d.ts +3 -4
- package/dist/typescript/utils/push/android.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/android.d.ts +8 -0
- package/dist/typescript/utils/push/internal/android.d.ts.map +1 -0
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +6 -5
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/firebaseMessaging/lib.d.ts +2 -2
- package/dist/typescript/utils/push/libs/firebaseMessaging/lib.d.ts.map +1 -1
- package/dist/typescript/utils/push/setupAndroidPushEvents.d.ts +3 -0
- package/dist/typescript/utils/push/setupAndroidPushEvents.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -1
- package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
- package/dist/typescript/utils/push/utils.d.ts +2 -2
- package/dist/typescript/utils/push/utils.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/ios/StreamInCallManager.m +4 -0
- package/ios/StreamInCallManager.swift +42 -10
- package/ios/TracksRecorder/RecorderVideoSink.swift +92 -5
- package/package.json +8 -8
- package/src/components/Call/CallControls/internal/ReactionsPicker.tsx +2 -2
- package/src/components/Call/Lobby/Lobby.tsx +4 -11
- package/src/components/Call/Lobby/LobbyCameraPreview.tsx +99 -0
- package/src/components/Call/Lobby/index.ts +1 -0
- package/src/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.tsx +56 -75
- package/src/components/Participant/ParticipantView/VideoRenderer/index.tsx +18 -7
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +12 -5
- package/src/hooks/useLoopbackRecording.ts +36 -248
- package/src/modules/call-manager/CallManager.ts +40 -71
- package/src/modules/call-manager/native-module.d.ts +13 -0
- package/src/modules/call-manager/types.ts +0 -1
- package/src/utils/StreamVideoRN/index.ts +2 -0
- package/src/utils/StreamVideoRN/types.ts +3 -0
- package/src/utils/internal/callingx/callingx.ts +37 -46
- package/src/utils/internal/registerMediaEngine.ts +42 -0
- package/src/utils/internal/registerSDKGlobals.ts +115 -42
- package/src/utils/push/android.ts +20 -253
- package/src/utils/push/internal/android.ts +252 -0
- package/src/utils/push/libs/firebaseMessaging/index.ts +14 -22
- package/src/utils/push/libs/firebaseMessaging/lib.ts +3 -3
- package/src/utils/push/setupAndroidPushEvents.ts +25 -0
- package/src/utils/push/setupCallingExpEvents.ts +6 -3
- package/src/utils/push/setupIosVoipPushEvents.ts +8 -7
- package/src/utils/push/utils.ts +2 -4
- package/src/version.ts +1 -1
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AllCallEvents,
|
|
3
|
+
AllClientEventTypes,
|
|
4
|
+
CallingState,
|
|
5
|
+
StreamVideoClient,
|
|
6
|
+
} from '@stream-io/video-client';
|
|
7
|
+
import { AppState, Platform } from 'react-native';
|
|
8
|
+
import {
|
|
9
|
+
type FirebaseRemoteMessage,
|
|
10
|
+
getCallingxLib,
|
|
11
|
+
getCallingxLibIfAvailable,
|
|
12
|
+
} from '../libs';
|
|
13
|
+
import { StreamVideoRN } from '../../StreamVideoRN';
|
|
14
|
+
import { pushUnsubscriptionCallbacks } from './constants';
|
|
15
|
+
import { canListenToWS, shouldCallBeClosed } from './utils';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Handles a Stream Video `call.ring` push payload: connects the WS to watch the ringing call
|
|
19
|
+
* and auto-dismisses it if it has already ended/been handled elsewhere. Non-ringing types are
|
|
20
|
+
* ignored (their display is app responsibility). Android-only; a no-op on other platforms.
|
|
21
|
+
*/
|
|
22
|
+
export const onRingNotificationReceived = async (
|
|
23
|
+
data: FirebaseRemoteMessage['data'],
|
|
24
|
+
) => {
|
|
25
|
+
/* Example data from firebase
|
|
26
|
+
"message": {
|
|
27
|
+
"data": {
|
|
28
|
+
call_cid: 'audio_room:dcc1638c-e90d-4dcb-bf3b-8fa7767bfbb0',
|
|
29
|
+
call_display_name: '',
|
|
30
|
+
created_by_display_name: 'tommaso',
|
|
31
|
+
created_by_id: 'tommaso-03dcddb7-e9e2-42ec-b2f3-5043aac666ee',
|
|
32
|
+
receiver_id: 'martin-21824f17-319b-401b-a61b-fcab646f0d3f',
|
|
33
|
+
sender: 'stream.video',
|
|
34
|
+
type: 'call.live_started',
|
|
35
|
+
version: 'v2'
|
|
36
|
+
},
|
|
37
|
+
// other stuff
|
|
38
|
+
}
|
|
39
|
+
*/
|
|
40
|
+
if (Platform.OS !== 'android') return;
|
|
41
|
+
|
|
42
|
+
const nativeLog = (
|
|
43
|
+
message: string,
|
|
44
|
+
level: 'debug' | 'info' | 'warn' | 'error' = 'debug',
|
|
45
|
+
) =>
|
|
46
|
+
getCallingxLibIfAvailable()?.log(
|
|
47
|
+
`[callingx - onRingNotificationReceived]: ${message}`,
|
|
48
|
+
level,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
52
|
+
if (
|
|
53
|
+
!pushConfig ||
|
|
54
|
+
!data ||
|
|
55
|
+
data.sender !== 'stream.video' ||
|
|
56
|
+
data.type !== 'call.ring'
|
|
57
|
+
) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const call_cid = data.call_cid as string;
|
|
62
|
+
const callingx = getCallingxLib();
|
|
63
|
+
|
|
64
|
+
if (pushUnsubscriptionCallbacks.has(call_cid)) {
|
|
65
|
+
nativeLog(
|
|
66
|
+
`call_cid ${call_cid} is already being watched, skipping the duplicate call.ring notification`,
|
|
67
|
+
);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const asForegroundService = canListenToWS();
|
|
72
|
+
const backgroundTaskOwner = `push:${call_cid}`;
|
|
73
|
+
nativeLog(
|
|
74
|
+
`call.ring for callCid: ${call_cid} asForegroundService=${asForegroundService}`,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const finishBackgroundTask = () => {
|
|
78
|
+
nativeLog(`Finishing background task for callCid: ${call_cid}`);
|
|
79
|
+
callingx.releaseBackgroundTask(backgroundTaskOwner);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (asForegroundService) {
|
|
83
|
+
// initialize the callback array immediately to avoid race condition
|
|
84
|
+
pushUnsubscriptionCallbacks.set(call_cid, []);
|
|
85
|
+
// The owner is added synchronously inside acquireBackgroundTask (before its own await), so it
|
|
86
|
+
// is registered immediately even though we don't await the returned promise here.
|
|
87
|
+
nativeLog(`acquiring background task for callCid: ${call_cid}`);
|
|
88
|
+
callingx.acquireBackgroundTask(backgroundTaskOwner).catch((e) => {
|
|
89
|
+
nativeLog(
|
|
90
|
+
`Failed to acquire background task for callCid: ${call_cid} error: ${e}`,
|
|
91
|
+
'error',
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let client: StreamVideoClient | undefined;
|
|
97
|
+
try {
|
|
98
|
+
client = await pushConfig.createStreamVideoClient();
|
|
99
|
+
if (!client) {
|
|
100
|
+
nativeLog(`video client not found, skipping the call.ring notification`);
|
|
101
|
+
if (asForegroundService) {
|
|
102
|
+
finishBackgroundTask();
|
|
103
|
+
}
|
|
104
|
+
await callingx.stopService();
|
|
105
|
+
pushUnsubscriptionCallbacks.delete(call_cid);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
//we need to release the background task and stop the service to avoid stale owner
|
|
110
|
+
nativeLog(`Failed to create video client: ${error}`, 'error');
|
|
111
|
+
if (asForegroundService) {
|
|
112
|
+
finishBackgroundTask();
|
|
113
|
+
}
|
|
114
|
+
await callingx.stopService();
|
|
115
|
+
pushUnsubscriptionCallbacks.delete(call_cid);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (asForegroundService) {
|
|
120
|
+
// Listen to call events from WS with the keep-alive headless task, bound to the call service.
|
|
121
|
+
(async () => {
|
|
122
|
+
try {
|
|
123
|
+
nativeLog(`onRingingCall (fg service) for callCid: ${call_cid}`);
|
|
124
|
+
const callFromPush = await client.onRingingCall(call_cid);
|
|
125
|
+
const { mustEndCall, endCallReason } = shouldCallBeClosed(
|
|
126
|
+
callFromPush,
|
|
127
|
+
data,
|
|
128
|
+
);
|
|
129
|
+
if (mustEndCall) {
|
|
130
|
+
nativeLog(
|
|
131
|
+
`Closing fg service callCid: ${call_cid} endCallReason: ${endCallReason}`,
|
|
132
|
+
);
|
|
133
|
+
callingx.endCallWithReason(call_cid, endCallReason);
|
|
134
|
+
callFromPush.leave({ reject: false }).catch((error) => {
|
|
135
|
+
nativeLog(
|
|
136
|
+
`Failed to leave already-ended ringing call ${call_cid}: ${error}`,
|
|
137
|
+
'error',
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
finishBackgroundTask();
|
|
141
|
+
pushUnsubscriptionCallbacks.delete(call_cid);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// prevent subscriptions in case of call being left and subscriptions being already cleared
|
|
146
|
+
const unsubscribeFunctions = pushUnsubscriptionCallbacks.get(call_cid);
|
|
147
|
+
if (!unsubscribeFunctions) {
|
|
148
|
+
nativeLog(
|
|
149
|
+
`ring cancelled during onRingingCall for callCid: ${call_cid}, releasing background task`,
|
|
150
|
+
);
|
|
151
|
+
finishBackgroundTask();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
nativeLog(`watching WS for ringing callCid: ${call_cid}`);
|
|
155
|
+
// check if service needs to be closed if accept/decline event was done on another device
|
|
156
|
+
const unsubscribe = callFromPush.on(
|
|
157
|
+
'all',
|
|
158
|
+
(event: AllCallEvents[AllClientEventTypes]) => {
|
|
159
|
+
const _canListenToWS = canListenToWS();
|
|
160
|
+
if (!_canListenToWS) {
|
|
161
|
+
nativeLog(
|
|
162
|
+
`Closing fg service from event ${event.type} callCid: ${call_cid} canListenToWS: ${_canListenToWS}`,
|
|
163
|
+
);
|
|
164
|
+
unsubscribeFunctions.forEach((fn) => fn());
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const {
|
|
169
|
+
mustEndCall: mustEndCallFromEvent,
|
|
170
|
+
endCallReason: endCallReasonFromEvent,
|
|
171
|
+
} = shouldCallBeClosed(callFromPush, data);
|
|
172
|
+
if (mustEndCallFromEvent) {
|
|
173
|
+
nativeLog(
|
|
174
|
+
`Closing fg service from event ${event.type} callCid: ${call_cid} shouldCallBeClosed`,
|
|
175
|
+
);
|
|
176
|
+
callingx.endCallWithReason(call_cid, endCallReasonFromEvent);
|
|
177
|
+
unsubscribeFunctions.forEach((fn) => fn());
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// check if service needs to be closed if call was left
|
|
183
|
+
const stateSubscription = callFromPush.state.callingState$.subscribe(
|
|
184
|
+
(callingState) => {
|
|
185
|
+
if (
|
|
186
|
+
callingState === CallingState.IDLE ||
|
|
187
|
+
callingState === CallingState.LEFT
|
|
188
|
+
) {
|
|
189
|
+
nativeLog(
|
|
190
|
+
`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`,
|
|
191
|
+
);
|
|
192
|
+
unsubscribeFunctions.forEach((fn) => fn());
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
//stop background task when app comes to foreground
|
|
198
|
+
const appStateSubscription = AppState.addEventListener(
|
|
199
|
+
'change',
|
|
200
|
+
(nextAppState) => {
|
|
201
|
+
const _canListenToWS = canListenToWS();
|
|
202
|
+
nativeLog(
|
|
203
|
+
`AppState changed to: ${nextAppState} for callCid: ${call_cid} canListenToWS: ${_canListenToWS}`,
|
|
204
|
+
);
|
|
205
|
+
if (!_canListenToWS) {
|
|
206
|
+
unsubscribeFunctions.forEach((fn) => fn());
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
unsubscribeFunctions.push(unsubscribe);
|
|
213
|
+
unsubscribeFunctions.push(() => stateSubscription.unsubscribe());
|
|
214
|
+
unsubscribeFunctions.push(() => appStateSubscription.remove());
|
|
215
|
+
unsubscribeFunctions.push(finishBackgroundTask);
|
|
216
|
+
unsubscribeFunctions.push(() =>
|
|
217
|
+
pushUnsubscriptionCallbacks.delete(call_cid),
|
|
218
|
+
);
|
|
219
|
+
nativeLog(`WS subscriptions registered for callCid: ${call_cid}`);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
nativeLog(
|
|
222
|
+
`Failed to start background task with callCid: ${call_cid} error: ${error}`,
|
|
223
|
+
'error',
|
|
224
|
+
);
|
|
225
|
+
pushUnsubscriptionCallbacks.delete(call_cid);
|
|
226
|
+
finishBackgroundTask();
|
|
227
|
+
}
|
|
228
|
+
})();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (asForegroundService) {
|
|
232
|
+
// no need to check if call has be closed as that will be handled by the fg service
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
nativeLog(`onRingingCall (foreground) for callCid: ${call_cid}`);
|
|
237
|
+
const callFromPush = await client.onRingingCall(call_cid);
|
|
238
|
+
|
|
239
|
+
const { mustEndCall, endCallReason } = shouldCallBeClosed(callFromPush, data);
|
|
240
|
+
if (mustEndCall) {
|
|
241
|
+
nativeLog(
|
|
242
|
+
`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`,
|
|
243
|
+
);
|
|
244
|
+
callingx.endCallWithReason(call_cid, endCallReason);
|
|
245
|
+
callFromPush.leave({ reject: false }).catch((error) => {
|
|
246
|
+
nativeLog(
|
|
247
|
+
`Failed to leave already-ended ringing call ${call_cid}: ${error}`,
|
|
248
|
+
'error',
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { lib, type
|
|
2
|
-
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
3
|
-
|
|
4
|
-
export type { FirebaseMessagingTypes } from '@react-native-firebase/messaging';
|
|
5
|
-
export type FirebaseMessagingType = Type;
|
|
1
|
+
import { lib, type MessagingModule } from './lib';
|
|
6
2
|
|
|
7
3
|
const INSTALLATION_INSTRUCTION =
|
|
8
4
|
'Please see https://rnfirebase.io/messaging/usage#installation for installation instructions';
|
|
9
5
|
|
|
10
|
-
export
|
|
6
|
+
export type FirebaseRemoteMessage = NonNullable<
|
|
7
|
+
Awaited<ReturnType<MessagingModule['getInitialNotification']>>
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
function getFirebaseMessagingModule() {
|
|
11
11
|
if (!lib) {
|
|
12
12
|
throw Error(
|
|
13
13
|
'@react-native-firebase/messaging is not installed. ' +
|
|
@@ -17,20 +17,12 @@ export function getFirebaseMessagingLib(): FirebaseMessagingType {
|
|
|
17
17
|
return lib;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
`${
|
|
29
|
-
isExpo
|
|
30
|
-
? 'In Expo, @react-native-firebase/messaging library is required to receive ringing notifications in app killed state for Android.'
|
|
31
|
-
: ''
|
|
32
|
-
}${INSTALLATION_INSTRUCTION}`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
return lib;
|
|
20
|
+
export function getFirebaseMessagingLib() {
|
|
21
|
+
const messagingModule = getFirebaseMessagingModule();
|
|
22
|
+
const messaging = messagingModule.getMessaging();
|
|
23
|
+
return () => ({
|
|
24
|
+
getToken: () => messagingModule.getToken(messaging),
|
|
25
|
+
onTokenRefresh: (listener: (token: string) => void) =>
|
|
26
|
+
messagingModule.onTokenRefresh(messaging, listener),
|
|
27
|
+
});
|
|
36
28
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type MessagingModule = typeof import('@react-native-firebase/messaging');
|
|
2
2
|
|
|
3
|
-
let lib:
|
|
3
|
+
let lib: MessagingModule | undefined;
|
|
4
4
|
|
|
5
5
|
try {
|
|
6
|
-
lib = require('@react-native-firebase/messaging')
|
|
6
|
+
lib = require('@react-native-firebase/messaging');
|
|
7
7
|
} catch {}
|
|
8
8
|
|
|
9
9
|
export { lib };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
3
|
+
import { StreamVideoConfig } from '../StreamVideoRN/types';
|
|
4
|
+
import { getCallingxLib } from './libs';
|
|
5
|
+
import { onRingNotificationReceived } from './internal/android';
|
|
6
|
+
|
|
7
|
+
export function setupAndroidPushEvents(
|
|
8
|
+
pushConfig: NonNullable<StreamVideoConfig['push']>,
|
|
9
|
+
) {
|
|
10
|
+
const logger = videoLoggerSystem.getLogger('setupAndroidPushEvents');
|
|
11
|
+
if (Platform.OS !== 'android' || !pushConfig.android?.pushProviderName) {
|
|
12
|
+
logger.debug(
|
|
13
|
+
`setupAndroidPushEvents skipped: platform=${Platform.OS} pushProviderName=${pushConfig.android?.pushProviderName}`,
|
|
14
|
+
);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const callingx = getCallingxLib();
|
|
19
|
+
callingx.addEventListener('ringCallPushReceived', (params) => {
|
|
20
|
+
logger.debug(`ringCallPushReceived event call_cid: ${params?.call_cid}`);
|
|
21
|
+
onRingNotificationReceived(params).catch((error) => {
|
|
22
|
+
logger.error(`Error in onRingNotificationReceived: ${error}`);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type EventParams,
|
|
15
15
|
} from './libs/callingx';
|
|
16
16
|
import { Platform } from 'react-native';
|
|
17
|
+
import { onRingNotificationReceived } from './internal/android';
|
|
17
18
|
|
|
18
19
|
type PushConfig = NonNullable<StreamVideoConfig['push']>;
|
|
19
20
|
|
|
@@ -62,11 +63,10 @@ export function setupCallingExpEvents(pushConfig: NonNullable<PushConfig>) {
|
|
|
62
63
|
const events = callingx.getInitialEvents();
|
|
63
64
|
events.forEach((event: EventData) => {
|
|
64
65
|
const { eventName, params } = event;
|
|
66
|
+
logger.debug(`${eventName} delayed event`);
|
|
65
67
|
if (eventName === 'answerCall') {
|
|
66
|
-
logger.debug(`answerCall delayed event callId: ${params?.callId}`);
|
|
67
68
|
onAcceptCall(pushConfig)(params as EventParams['answerCall']);
|
|
68
69
|
} else if (eventName === 'endCall') {
|
|
69
|
-
logger.debug(`endCall delayed event callId: ${params?.callId}`);
|
|
70
70
|
onEndCall(pushConfig)(params as EventParams['endCall']);
|
|
71
71
|
} else if (eventName === 'didActivateAudioSession') {
|
|
72
72
|
onDidActivateAudioSession();
|
|
@@ -74,6 +74,10 @@ export function setupCallingExpEvents(pushConfig: NonNullable<PushConfig>) {
|
|
|
74
74
|
onDidDeactivateAudioSession();
|
|
75
75
|
} else if (eventName === 'providerReset') {
|
|
76
76
|
onProviderReset(pushConfig)(params as EventParams['providerReset']);
|
|
77
|
+
} else if (eventName === 'ringCallPushReceived') {
|
|
78
|
+
onRingNotificationReceived(params).catch((error) => {
|
|
79
|
+
logger.error(`Error in onRingNotificationReceived: ${error}`);
|
|
80
|
+
});
|
|
77
81
|
}
|
|
78
82
|
});
|
|
79
83
|
}
|
|
@@ -128,7 +132,6 @@ const onAcceptCall =
|
|
|
128
132
|
|
|
129
133
|
const callingx = getCallingxLib();
|
|
130
134
|
clearPushWSEventSubscriptions(call_cid);
|
|
131
|
-
|
|
132
135
|
processCallFromPushInBackground(
|
|
133
136
|
pushConfig,
|
|
134
137
|
call_cid,
|
|
@@ -9,20 +9,21 @@ import { getCallingxLib } from './libs';
|
|
|
9
9
|
export function setupIosVoipPushEvents(
|
|
10
10
|
pushConfig: NonNullable<StreamVideoConfig['push']>,
|
|
11
11
|
) {
|
|
12
|
-
if (Platform.OS !== 'ios' || !pushConfig.ios?.pushProviderName) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
12
|
const logger = videoLoggerSystem.getLogger('setupIosVoipPushEvents');
|
|
16
|
-
if (!pushConfig.ios
|
|
17
|
-
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
13
|
+
if (Platform.OS !== 'ios' || !pushConfig.ios?.pushProviderName) {
|
|
18
14
|
logger.debug(
|
|
19
|
-
|
|
15
|
+
`setupIosVoipPushEvents skipped: platform=${Platform.OS} pushProviderName=${pushConfig.ios?.pushProviderName}`,
|
|
20
16
|
);
|
|
21
17
|
return;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
const callingx = getCallingxLib();
|
|
25
21
|
callingx.addEventListener('voipNotificationReceived', (params) => {
|
|
26
|
-
|
|
22
|
+
logger.debug(
|
|
23
|
+
`voipNotificationReceived event call_cid: ${params?.stream?.call_cid}`,
|
|
24
|
+
);
|
|
25
|
+
onVoipNotificationReceived(params, pushConfig).catch((error) => {
|
|
26
|
+
logger.error(`Error in onVoipNotificationReceived: ${error}`);
|
|
27
|
+
});
|
|
27
28
|
});
|
|
28
29
|
}
|
package/src/utils/push/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FirebaseRemoteMessage } from './libs/firebaseMessaging';
|
|
2
2
|
import type { NonRingingPushEvent } from '../StreamVideoRN/types';
|
|
3
3
|
|
|
4
4
|
export type StreamPushPayload =
|
|
@@ -9,8 +9,6 @@ export type StreamPushPayload =
|
|
|
9
9
|
}
|
|
10
10
|
| undefined;
|
|
11
11
|
|
|
12
|
-
export function isFirebaseStreamVideoMessage(
|
|
13
|
-
message: FirebaseMessagingTypes.RemoteMessage,
|
|
14
|
-
) {
|
|
12
|
+
export function isFirebaseStreamVideoMessage(message: FirebaseRemoteMessage) {
|
|
15
13
|
return message.data?.sender === 'stream.video';
|
|
16
14
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.45.0';
|