@stream-io/video-react-native-sdk 1.10.12 → 1.10.14
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 +18 -0
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +7 -17
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +34 -0
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -0
- package/dist/commonjs/hooks/push/index.js +0 -2
- package/dist/commonjs/hooks/push/index.js.map +1 -1
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +20 -23
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +6 -103
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +4 -0
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/push/ios.js +95 -1
- package/dist/commonjs/utils/push/ios.js.map +1 -1
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +150 -0
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +27 -0
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +9 -19
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipNative.js +26 -0
- package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -0
- package/dist/module/hooks/push/index.js +0 -2
- package/dist/module/hooks/push/index.js.map +1 -1
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +21 -24
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +10 -108
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +4 -0
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/push/ios.js +97 -4
- package/dist/module/utils/push/ios.js.map +1 -1
- package/dist/module/utils/push/setupIosCallKeepEvents.js +145 -0
- package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/module/utils/push/setupIosVoipPushEvents.js +21 -0
- package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -0
- package/dist/module/version.js +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +8 -0
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -0
- package/dist/typescript/hooks/push/index.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/ios.d.ts +1 -0
- package/dist/typescript/utils/push/ios.d.ts.map +1 -1
- 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 +3 -0
- package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -0
- package/dist/typescript/version.d.ts +1 -1
- package/ios/PictureInPicture/StreamPictureInPictureController.swift +7 -0
- package/ios/RTCViewPip.swift +52 -25
- package/ios/RTCViewPipManager.swift +5 -5
- package/ios/StreamVideoReactNative.m +72 -22
- package/package.json +3 -3
- package/src/components/Call/CallContent/RTCViewPipIOS.tsx +15 -38
- package/src/components/Call/CallContent/RTCViewPipNative.tsx +51 -0
- package/src/hooks/push/index.ts +0 -2
- package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +37 -31
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +10 -145
- package/src/utils/StreamVideoRN/index.ts +5 -0
- package/src/utils/push/ios.ts +135 -3
- package/src/utils/push/setupIosCallKeepEvents.ts +187 -0
- package/src/utils/push/setupIosVoipPushEvents.ts +29 -0
- package/src/version.ts +1 -1
- package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js +0 -109
- package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js.map +0 -1
- package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js +0 -103
- package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js.map +0 -1
- package/dist/typescript/hooks/push/useIosCallKeepEventsSetupEffect.d.ts +0 -5
- package/dist/typescript/hooks/push/useIosCallKeepEventsSetupEffect.d.ts.map +0 -1
- package/src/hooks/push/useIosCallKeepEventsSetupEffect.ts +0 -132
|
@@ -5,13 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.initIosNonVoipToken = initIosNonVoipToken;
|
|
7
7
|
exports.onPushNotificationiOSStreamVideoEvent = onPushNotificationiOSStreamVideoEvent;
|
|
8
|
-
exports.oniOSNotifeeEvent = exports.oniOSExpoNotificationEvent = void 0;
|
|
8
|
+
exports.oniOSNotifeeEvent = exports.oniOSExpoNotificationEvent = exports.onVoipNotificationReceived = void 0;
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
10
|
var _rxSubjects = require("./internal/rxSubjects");
|
|
11
11
|
var _libs = require("./libs");
|
|
12
12
|
var _videoClient = require("@stream-io/video-client");
|
|
13
13
|
var _pushLogoutCallback = require("../internal/pushLogoutCallback");
|
|
14
14
|
var _StreamVideoRN = require("../StreamVideoRN");
|
|
15
|
+
var _utils = require("./internal/utils");
|
|
15
16
|
let lastApnToken = {
|
|
16
17
|
token: '',
|
|
17
18
|
userId: ''
|
|
@@ -153,4 +154,97 @@ async function initIosNonVoipToken(client, pushConfig, setUnsubscribeListener) {
|
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
}
|
|
157
|
+
const onVoipNotificationReceived = async notification => {
|
|
158
|
+
/* --- Example payload ---
|
|
159
|
+
{
|
|
160
|
+
"aps": {
|
|
161
|
+
"alert": {
|
|
162
|
+
"body": "",
|
|
163
|
+
"title": "Vishal Narkhede is calling you"
|
|
164
|
+
},
|
|
165
|
+
"badge": 0,
|
|
166
|
+
"category": "stream.video",
|
|
167
|
+
"mutable-content": 1
|
|
168
|
+
},
|
|
169
|
+
"stream": {
|
|
170
|
+
"call_cid": "default:ixbm7y0k74pbjnq",
|
|
171
|
+
"call_display_name": "",
|
|
172
|
+
"created_by_display_name": "Vishal Narkhede",
|
|
173
|
+
"created_by_id": "vishalexpo",
|
|
174
|
+
"receiver_id": "santhoshexpo",
|
|
175
|
+
"sender": "stream.video",
|
|
176
|
+
"type": "call.ring",
|
|
177
|
+
"version": "v2"
|
|
178
|
+
}
|
|
179
|
+
} */
|
|
180
|
+
const sender = notification?.stream?.sender;
|
|
181
|
+
const type = notification?.stream?.type;
|
|
182
|
+
// do not process any other notifications other than stream.video or ringing
|
|
183
|
+
if (sender !== 'stream.video' && type !== 'call.ring') {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const call_cid = notification?.stream?.call_cid;
|
|
187
|
+
const pushConfig = _StreamVideoRN.StreamVideoRN.getConfig().push;
|
|
188
|
+
if (!call_cid || _reactNative.Platform.OS !== 'ios' || !pushConfig) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const logger = (0, _videoClient.getLogger)(['setupIosVoipPushEvents']);
|
|
192
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
193
|
+
if (!client) {
|
|
194
|
+
logger('debug', 'client not found, not processing call.ring voip push notification');
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const callFromPush = await client.onRingingCall(call_cid);
|
|
198
|
+
let uuid = '';
|
|
199
|
+
try {
|
|
200
|
+
uuid = await _reactNative.NativeModules?.StreamVideoReactNative?.getIncomingCallUUid(call_cid);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
logger('error', 'Error in getting call uuid from native module', error);
|
|
203
|
+
}
|
|
204
|
+
if (!uuid) {
|
|
205
|
+
logger('error', `Not processing call.ring push notification, as no uuid found for call_cid: ${call_cid}`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const created_by_id = notification?.stream?.created_by_id;
|
|
209
|
+
const receiver_id = notification?.stream?.receiver_id;
|
|
210
|
+
function closeCallIfNecessary() {
|
|
211
|
+
const {
|
|
212
|
+
mustEndCall,
|
|
213
|
+
callkeepReason
|
|
214
|
+
} = (0, _utils.shouldCallBeEnded)(callFromPush, created_by_id, receiver_id);
|
|
215
|
+
if (mustEndCall) {
|
|
216
|
+
const callkeep = (0, _libs.getCallKeepLib)();
|
|
217
|
+
logger('debug', `callkeep.reportEndCallWithUUID for uuid: ${uuid}, call_cid: ${call_cid}, reason: ${callkeepReason}`);
|
|
218
|
+
callkeep.reportEndCallWithUUID(uuid, callkeepReason);
|
|
219
|
+
const voipPushNotification = (0, _libs.getVoipPushNotificationLib)();
|
|
220
|
+
voipPushNotification.onVoipNotificationCompleted(uuid);
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
const closed = closeCallIfNecessary();
|
|
226
|
+
const canListenToWS = () => _utils.canAddPushWSSubscriptionsRef.current && _reactNative.AppState.currentState !== 'active';
|
|
227
|
+
if (!closed && canListenToWS()) {
|
|
228
|
+
const unsubscribe = callFromPush.on('all', event => {
|
|
229
|
+
const _canListenToWS = canListenToWS();
|
|
230
|
+
if (!_canListenToWS) {
|
|
231
|
+
logger('debug', `unsubscribe due to event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, event);
|
|
232
|
+
unsubscribe();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const _closed = closeCallIfNecessary();
|
|
236
|
+
if (_closed) {
|
|
237
|
+
logger('debug', `unsubscribe due to event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed: ${_closed}`, event);
|
|
238
|
+
unsubscribe();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
const unsubscriptionCallbacks = _videoClient.RxUtils.getCurrentValue(_rxSubjects.pushUnsubscriptionCallbacks$) ?? [];
|
|
242
|
+
_rxSubjects.pushUnsubscriptionCallbacks$.next([...unsubscriptionCallbacks, unsubscribe]);
|
|
243
|
+
}
|
|
244
|
+
// send the info to this subject, it is listened by callkeep events
|
|
245
|
+
// callkeep events will then accept/reject the call
|
|
246
|
+
logger('debug', `call_cid:${call_cid} uuid:${uuid} received and processed from call.ring push notification`);
|
|
247
|
+
_rxSubjects.voipPushNotificationCallCId$.next(call_cid);
|
|
248
|
+
};
|
|
249
|
+
exports.onVoipNotificationReceived = onVoipNotificationReceived;
|
|
156
250
|
//# sourceMappingURL=ios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_rxSubjects","_libs","_videoClient","_pushLogoutCallback","_StreamVideoRN","lastApnToken","token","userId","processNonRingingNotificationStreamPayload","streamPayload","sender","type","cid","call_cid","logger","getLogger","pushNonRingingCallData$","next","undefined","oniOSExpoNotificationEvent","event","pushConfig","StreamVideoRN","getConfig","push","trigger","request","payload","stream","JSON","stringify","exports","oniOSNotifeeEvent","Platform","OS","detail","notifeeLib","getNotifeeLibThrowIfNotInstalledForPush","EventType","PRESS","notification","data","result","onTapNonRingingCallNotification","onPushNotificationiOSStreamVideoEvent","pushNotificationIosLib","getPushNotificationIosLib","getData","isClicked","userInteraction","finish","FetchResult","NoData","initIosNonVoipToken","client","setUnsubscribeListener","ios","pushProviderName","setDeviceToken","streamClient","_user","id","setPushLogoutCallback","removeDevice","err","push_provider_name","addDevice","then","catch","isExpo","expoNotificationsLib","getExpoNotificationsLib","getDevicePushTokenAsync","devicePushToken","subscription","addPushTokenListener","remove","addEventListener","removeEventListener"],"sourceRoot":"../../../../src","sources":["utils/push/ios.ts"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_rxSubjects","_libs","_videoClient","_pushLogoutCallback","_StreamVideoRN","_utils","lastApnToken","token","userId","processNonRingingNotificationStreamPayload","streamPayload","sender","type","cid","call_cid","logger","getLogger","pushNonRingingCallData$","next","undefined","oniOSExpoNotificationEvent","event","pushConfig","StreamVideoRN","getConfig","push","trigger","request","payload","stream","JSON","stringify","exports","oniOSNotifeeEvent","Platform","OS","detail","notifeeLib","getNotifeeLibThrowIfNotInstalledForPush","EventType","PRESS","notification","data","result","onTapNonRingingCallNotification","onPushNotificationiOSStreamVideoEvent","pushNotificationIosLib","getPushNotificationIosLib","getData","isClicked","userInteraction","finish","FetchResult","NoData","initIosNonVoipToken","client","setUnsubscribeListener","ios","pushProviderName","setDeviceToken","streamClient","_user","id","setPushLogoutCallback","removeDevice","err","push_provider_name","addDevice","then","catch","isExpo","expoNotificationsLib","getExpoNotificationsLib","getDevicePushTokenAsync","devicePushToken","subscription","addPushTokenListener","remove","addEventListener","removeEventListener","onVoipNotificationReceived","createStreamVideoClient","callFromPush","onRingingCall","uuid","NativeModules","StreamVideoReactNative","getIncomingCallUUid","error","created_by_id","receiver_id","closeCallIfNecessary","mustEndCall","callkeepReason","shouldCallBeEnded","callkeep","getCallKeepLib","reportEndCallWithUUID","voipPushNotification","getVoipPushNotificationLib","onVoipNotificationCompleted","closed","canListenToWS","canAddPushWSSubscriptionsRef","current","AppState","currentState","unsubscribe","on","_canListenToWS","_closed","unsubscriptionCallbacks","RxUtils","getCurrentValue","pushUnsubscriptionCallbacks$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C,CAChC,GAAG6F,uBAAuB,EAC1BJ,WAAW,CACZ,CAAC;EACJ;EACA;EACA;EACA5F,MAAM,CACJ,OAAO,EACP,YAAYD,QAAQ,SAASsE,IAAI,0DACnC,CAAC;EACD+B,wCAA4B,CAACjG,IAAI,CAACJ,QAAQ,CAAC;AAC7C,CAAC;AAACkB,OAAA,CAAAgD,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setupIosCallKeepEvents = setupIosCallKeepEvents;
|
|
7
|
+
var _rxSubjects = require("./internal/rxSubjects");
|
|
8
|
+
var _videoClient = require("@stream-io/video-client");
|
|
9
|
+
var _libs = require("./libs");
|
|
10
|
+
var _utils = require("./internal/utils");
|
|
11
|
+
var _reactNative = require("react-native");
|
|
12
|
+
var _pushLogoutCallback = require("../internal/pushLogoutCallback");
|
|
13
|
+
/**
|
|
14
|
+
* This hook is used to listen to callkeep events and do the necessary actions
|
|
15
|
+
*/
|
|
16
|
+
function setupIosCallKeepEvents(pushConfig) {
|
|
17
|
+
if (_reactNative.Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const logger = (0, _videoClient.getLogger)(['setupIosCallKeepEvents']);
|
|
21
|
+
const callkeep = (0, _libs.getCallKeepLib)();
|
|
22
|
+
async function getCallCid(callUUID) {
|
|
23
|
+
let call_cid = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipPushNotificationCallCId$);
|
|
24
|
+
if (!call_cid) {
|
|
25
|
+
// if call_cid is not available, try to get it from native module
|
|
26
|
+
try {
|
|
27
|
+
call_cid = await _reactNative.NativeModules?.StreamVideoReactNative?.getIncomingCallCid(callUUID);
|
|
28
|
+
_rxSubjects.voipPushNotificationCallCId$.next(call_cid);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
logger('debug', 'Error in getting call cid from native module - probably the call was already processed, so ignoring this callkeep event');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return call_cid;
|
|
34
|
+
}
|
|
35
|
+
function answerCall(callUUID) {
|
|
36
|
+
getCallCid(callUUID).then(call_cid => {
|
|
37
|
+
logger('debug', `answerCall event with call_cid: ${call_cid}`);
|
|
38
|
+
iosCallkeepAcceptCall(call_cid, callUUID);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function endCall(callUUID) {
|
|
42
|
+
getCallCid(callUUID).then(call_cid => {
|
|
43
|
+
logger('debug', `endCall event with call_cid: ${call_cid}`);
|
|
44
|
+
iosCallkeepRejectCall(call_cid, callUUID, pushConfig);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function didDisplayIncomingCall(callUUID, payload) {
|
|
48
|
+
const voipPushNotification = (0, _libs.getVoipPushNotificationLib)();
|
|
49
|
+
// @ts-expect-error
|
|
50
|
+
const call_cid = payload?.call_cid;
|
|
51
|
+
logger('debug', `didDisplayIncomingCall event with callUUID: ${callUUID} call_cid: ${call_cid}`);
|
|
52
|
+
if (call_cid) {
|
|
53
|
+
if (_reactNative.AppState.currentState === 'background') {
|
|
54
|
+
(0, _utils.processCallFromPushInBackground)(pushConfig, call_cid, 'backgroundDelivered');
|
|
55
|
+
}
|
|
56
|
+
_rxSubjects.voipCallkeepCallOnForegroundMap$.next({
|
|
57
|
+
uuid: callUUID,
|
|
58
|
+
cid: call_cid
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
voipPushNotification.onVoipNotificationCompleted(callUUID);
|
|
62
|
+
}
|
|
63
|
+
const {
|
|
64
|
+
remove: removeAnswerCall
|
|
65
|
+
} = callkeep.addEventListener('answerCall', ({
|
|
66
|
+
callUUID
|
|
67
|
+
}) => {
|
|
68
|
+
answerCall(callUUID);
|
|
69
|
+
});
|
|
70
|
+
const {
|
|
71
|
+
remove: removeEndCall
|
|
72
|
+
} = callkeep.addEventListener('endCall', ({
|
|
73
|
+
callUUID
|
|
74
|
+
}) => {
|
|
75
|
+
endCall(callUUID);
|
|
76
|
+
});
|
|
77
|
+
const {
|
|
78
|
+
remove: removeDisplayIncomingCall
|
|
79
|
+
} = callkeep.addEventListener('didDisplayIncomingCall', ({
|
|
80
|
+
callUUID,
|
|
81
|
+
payload
|
|
82
|
+
}) => {
|
|
83
|
+
didDisplayIncomingCall(callUUID, payload);
|
|
84
|
+
});
|
|
85
|
+
const {
|
|
86
|
+
remove: removeDidLoadWithEvents
|
|
87
|
+
} = callkeep.addEventListener('didLoadWithEvents', events => {
|
|
88
|
+
if (!events || !Array.isArray(events) || events.length < 1) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
events.forEach(event => {
|
|
92
|
+
const {
|
|
93
|
+
name,
|
|
94
|
+
data
|
|
95
|
+
} = event;
|
|
96
|
+
if (name === 'RNCallKeepDidDisplayIncomingCall') {
|
|
97
|
+
didDisplayIncomingCall(data.callUUID, data.payload);
|
|
98
|
+
} else if (name === 'RNCallKeepPerformAnswerCallAction') {
|
|
99
|
+
answerCall(data.callUUID);
|
|
100
|
+
} else if (name === 'RNCallKeepPerformEndCallAction') {
|
|
101
|
+
endCall(data.callUUID);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
(0, _pushLogoutCallback.setPushLogoutCallback)(async () => {
|
|
106
|
+
removeAnswerCall();
|
|
107
|
+
removeEndCall();
|
|
108
|
+
removeDisplayIncomingCall();
|
|
109
|
+
removeDidLoadWithEvents();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const iosCallkeepAcceptCall = (call_cid, callUUIDFromCallkeep) => {
|
|
113
|
+
if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
(0, _utils.clearPushWSEventSubscriptions)();
|
|
117
|
+
// to call end callkeep later if ended in app and not through callkeep
|
|
118
|
+
_rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$.next({
|
|
119
|
+
uuid: callUUIDFromCallkeep,
|
|
120
|
+
cid: call_cid
|
|
121
|
+
});
|
|
122
|
+
// to process the call in the app
|
|
123
|
+
_rxSubjects.pushAcceptedIncomingCallCId$.next(call_cid);
|
|
124
|
+
// no need to keep these references anymore
|
|
125
|
+
_rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
126
|
+
};
|
|
127
|
+
const iosCallkeepRejectCall = async (call_cid, callUUIDFromCallkeep, pushConfig) => {
|
|
128
|
+
if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
(0, _utils.clearPushWSEventSubscriptions)();
|
|
132
|
+
// no need to keep these references anymore
|
|
133
|
+
_rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
134
|
+
_rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
135
|
+
_rxSubjects.voipPushNotificationCallCId$.next(undefined);
|
|
136
|
+
await (0, _utils.processCallFromPushInBackground)(pushConfig, call_cid, 'decline');
|
|
137
|
+
await _reactNative.NativeModules.StreamVideoReactNative?.removeIncomingCall(call_cid);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Helper function to determine if the answer/end call event from callkeep must be processed
|
|
142
|
+
* Just checks if we have a valid call_cid and acts as a type guard for call_cid
|
|
143
|
+
*/
|
|
144
|
+
const shouldProcessCallFromCallkeep = (call_cid, callUUIDFromCallkeep) => {
|
|
145
|
+
if (!call_cid || !callUUIDFromCallkeep) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=setupIosCallKeepEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rxSubjects","require","_videoClient","_libs","_utils","_reactNative","_pushLogoutCallback","setupIosCallKeepEvents","pushConfig","Platform","OS","ios","pushProviderName","logger","getLogger","callkeep","getCallKeepLib","getCallCid","callUUID","call_cid","RxUtils","getCurrentValue","voipPushNotificationCallCId$","NativeModules","StreamVideoReactNative","getIncomingCallCid","next","error","answerCall","then","iosCallkeepAcceptCall","endCall","iosCallkeepRejectCall","didDisplayIncomingCall","payload","voipPushNotification","getVoipPushNotificationLib","AppState","currentState","processCallFromPushInBackground","voipCallkeepCallOnForegroundMap$","uuid","cid","onVoipNotificationCompleted","remove","removeAnswerCall","addEventListener","removeEndCall","removeDisplayIncomingCall","removeDidLoadWithEvents","events","Array","isArray","length","forEach","event","name","data","setPushLogoutCallback","callUUIDFromCallkeep","shouldProcessCallFromCallkeep","clearPushWSEventSubscriptions","voipCallkeepAcceptedCallOnNativeDialerMap$","pushAcceptedIncomingCallCId$","undefined","removeIncomingCall"],"sourceRoot":"../../../../src","sources":["utils/push/setupIosCallKeepEvents.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAIA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAQA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAAA;AAIA;AACA;AACA;AACO,SAASM,sBAAsBA,CACpCC,UAAkD,EAClD;EACA,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACF,UAAU,CAACG,GAAG,CAACC,gBAAgB,EAAE;IAC7D;EACF;EACA,MAAMC,MAAM,GAAG,IAAAC,sBAAS,EAAC,CAAC,wBAAwB,CAAC,CAAC;EACpD,MAAMC,QAAQ,GAAG,IAAAC,oBAAc,EAAC,CAAC;EAEjC,eAAeC,UAAUA,CAACC,QAAgB,EAA+B;IACvE,IAAIC,QAAQ,GAAGC,oBAAO,CAACC,eAAe,CAACC,wCAA4B,CAAC;IAC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CAAC;AAC1E,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMyC,6BAA6B,GAAGA,CACpCzC,QAA4B,EAC5BwC,oBAA4B,KACL;EACvB,IAAI,CAACxC,QAAQ,IAAI,CAACwC,oBAAoB,EAAE;IACtC,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setupIosVoipPushEvents = setupIosVoipPushEvents;
|
|
7
|
+
var _libs = require("./libs");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _ = require("..");
|
|
10
|
+
var _pushLogoutCallback = require("../internal/pushLogoutCallback");
|
|
11
|
+
var _videoClient = require("@stream-io/video-client");
|
|
12
|
+
function setupIosVoipPushEvents(pushConfig) {
|
|
13
|
+
if (_reactNative.Platform.OS !== 'ios' || !pushConfig.ios?.pushProviderName) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const logger = (0, _videoClient.getLogger)(['setupIosVoipPushEvents']);
|
|
17
|
+
const voipPushNotification = (0, _libs.getVoipPushNotificationLib)();
|
|
18
|
+
logger('debug', 'notification event listener added');
|
|
19
|
+
voipPushNotification.addEventListener('notification', notification => {
|
|
20
|
+
(0, _.onVoipNotificationReceived)(notification);
|
|
21
|
+
});
|
|
22
|
+
(0, _pushLogoutCallback.setPushLogoutCallback)(async () => {
|
|
23
|
+
(0, _videoClient.getLogger)(['setPushLogoutCallback'])('debug', 'notification event listener removed');
|
|
24
|
+
voipPushNotification.removeEventListener('notification');
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=setupIosVoipPushEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_libs","require","_reactNative","_","_pushLogoutCallback","_videoClient","setupIosVoipPushEvents","pushConfig","Platform","OS","ios","pushProviderName","logger","getLogger","voipPushNotification","getVoipPushNotificationLib","addEventListener","notification","onVoipNotificationReceived","setPushLogoutCallback","removeEventListener"],"sourceRoot":"../../../../src","sources":["utils/push/setupIosVoipPushEvents.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAGO,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,GAAG,IAAAC,sBAAS,EAAC,CAAC,wBAAwB,CAAC,CAAC;EACpD,MAAMC,oBAAoB,GAAG,IAAAC,gCAA0B,EAAC,CAAC;EAEzDH,MAAM,CAAC,OAAO,EAAE,mCAAmC,CAAC;EACpDE,oBAAoB,CAACE,gBAAgB,CAAC,cAAc,EAAGC,YAAY,IAAK;IACtE,IAAAC,4BAA0B,EAACD,YAAY,CAAC;EAC1C,CAAC,CAAC;EACF,IAAAE,yCAAqB,EAAC,YAAY;IAChC,IAAAN,sBAAS,EAAC,CAAC,uBAAuB,CAAC,CAAC,CAClC,OAAO,EACP,qCACF,CAAC;IACDC,oBAAoB,CAACM,mBAAmB,CAAC,cAAc,CAAC;EAC1D,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/dist/commonjs/version.js
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import { CallingState, hasScreenShare, speakerLayoutSortPreset } from '@stream-io/video-client';
|
|
1
|
+
import { CallingState, getLogger, hasScreenShare, speakerLayoutSortPreset } from '@stream-io/video-client';
|
|
2
2
|
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
3
3
|
import React, { useEffect, useMemo } from 'react';
|
|
4
|
-
import { findNodeHandle
|
|
4
|
+
import { findNodeHandle } from 'react-native';
|
|
5
|
+
import { RTCViewPipNative, onNativeCallClosed } from './RTCViewPipNative';
|
|
5
6
|
import { useDebouncedValue } from '../../../utils/hooks/useDebouncedValue';
|
|
6
7
|
import { shouldDisableIOSLocalVideoOnBackgroundRef } from '../../../utils/internal/shouldDisableIOSLocalVideoOnBackground';
|
|
7
|
-
const COMPONENT_NAME = 'RTCViewPip';
|
|
8
|
-
const RTCViewPipNative = requireNativeComponent(COMPONENT_NAME);
|
|
9
|
-
|
|
10
|
-
/** Wrapper for the native view
|
|
11
|
-
* meant to stay private and not exposed */
|
|
12
|
-
const RTCViewPip = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef((props, ref) => {
|
|
13
|
-
if (Platform.OS !== 'ios') return null;
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
return /*#__PURE__*/React.createElement(RTCViewPipNative, {
|
|
16
|
-
streamURL: props.streamURL,
|
|
17
|
-
ref: ref
|
|
18
|
-
});
|
|
19
|
-
}));
|
|
20
8
|
const RTCViewPipIOS = /*#__PURE__*/React.memo(({
|
|
21
9
|
includeLocalParticipantVideo
|
|
22
10
|
}) => {
|
|
@@ -50,17 +38,19 @@ const RTCViewPipIOS = /*#__PURE__*/React.memo(({
|
|
|
50
38
|
callClosedInvokedOnce = true;
|
|
51
39
|
const node = findNodeHandle(nativeRef.current);
|
|
52
40
|
if (node !== null) {
|
|
53
|
-
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
UIManager.getViewManagerConfig(COMPONENT_NAME).Commands.onCallClosed, []);
|
|
41
|
+
onNativeCallClosed(node);
|
|
56
42
|
}
|
|
57
43
|
shouldDisableIOSLocalVideoOnBackgroundRef.current = true;
|
|
58
44
|
};
|
|
59
45
|
const unsubFunc = call?.on('call.ended', () => {
|
|
46
|
+
getLogger(['RTCViewPipIOS'])('debug', `onCallClosed due to call.ended event`);
|
|
47
|
+
unsubFunc?.();
|
|
60
48
|
onCallClosed();
|
|
61
49
|
});
|
|
62
50
|
const subscription = call?.state.callingState$.subscribe(state => {
|
|
63
51
|
if (state === CallingState.LEFT || state === CallingState.IDLE) {
|
|
52
|
+
getLogger(['RTCViewPipIOS'])('debug', `onCallClosed due to callingState: ${state}`);
|
|
53
|
+
subscription?.unsubscribe();
|
|
64
54
|
onCallClosed();
|
|
65
55
|
}
|
|
66
56
|
});
|
|
@@ -82,7 +72,7 @@ const RTCViewPipIOS = /*#__PURE__*/React.memo(({
|
|
|
82
72
|
const videoStreamToRender = isScreenSharing ? screenShareStream : videoStream;
|
|
83
73
|
return videoStreamToRender?.toURL();
|
|
84
74
|
}, [participantInSpotlight]);
|
|
85
|
-
return /*#__PURE__*/React.createElement(
|
|
75
|
+
return /*#__PURE__*/React.createElement(RTCViewPipNative, {
|
|
86
76
|
streamURL: streamURL,
|
|
87
77
|
ref: nativeRef
|
|
88
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CallingState","hasScreenShare","speakerLayoutSortPreset","useCall","useCallStateHooks","React","useEffect","useMemo","findNodeHandle","
|
|
1
|
+
{"version":3,"names":["CallingState","getLogger","hasScreenShare","speakerLayoutSortPreset","useCall","useCallStateHooks","React","useEffect","useMemo","findNodeHandle","RTCViewPipNative","onNativeCallClosed","useDebouncedValue","shouldDisableIOSLocalVideoOnBackgroundRef","RTCViewPipIOS","memo","includeLocalParticipantVideo","call","useParticipants","_allParticipants","sortBy","allParticipants","dominantSpeaker","dominantSpeaker2","filter","participant","isLocalParticipant","participantInSpotlight","current","nativeRef","useRef","callClosedInvokedOnce","onCallClosed","node","unsubFunc","on","subscription","state","callingState$","subscribe","LEFT","IDLE","unsubscribe","streamURL","undefined","videoStream","screenShareStream","isScreenSharing","videoStreamToRender","toURL","createElement","ref"],"sourceRoot":"../../../../../src","sources":["components/Call/CallContent/RTCViewPipIOS.tsx"],"mappings":"AAAA,SACEA,YAAY,EACZC,SAAS,E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sBAAsB,CAAC;IAE9D,MAAMqB,mBAAmB,GAAID,eAAe,GACxCD,iBAAiB,GACjBD,WAAkD;IAEtD,OAAOG,mBAAmB,EAAEC,KAAK,CAAC,CAAC;EACrC,CAAC,EAAE,CAACtB,sBAAsB,CAAC,CAAC;EAE5B,oBAAOrB,KAAA,CAAA4C,aAAA,CAACxC,gBAAgB;IAACiC,SAAS,EAAEA,SAAU;IAACQ,GAAG,EAAEtB;EAAU,CAAE,CAAC;AACnE,CAAC,CAAC;AAEF,eAAef,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getLogger } from '@stream-io/video-client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Platform, requireNativeComponent, UIManager, StyleSheet } from 'react-native';
|
|
4
|
+
const COMPONENT_NAME = 'RTCViewPip';
|
|
5
|
+
const NativeComponent = requireNativeComponent(COMPONENT_NAME);
|
|
6
|
+
export function onNativeCallClosed(reactTag) {
|
|
7
|
+
getLogger(['RTCViewPipNative'])('debug', 'onNativeCallClosed');
|
|
8
|
+
UIManager.dispatchViewManagerCommand(reactTag,
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
UIManager.getViewManagerConfig(COMPONENT_NAME).Commands.onCallClosed, []);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Wrapper for the native view
|
|
14
|
+
* meant to stay private and not exposed */
|
|
15
|
+
export const RTCViewPipNative = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef((props, ref) => {
|
|
16
|
+
if (Platform.OS !== 'ios') return null;
|
|
17
|
+
return /*#__PURE__*/React.createElement(NativeComponent, {
|
|
18
|
+
style: StyleSheet.absoluteFill,
|
|
19
|
+
pointerEvents: 'none',
|
|
20
|
+
streamURL: props.streamURL
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
,
|
|
23
|
+
ref: ref
|
|
24
|
+
});
|
|
25
|
+
}));
|
|
26
|
+
//# sourceMappingURL=RTCViewPipNative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getLogger","React","Platform","requireNativeComponent","UIManager","StyleSheet","COMPONENT_NAME","NativeComponent","onNativeCallClosed","reactTag","dispatchViewManagerCommand","getViewManagerConfig","Commands","onCallClosed","RTCViewPipNative","memo","forwardRef","props","ref","OS","createElement","style","absoluteFill","pointerEvents","streamURL"],"sourceRoot":"../../../../../src","sources":["components/Call/CallContent/RTCViewPipNative.tsx"],"mappings":"AAAA,SAASA,SAAS,QAAQ,yBAAyB;AACnD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAEEC,QAAQ,EACRC,sBAAsB,EACtBC,SAAS,EACTC,UAAU,QACL,cAAc;AAErB,MAAMC,cAAc,GAAG,YAAY;AAMnC,MAAMC,eAAqD,GACzDJ,sBAAsB,CAACG,cAAc,CAAC;AAExC,OAAO,SAASE,kBAAkBA,CAACC,QAAgB,EAAE;EACnDT,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC;EAC9DI,SAAS,CAACM,0BAA0B,CAClCD,QAAQ;EACR;EACAL,SAAS,CAACO,oBAAoB,CAACL,cAAc,CAAC,CAACM,QAAQ,CAACC,YAAY,EACpE,EACF,CAAC;AACH;;AAEA;AACA;AACA,OAAO,MAAMC,gBAAgB,gBAAGb,KAAK,CAACc,IAAI,cACxCd,KAAK,CAACe,UAAU,CAKd,CAACC,KAAK,EAAEC,GAAG,KAAK;EAChB,IAAIhB,QAAQ,CAACiB,EAAE,KAAK,KAAK,EAAE,OAAO,IAAI;EAEtC,oBACElB,KAAA,CAAAmB,aAAA,CAACb,eAAe;IACdc,KAAK,EAAEhB,UAAU,CAACiB,YAAa;IAC/BC,aAAa,EAAE,MAAO;IACtBC,SAAS,EAAEP,KAAK,CAACO;IACjB;IAAA;IACAN,GAAG,EAAEA;EAAI,CACV,CAAC;AAEN,CAAC,CACH,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useIosCallKeepEventsSetupEffect } from './useIosCallKeepEventsSetupEffect';
|
|
2
1
|
import { useIosVoipPushEventsSetupEffect } from './useIosVoipPushEventsSetupEffect';
|
|
3
2
|
import { useProcessPushCallEffect } from './useProcessPushCallEffect';
|
|
4
3
|
import { useInitAndroidTokenAndRest } from './useInitAndroidTokenAndRest';
|
|
@@ -11,7 +10,6 @@ import { useProcessPushNonRingingCallEffect } from './useProcessPushNonRingingCa
|
|
|
11
10
|
*/
|
|
12
11
|
export const usePushRegisterEffect = () => {
|
|
13
12
|
useIosInitRemoteNotifications();
|
|
14
|
-
useIosCallKeepEventsSetupEffect();
|
|
15
13
|
useIosVoipPushEventsSetupEffect();
|
|
16
14
|
useProcessPushNonRingingCallEffect();
|
|
17
15
|
useProcessPushCallEffect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useIosVoipPushEventsSetupEffect","useProcessPushCallEffect","useInitAndroidTokenAndRest","useIosInitRemoteNotifications","useProcessPushNonRingingCallEffect","usePushRegisterEffect"],"sourceRoot":"../../../../src","sources":["hooks/push/index.ts"],"mappings":"AAAA,SAASA,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,6BAA6B,QAAQ,iCAAiC;AAC/E,SAASC,kCAAkC,QAAQ,sCAAsC;;AAEzF;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACzCF,6BAA6B,CAAC,CAAC;EAC/BH,+BAA+B,CAAC,CAAC;EACjCI,kCAAkC,CAAC,CAAC;EACpCH,wBAAwB,CAAC,CAAC;EAC1BC,0BAA0B,CAAC,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CallingState, getLogger, RxUtils } from '@stream-io/video-client';
|
|
2
2
|
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
3
|
+
import { NativeModules, Platform } from 'react-native';
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { StreamVideoRN } from '../../utils';
|
|
6
6
|
import { getCallKeepLib } from '../../utils/push/libs';
|
|
@@ -11,14 +11,18 @@ const isNonActiveCallingState = callingState => {
|
|
|
11
11
|
const isAcceptedCallingState = callingState => {
|
|
12
12
|
return callingState === CallingState.JOINING || callingState === CallingState.JOINED;
|
|
13
13
|
};
|
|
14
|
-
const unsubscribeCallkeepEvents = activeCallCid => {
|
|
14
|
+
const unsubscribeCallkeepEvents = async activeCallCid => {
|
|
15
15
|
const voipPushNotificationCallCId = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
|
|
16
16
|
if (activeCallCid && activeCallCid === voipPushNotificationCallCId) {
|
|
17
17
|
// callkeep events should not be listened anymore so clear the call cid
|
|
18
18
|
voipPushNotificationCallCId$.next(undefined);
|
|
19
19
|
}
|
|
20
|
+
return await NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid);
|
|
20
21
|
};
|
|
21
22
|
const logger = getLogger(['useIosCallkeepWithCallingStateEffect']);
|
|
23
|
+
const log = message => {
|
|
24
|
+
logger('warn', message);
|
|
25
|
+
};
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
28
|
* This hook is used to inform the callkeep library that the call has been joined or ended.
|
|
@@ -39,10 +43,8 @@ export const useIosCallkeepWithCallingStateEffect = () => {
|
|
|
39
43
|
const callkeep = getCallKeepLib();
|
|
40
44
|
// if the component is unmounted and the callID was not reported to callkeep, then report it now
|
|
41
45
|
if (acceptedForegroundCallkeepMap) {
|
|
42
|
-
|
|
43
|
-
unsubscribeCallkeepEvents(acceptedForegroundCallkeepMap.cid);
|
|
44
|
-
// this call should be ended in callkeep
|
|
45
|
-
callkeep.endCall(acceptedForegroundCallkeepMap.uuid);
|
|
46
|
+
log(`Ending call in callkeep: ${acceptedForegroundCallkeepMap.cid}, reason: component unmounted and call was present in acceptedForegroundCallkeepMap`);
|
|
47
|
+
unsubscribeCallkeepEvents(acceptedForegroundCallkeepMap.cid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
}, [acceptedForegroundCallkeepMap]);
|
|
@@ -57,17 +59,13 @@ export const useIosCallkeepWithCallingStateEffect = () => {
|
|
|
57
59
|
const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
|
|
58
60
|
const callkeep = getCallKeepLib();
|
|
59
61
|
if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
|
|
60
|
-
|
|
61
|
-
unsubscribeCallkeepEvents(activeCallCid);
|
|
62
|
-
callkeep.endCall(nativeDialerAcceptedCallMap.uuid);
|
|
62
|
+
log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in nativeDialerAcceptedCallMap`);
|
|
63
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
|
|
63
64
|
// no need to keep this reference anymore
|
|
64
65
|
voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
65
66
|
} else if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
|
|
66
|
-
|
|
67
|
-
unsubscribeCallkeepEvents(activeCallCid);
|
|
68
|
-
callkeep.endCall(foregroundIncomingCallkeepMap.uuid);
|
|
69
|
-
// no need to keep this reference anymore
|
|
70
|
-
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
67
|
+
log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in foregroundIncomingCallkeepMap`);
|
|
68
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
|
|
71
69
|
}
|
|
72
70
|
};
|
|
73
71
|
}, [activeCallCid]);
|
|
@@ -85,13 +83,13 @@ export const useIosCallkeepWithCallingStateEffect = () => {
|
|
|
85
83
|
// but the call has been accepted through the app and not through the native dialer
|
|
86
84
|
const foregroundCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
|
|
87
85
|
if (foregroundCallkeepMap && foregroundCallkeepMap.cid === activeCallCid) {
|
|
88
|
-
|
|
86
|
+
log(
|
|
89
87
|
// @ts-ignore
|
|
90
88
|
`Accepting call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundCallkeepMap`);
|
|
91
|
-
// this call should be accepted in callkeep
|
|
92
|
-
callkeep.answerIncomingCall(foregroundCallkeepMap.uuid);
|
|
93
89
|
// no need to keep this reference anymore
|
|
94
90
|
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
91
|
+
NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid).then(() => callkeep.answerIncomingCall(foregroundCallkeepMap.uuid));
|
|
92
|
+
// this call should be accepted in callkeep
|
|
95
93
|
setAcceptedForegroundCallkeepMap(foregroundCallkeepMap);
|
|
96
94
|
}
|
|
97
95
|
}
|
|
@@ -101,16 +99,15 @@ export const useIosCallkeepWithCallingStateEffect = () => {
|
|
|
101
99
|
*/
|
|
102
100
|
if (isNonActiveCallingState(callingState)) {
|
|
103
101
|
const callkeep = getCallKeepLib();
|
|
104
|
-
unsubscribeCallkeepEvents(activeCallCid);
|
|
105
102
|
|
|
106
103
|
// this was a previously joined call which had push notification displayed
|
|
107
104
|
// the call was accepted through the app and not through native dialer
|
|
108
105
|
// the call was left using the leave button in the app and not through native dialer
|
|
109
106
|
if (activeCallCid === acceptedForegroundCallkeepMap?.cid) {
|
|
110
|
-
|
|
107
|
+
log(
|
|
111
108
|
// @ts-ignore
|
|
112
109
|
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in acceptedForegroundCallkeepMap`);
|
|
113
|
-
callkeep.endCall(acceptedForegroundCallkeepMap.uuid);
|
|
110
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
|
|
114
111
|
setAcceptedForegroundCallkeepMap(undefined);
|
|
115
112
|
return;
|
|
116
113
|
}
|
|
@@ -118,10 +115,10 @@ export const useIosCallkeepWithCallingStateEffect = () => {
|
|
|
118
115
|
// the user rejected in the app and not from native dialer
|
|
119
116
|
const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
|
|
120
117
|
if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
|
|
121
|
-
|
|
118
|
+
log(
|
|
122
119
|
// @ts-ignore
|
|
123
120
|
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundIncomingCallkeepMap`);
|
|
124
|
-
callkeep.endCall(foregroundIncomingCallkeepMap.uuid);
|
|
121
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
|
|
125
122
|
// no need to keep this reference anymore
|
|
126
123
|
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
127
124
|
return;
|
|
@@ -131,10 +128,10 @@ export const useIosCallkeepWithCallingStateEffect = () => {
|
|
|
131
128
|
// the user left using the leave button in the app
|
|
132
129
|
const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(voipCallkeepAcceptedCallOnNativeDialerMap$);
|
|
133
130
|
if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
|
|
134
|
-
|
|
131
|
+
log(
|
|
135
132
|
// @ts-ignore
|
|
136
133
|
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in nativeDialerAcceptedCallMap`);
|
|
137
|
-
callkeep.endCall(nativeDialerAcceptedCallMap.uuid);
|
|
134
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
|
|
138
135
|
// no need to keep this reference anymore
|
|
139
136
|
voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
140
137
|
return;
|