@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.
Files changed (75) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +7 -17
  3. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  4. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +34 -0
  5. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -0
  6. package/dist/commonjs/hooks/push/index.js +0 -2
  7. package/dist/commonjs/hooks/push/index.js.map +1 -1
  8. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +20 -23
  9. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
  10. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +6 -103
  11. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  12. package/dist/commonjs/utils/StreamVideoRN/index.js +4 -0
  13. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  14. package/dist/commonjs/utils/push/ios.js +95 -1
  15. package/dist/commonjs/utils/push/ios.js.map +1 -1
  16. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +150 -0
  17. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
  18. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +27 -0
  19. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -0
  20. package/dist/commonjs/version.js +1 -1
  21. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +9 -19
  22. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  23. package/dist/module/components/Call/CallContent/RTCViewPipNative.js +26 -0
  24. package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -0
  25. package/dist/module/hooks/push/index.js +0 -2
  26. package/dist/module/hooks/push/index.js.map +1 -1
  27. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +21 -24
  28. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
  29. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +10 -108
  30. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  31. package/dist/module/utils/StreamVideoRN/index.js +4 -0
  32. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  33. package/dist/module/utils/push/ios.js +97 -4
  34. package/dist/module/utils/push/ios.js.map +1 -1
  35. package/dist/module/utils/push/setupIosCallKeepEvents.js +145 -0
  36. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
  37. package/dist/module/utils/push/setupIosVoipPushEvents.js +21 -0
  38. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -0
  39. package/dist/module/version.js +1 -1
  40. package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
  41. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +8 -0
  42. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -0
  43. package/dist/typescript/hooks/push/index.d.ts.map +1 -1
  44. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -1
  45. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  46. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  47. package/dist/typescript/utils/push/ios.d.ts +1 -0
  48. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  49. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
  50. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
  51. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts +3 -0
  52. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -0
  53. package/dist/typescript/version.d.ts +1 -1
  54. package/ios/PictureInPicture/StreamPictureInPictureController.swift +7 -0
  55. package/ios/RTCViewPip.swift +52 -25
  56. package/ios/RTCViewPipManager.swift +5 -5
  57. package/ios/StreamVideoReactNative.m +72 -22
  58. package/package.json +3 -3
  59. package/src/components/Call/CallContent/RTCViewPipIOS.tsx +15 -38
  60. package/src/components/Call/CallContent/RTCViewPipNative.tsx +51 -0
  61. package/src/hooks/push/index.ts +0 -2
  62. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +37 -31
  63. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +10 -145
  64. package/src/utils/StreamVideoRN/index.ts +5 -0
  65. package/src/utils/push/ios.ts +135 -3
  66. package/src/utils/push/setupIosCallKeepEvents.ts +187 -0
  67. package/src/utils/push/setupIosVoipPushEvents.ts +29 -0
  68. package/src/version.ts +1 -1
  69. package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js +0 -109
  70. package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js.map +0 -1
  71. package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js +0 -103
  72. package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js.map +0 -1
  73. package/dist/typescript/hooks/push/useIosCallKeepEventsSetupEffect.d.ts +0 -5
  74. package/dist/typescript/hooks/push/useIosCallKeepEventsSetupEffect.d.ts.map +0 -1
  75. package/src/hooks/push/useIosCallKeepEventsSetupEffect.ts +0 -132
@@ -0,0 +1,187 @@
1
+ import {
2
+ voipCallkeepCallOnForegroundMap$,
3
+ voipPushNotificationCallCId$,
4
+ } from './internal/rxSubjects';
5
+ import { getLogger, RxUtils } from '@stream-io/video-client';
6
+ import { getCallKeepLib, getVoipPushNotificationLib } from './libs';
7
+ import type { StreamVideoConfig } from '../StreamVideoRN/types';
8
+ import {
9
+ clearPushWSEventSubscriptions,
10
+ processCallFromPushInBackground,
11
+ } from './internal/utils';
12
+ import {
13
+ pushAcceptedIncomingCallCId$,
14
+ voipCallkeepAcceptedCallOnNativeDialerMap$,
15
+ } from './internal/rxSubjects';
16
+ import { AppState, NativeModules, Platform } from 'react-native';
17
+ import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
18
+
19
+ type PushConfig = NonNullable<StreamVideoConfig['push']>;
20
+
21
+ /**
22
+ * This hook is used to listen to callkeep events and do the necessary actions
23
+ */
24
+ export function setupIosCallKeepEvents(
25
+ pushConfig: NonNullable<StreamVideoConfig['push']>
26
+ ) {
27
+ if (Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName) {
28
+ return;
29
+ }
30
+ const logger = getLogger(['setupIosCallKeepEvents']);
31
+ const callkeep = getCallKeepLib();
32
+
33
+ async function getCallCid(callUUID: string): Promise<string | undefined> {
34
+ let call_cid = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
35
+ if (!call_cid) {
36
+ // if call_cid is not available, try to get it from native module
37
+ try {
38
+ call_cid =
39
+ await NativeModules?.StreamVideoReactNative?.getIncomingCallCid(
40
+ callUUID
41
+ );
42
+ voipPushNotificationCallCId$.next(call_cid);
43
+ } catch (error) {
44
+ logger(
45
+ 'debug',
46
+ 'Error in getting call cid from native module - probably the call was already processed, so ignoring this callkeep event'
47
+ );
48
+ }
49
+ }
50
+ return call_cid;
51
+ }
52
+
53
+ function answerCall(callUUID: string) {
54
+ getCallCid(callUUID).then((call_cid) => {
55
+ logger('debug', `answerCall event with call_cid: ${call_cid}`);
56
+ iosCallkeepAcceptCall(call_cid, callUUID);
57
+ });
58
+ }
59
+
60
+ function endCall(callUUID: string) {
61
+ getCallCid(callUUID).then((call_cid) => {
62
+ logger('debug', `endCall event with call_cid: ${call_cid}`);
63
+ iosCallkeepRejectCall(call_cid, callUUID, pushConfig!);
64
+ });
65
+ }
66
+
67
+ function didDisplayIncomingCall(callUUID: string, payload: object) {
68
+ const voipPushNotification = getVoipPushNotificationLib();
69
+ // @ts-expect-error
70
+ const call_cid = payload?.call_cid as string | undefined;
71
+ logger(
72
+ 'debug',
73
+ `didDisplayIncomingCall event with callUUID: ${callUUID} call_cid: ${call_cid}`
74
+ );
75
+ if (call_cid) {
76
+ if (AppState.currentState === 'background') {
77
+ processCallFromPushInBackground(
78
+ pushConfig!,
79
+ call_cid,
80
+ 'backgroundDelivered'
81
+ );
82
+ }
83
+ voipCallkeepCallOnForegroundMap$.next({
84
+ uuid: callUUID,
85
+ cid: call_cid,
86
+ });
87
+ }
88
+ voipPushNotification.onVoipNotificationCompleted(callUUID);
89
+ }
90
+
91
+ const { remove: removeAnswerCall } = callkeep.addEventListener(
92
+ 'answerCall',
93
+ ({ callUUID }) => {
94
+ answerCall(callUUID);
95
+ }
96
+ );
97
+ const { remove: removeEndCall } = callkeep.addEventListener(
98
+ 'endCall',
99
+ ({ callUUID }) => {
100
+ endCall(callUUID);
101
+ }
102
+ );
103
+
104
+ const { remove: removeDisplayIncomingCall } = callkeep.addEventListener(
105
+ 'didDisplayIncomingCall',
106
+ ({ callUUID, payload }) => {
107
+ didDisplayIncomingCall(callUUID, payload);
108
+ }
109
+ );
110
+
111
+ const { remove: removeDidLoadWithEvents } = callkeep.addEventListener(
112
+ 'didLoadWithEvents',
113
+ (events) => {
114
+ if (!events || !Array.isArray(events) || events.length < 1) {
115
+ return;
116
+ }
117
+
118
+ events.forEach((event) => {
119
+ const { name, data } = event;
120
+ if (name === 'RNCallKeepDidDisplayIncomingCall') {
121
+ didDisplayIncomingCall(data.callUUID, data.payload);
122
+ } else if (name === 'RNCallKeepPerformAnswerCallAction') {
123
+ answerCall(data.callUUID);
124
+ } else if (name === 'RNCallKeepPerformEndCallAction') {
125
+ endCall(data.callUUID);
126
+ }
127
+ });
128
+ }
129
+ );
130
+
131
+ setPushLogoutCallback(async () => {
132
+ removeAnswerCall();
133
+ removeEndCall();
134
+ removeDisplayIncomingCall();
135
+ removeDidLoadWithEvents();
136
+ });
137
+ }
138
+
139
+ const iosCallkeepAcceptCall = (
140
+ call_cid: string | undefined,
141
+ callUUIDFromCallkeep: string
142
+ ) => {
143
+ if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
144
+ return;
145
+ }
146
+ clearPushWSEventSubscriptions();
147
+ // to call end callkeep later if ended in app and not through callkeep
148
+ voipCallkeepAcceptedCallOnNativeDialerMap$.next({
149
+ uuid: callUUIDFromCallkeep,
150
+ cid: call_cid,
151
+ });
152
+ // to process the call in the app
153
+ pushAcceptedIncomingCallCId$.next(call_cid);
154
+ // no need to keep these references anymore
155
+ voipCallkeepCallOnForegroundMap$.next(undefined);
156
+ };
157
+
158
+ const iosCallkeepRejectCall = async (
159
+ call_cid: string | undefined,
160
+ callUUIDFromCallkeep: string,
161
+ pushConfig: PushConfig
162
+ ) => {
163
+ if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
164
+ return;
165
+ }
166
+ clearPushWSEventSubscriptions();
167
+ // no need to keep these references anymore
168
+ voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
169
+ voipCallkeepCallOnForegroundMap$.next(undefined);
170
+ voipPushNotificationCallCId$.next(undefined);
171
+ await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
172
+ await NativeModules.StreamVideoReactNative?.removeIncomingCall(call_cid);
173
+ };
174
+
175
+ /**
176
+ * Helper function to determine if the answer/end call event from callkeep must be processed
177
+ * Just checks if we have a valid call_cid and acts as a type guard for call_cid
178
+ */
179
+ const shouldProcessCallFromCallkeep = (
180
+ call_cid: string | undefined,
181
+ callUUIDFromCallkeep: string
182
+ ): call_cid is string => {
183
+ if (!call_cid || !callUUIDFromCallkeep) {
184
+ return false;
185
+ }
186
+ return true;
187
+ };
@@ -0,0 +1,29 @@
1
+ import { getVoipPushNotificationLib } from './libs';
2
+
3
+ import { Platform } from 'react-native';
4
+ import { onVoipNotificationReceived } from '..';
5
+ import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
6
+ import { getLogger } from '@stream-io/video-client';
7
+ import { StreamVideoConfig } from '../StreamVideoRN/types';
8
+
9
+ export function setupIosVoipPushEvents(
10
+ pushConfig: NonNullable<StreamVideoConfig['push']>
11
+ ) {
12
+ if (Platform.OS !== 'ios' || !pushConfig.ios?.pushProviderName) {
13
+ return;
14
+ }
15
+ const logger = getLogger(['setupIosVoipPushEvents']);
16
+ const voipPushNotification = getVoipPushNotificationLib();
17
+
18
+ logger('debug', 'notification event listener added');
19
+ voipPushNotification.addEventListener('notification', (notification) => {
20
+ onVoipNotificationReceived(notification);
21
+ });
22
+ setPushLogoutCallback(async () => {
23
+ getLogger(['setPushLogoutCallback'])(
24
+ 'debug',
25
+ 'notification event listener removed'
26
+ );
27
+ voipPushNotification.removeEventListener('notification');
28
+ });
29
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.10.12';
1
+ export const version = '1.10.14';
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useIosCallKeepEventsSetupEffect = void 0;
7
- var _react = require("react");
8
- var _rxSubjects = require("../../utils/push/internal/rxSubjects");
9
- var _videoClient = require("@stream-io/video-client");
10
- var _libs = require("../../utils/push/libs");
11
- var _StreamVideoRN = require("../../utils/StreamVideoRN");
12
- var _utils = require("../../utils/push/internal/utils");
13
- var _reactNative = require("react-native");
14
- const logger = (0, _videoClient.getLogger)(['useIosCallKeepEventsSetupEffect']);
15
-
16
- /**
17
- * This hook is used to listen to callkeep events and do the necessary actions
18
- */
19
- const useIosCallKeepEventsSetupEffect = () => {
20
- (0, _react.useEffect)(() => {
21
- const pushConfig = _StreamVideoRN.StreamVideoRN.getConfig().push;
22
- if (_reactNative.Platform.OS !== 'ios' || !pushConfig) {
23
- return;
24
- }
25
- const callkeep = (0, _libs.getCallKeepLib)();
26
- const {
27
- remove: removeAnswerCall
28
- } = callkeep.addEventListener('answerCall', ({
29
- callUUID
30
- }) => {
31
- const call_cid = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipPushNotificationCallCId$);
32
- logger('debug', `answerCall event with call_cid: ${call_cid}`);
33
- iosCallkeepAcceptCall(call_cid, callUUID);
34
- });
35
- const {
36
- remove: removeEndCall
37
- } = callkeep.addEventListener('endCall', ({
38
- callUUID
39
- }) => {
40
- const call_cid = _videoClient.RxUtils.getCurrentValue(_rxSubjects.voipPushNotificationCallCId$);
41
- logger('debug', `endCall event with call_cid: ${call_cid}`);
42
- iosCallkeepRejectCall(call_cid, callUUID, pushConfig);
43
- });
44
- const {
45
- remove: removeDisplayIncomingCall
46
- } = callkeep.addEventListener('didDisplayIncomingCall', ({
47
- callUUID,
48
- payload
49
- }) => {
50
- const voipPushNotification = (0, _libs.getVoipPushNotificationLib)();
51
- // you might want to do following things when receiving this event:
52
- // - Start playing ringback if it is an outgoing call
53
- // @ts-expect-error
54
- const call_cid = payload?.call_cid;
55
- logger('debug', `didDisplayIncomingCall event with callUUID: ${callUUID} call_cid: ${call_cid}`);
56
- if (call_cid) {
57
- _rxSubjects.voipCallkeepCallOnForegroundMap$.next({
58
- uuid: callUUID,
59
- cid: call_cid
60
- });
61
- }
62
- voipPushNotification.onVoipNotificationCompleted(callUUID);
63
- });
64
- return () => {
65
- removeAnswerCall();
66
- removeEndCall();
67
- removeDisplayIncomingCall();
68
- };
69
- }, []);
70
- };
71
- exports.useIosCallKeepEventsSetupEffect = useIosCallKeepEventsSetupEffect;
72
- const iosCallkeepAcceptCall = (call_cid, callUUIDFromCallkeep) => {
73
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
74
- return;
75
- }
76
- (0, _utils.clearPushWSEventSubscriptions)();
77
- // to call end callkeep later if ended in app and not through callkeep
78
- _rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$.next({
79
- uuid: callUUIDFromCallkeep,
80
- cid: call_cid
81
- });
82
- // to process the call in the app
83
- _rxSubjects.pushAcceptedIncomingCallCId$.next(call_cid);
84
- // no need to keep these references anymore
85
- _rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
86
- };
87
- const iosCallkeepRejectCall = async (call_cid, callUUIDFromCallkeep, pushConfig) => {
88
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
89
- return;
90
- }
91
- (0, _utils.clearPushWSEventSubscriptions)();
92
- // no need to keep these references anymore
93
- _rxSubjects.voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
94
- _rxSubjects.voipCallkeepCallOnForegroundMap$.next(undefined);
95
- _rxSubjects.voipPushNotificationCallCId$.next(undefined);
96
- await (0, _utils.processCallFromPushInBackground)(pushConfig, call_cid, 'decline');
97
- };
98
-
99
- /**
100
- * Helper function to determine if the answer/end call event from callkeep must be processed
101
- * Just checks if we have a valid call_cid and acts as a type guard for call_cid
102
- */
103
- const shouldProcessCallFromCallkeep = (call_cid, callUUIDFromCallkeep) => {
104
- if (!call_cid || !callUUIDFromCallkeep) {
105
- return false;
106
- }
107
- return true;
108
- };
109
- //# sourceMappingURL=useIosCallKeepEventsSetupEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_rxSubjects","_videoClient","_libs","_StreamVideoRN","_utils","_reactNative","logger","getLogger","useIosCallKeepEventsSetupEffect","useEffect","pushConfig","StreamVideoRN","getConfig","push","Platform","OS","callkeep","getCallKeepLib","remove","removeAnswerCall","addEventListener","callUUID","call_cid","RxUtils","getCurrentValue","voipPushNotificationCallCId$","iosCallkeepAcceptCall","removeEndCall","iosCallkeepRejectCall","removeDisplayIncomingCall","payload","voipPushNotification","getVoipPushNotificationLib","voipCallkeepCallOnForegroundMap$","next","uuid","cid","onVoipNotificationCompleted","exports","callUUIDFromCallkeep","shouldProcessCallFromCallkeep","clearPushWSEventSubscriptions","voipCallkeepAcceptedCallOnNativeDialerMap$","pushAcceptedIncomingCallCId$","undefined","processCallFromPushInBackground"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosCallKeepEventsSetupEffect.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAAE,YAAA,G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,IAAAE,oCAA6B,EAAC,CAAC;EAC/B;EACAC,sDAA0C,CAACR,IAAI,CAACU,SAAS,CAAC;EAC1DX,4CAAgC,CAACC,IAAI,CAACU,SAAS,CAAC;EAChDnB,wCAA4B,CAACS,IAAI,CAACU,SAAS,CAAC;EAC5C,MAAM,IAAAC,sCAA+B,EAACnC,UAAU,EAAEY,QAAQ,EAAE,SAAS,CAAC;AACxE,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMkB,6BAA6B,GAAGA,CACpClB,QAA4B,EAC5BiB,oBAA4B,KACL;EACvB,IAAI,CAACjB,QAAQ,IAAI,CAACiB,oBAAoB,EAAE;IACtC,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
@@ -1,103 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { voipCallkeepCallOnForegroundMap$, voipPushNotificationCallCId$ } from '../../utils/push/internal/rxSubjects';
3
- import { getLogger, RxUtils } from '@stream-io/video-client';
4
- import { getCallKeepLib, getVoipPushNotificationLib } from '../../utils/push/libs';
5
- import { StreamVideoRN } from '../../utils/StreamVideoRN';
6
- import { clearPushWSEventSubscriptions, processCallFromPushInBackground } from '../../utils/push/internal/utils';
7
- import { pushAcceptedIncomingCallCId$, voipCallkeepAcceptedCallOnNativeDialerMap$ } from '../../utils/push/internal/rxSubjects';
8
- import { Platform } from 'react-native';
9
- const logger = getLogger(['useIosCallKeepEventsSetupEffect']);
10
-
11
- /**
12
- * This hook is used to listen to callkeep events and do the necessary actions
13
- */
14
- export const useIosCallKeepEventsSetupEffect = () => {
15
- useEffect(() => {
16
- const pushConfig = StreamVideoRN.getConfig().push;
17
- if (Platform.OS !== 'ios' || !pushConfig) {
18
- return;
19
- }
20
- const callkeep = getCallKeepLib();
21
- const {
22
- remove: removeAnswerCall
23
- } = callkeep.addEventListener('answerCall', ({
24
- callUUID
25
- }) => {
26
- const call_cid = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
27
- logger('debug', `answerCall event with call_cid: ${call_cid}`);
28
- iosCallkeepAcceptCall(call_cid, callUUID);
29
- });
30
- const {
31
- remove: removeEndCall
32
- } = callkeep.addEventListener('endCall', ({
33
- callUUID
34
- }) => {
35
- const call_cid = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
36
- logger('debug', `endCall event with call_cid: ${call_cid}`);
37
- iosCallkeepRejectCall(call_cid, callUUID, pushConfig);
38
- });
39
- const {
40
- remove: removeDisplayIncomingCall
41
- } = callkeep.addEventListener('didDisplayIncomingCall', ({
42
- callUUID,
43
- payload
44
- }) => {
45
- const voipPushNotification = getVoipPushNotificationLib();
46
- // you might want to do following things when receiving this event:
47
- // - Start playing ringback if it is an outgoing call
48
- // @ts-expect-error
49
- const call_cid = payload?.call_cid;
50
- logger('debug', `didDisplayIncomingCall event with callUUID: ${callUUID} call_cid: ${call_cid}`);
51
- if (call_cid) {
52
- voipCallkeepCallOnForegroundMap$.next({
53
- uuid: callUUID,
54
- cid: call_cid
55
- });
56
- }
57
- voipPushNotification.onVoipNotificationCompleted(callUUID);
58
- });
59
- return () => {
60
- removeAnswerCall();
61
- removeEndCall();
62
- removeDisplayIncomingCall();
63
- };
64
- }, []);
65
- };
66
- const iosCallkeepAcceptCall = (call_cid, callUUIDFromCallkeep) => {
67
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
68
- return;
69
- }
70
- clearPushWSEventSubscriptions();
71
- // to call end callkeep later if ended in app and not through callkeep
72
- voipCallkeepAcceptedCallOnNativeDialerMap$.next({
73
- uuid: callUUIDFromCallkeep,
74
- cid: call_cid
75
- });
76
- // to process the call in the app
77
- pushAcceptedIncomingCallCId$.next(call_cid);
78
- // no need to keep these references anymore
79
- voipCallkeepCallOnForegroundMap$.next(undefined);
80
- };
81
- const iosCallkeepRejectCall = async (call_cid, callUUIDFromCallkeep, pushConfig) => {
82
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
83
- return;
84
- }
85
- clearPushWSEventSubscriptions();
86
- // no need to keep these references anymore
87
- voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
88
- voipCallkeepCallOnForegroundMap$.next(undefined);
89
- voipPushNotificationCallCId$.next(undefined);
90
- await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
91
- };
92
-
93
- /**
94
- * Helper function to determine if the answer/end call event from callkeep must be processed
95
- * Just checks if we have a valid call_cid and acts as a type guard for call_cid
96
- */
97
- const shouldProcessCallFromCallkeep = (call_cid, callUUIDFromCallkeep) => {
98
- if (!call_cid || !callUUIDFromCallkeep) {
99
- return false;
100
- }
101
- return true;
102
- };
103
- //# sourceMappingURL=useIosCallKeepEventsSetupEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","voipCallkeepCallOnForegroundMap$","voipPushNotificationCallCId$","getLogger","RxUtils","getCallKeepLib","getVoipPushNotificationLib","StreamVideoRN","clearPushWSEventSubscriptions","processCallFromPushInBackground","pushAcceptedIncomingCallCId$","voipCallkeepAcceptedCallOnNativeDialerMap$","Platform","logger","useIosCallKeepEventsSetupEffect","pushConfig","getConfig","push","OS","callkeep","remove","removeAnswerCall","addEventListener","callUUID","call_cid","getCurrentValue","iosCallkeepAcceptCall","removeEndCall","iosCallkeepRejectCall","removeDisplayIncomingCall","payload","voipPushNotification","next","uuid","cid","onVoipNotificationCompleted","callUUIDFromCallkeep","shouldProcessCallFromCallkeep","undefined"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosCallKeepEventsSetupEffect.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SACEC,gCAAgC,EAChCC,4BAA4B,QACvB,sCAAsC;AAC7C,SAASC,SAAS,EAAEC,OAAO,QAAQ,yBAAyB;AAC5D,SACEC,cAAc,EACdC,0BAA0B,QACrB,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,2BAA2B;AAEzD,SACEC,6BAA6B,EAC7BC,+BAA+B,QAC1B,iCAAiC;AACxC,SACEC,4BAA4B,EAC5BC,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ACM,SAAS,CAAC;EAC5C,MAAM7B,+BAA+B,CAACM,UAAU,EAAES,QAAQ,EAAE,SAAS,CAAC;AACxE,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMa,6BAA6B,GAAGA,CACpCb,QAA4B,EAC5BY,oBAA4B,KACL;EACvB,IAAI,CAACZ,QAAQ,IAAI,CAACY,oBAAoB,EAAE;IACtC,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- /**
2
- * This hook is used to listen to callkeep events and do the necessary actions
3
- */
4
- export declare const useIosCallKeepEventsSetupEffect: () => void;
5
- //# sourceMappingURL=useIosCallKeepEventsSetupEffect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIosCallKeepEventsSetupEffect.d.ts","sourceRoot":"","sources":["../../../../src/hooks/push/useIosCallKeepEventsSetupEffect.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,eAAO,MAAM,+BAA+B,YAqD3C,CAAC"}
@@ -1,132 +0,0 @@
1
- import { useEffect } from 'react';
2
- import {
3
- voipCallkeepCallOnForegroundMap$,
4
- voipPushNotificationCallCId$,
5
- } from '../../utils/push/internal/rxSubjects';
6
- import { getLogger, RxUtils } from '@stream-io/video-client';
7
- import {
8
- getCallKeepLib,
9
- getVoipPushNotificationLib,
10
- } from '../../utils/push/libs';
11
- import { StreamVideoRN } from '../../utils/StreamVideoRN';
12
- import type { StreamVideoConfig } from '../../utils/StreamVideoRN/types';
13
- import {
14
- clearPushWSEventSubscriptions,
15
- processCallFromPushInBackground,
16
- } from '../../utils/push/internal/utils';
17
- import {
18
- pushAcceptedIncomingCallCId$,
19
- voipCallkeepAcceptedCallOnNativeDialerMap$,
20
- } from '../../utils/push/internal/rxSubjects';
21
- import { Platform } from 'react-native';
22
-
23
- type PushConfig = NonNullable<StreamVideoConfig['push']>;
24
-
25
- const logger = getLogger(['useIosCallKeepEventsSetupEffect']);
26
-
27
- /**
28
- * This hook is used to listen to callkeep events and do the necessary actions
29
- */
30
- export const useIosCallKeepEventsSetupEffect = () => {
31
- useEffect(() => {
32
- const pushConfig = StreamVideoRN.getConfig().push;
33
- if (Platform.OS !== 'ios' || !pushConfig) {
34
- return;
35
- }
36
- const callkeep = getCallKeepLib();
37
-
38
- const { remove: removeAnswerCall } = callkeep.addEventListener(
39
- 'answerCall',
40
- ({ callUUID }) => {
41
- const call_cid = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
42
- logger('debug', `answerCall event with call_cid: ${call_cid}`);
43
- iosCallkeepAcceptCall(call_cid, callUUID);
44
- }
45
- );
46
- const { remove: removeEndCall } = callkeep.addEventListener(
47
- 'endCall',
48
- ({ callUUID }) => {
49
- const call_cid = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
50
- logger('debug', `endCall event with call_cid: ${call_cid}`);
51
- iosCallkeepRejectCall(call_cid, callUUID, pushConfig);
52
- }
53
- );
54
-
55
- const { remove: removeDisplayIncomingCall } = callkeep.addEventListener(
56
- 'didDisplayIncomingCall',
57
- ({ callUUID, payload }) => {
58
- const voipPushNotification = getVoipPushNotificationLib();
59
- // you might want to do following things when receiving this event:
60
- // - Start playing ringback if it is an outgoing call
61
- // @ts-expect-error
62
- const call_cid = payload?.call_cid as string | undefined;
63
- logger(
64
- 'debug',
65
- `didDisplayIncomingCall event with callUUID: ${callUUID} call_cid: ${call_cid}`
66
- );
67
- if (call_cid) {
68
- voipCallkeepCallOnForegroundMap$.next({
69
- uuid: callUUID,
70
- cid: call_cid,
71
- });
72
- }
73
- voipPushNotification.onVoipNotificationCompleted(callUUID);
74
- }
75
- );
76
-
77
- return () => {
78
- removeAnswerCall();
79
- removeEndCall();
80
- removeDisplayIncomingCall();
81
- };
82
- }, []);
83
- };
84
-
85
- const iosCallkeepAcceptCall = (
86
- call_cid: string | undefined,
87
- callUUIDFromCallkeep: string
88
- ) => {
89
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
90
- return;
91
- }
92
- clearPushWSEventSubscriptions();
93
- // to call end callkeep later if ended in app and not through callkeep
94
- voipCallkeepAcceptedCallOnNativeDialerMap$.next({
95
- uuid: callUUIDFromCallkeep,
96
- cid: call_cid,
97
- });
98
- // to process the call in the app
99
- pushAcceptedIncomingCallCId$.next(call_cid);
100
- // no need to keep these references anymore
101
- voipCallkeepCallOnForegroundMap$.next(undefined);
102
- };
103
-
104
- const iosCallkeepRejectCall = async (
105
- call_cid: string | undefined,
106
- callUUIDFromCallkeep: string,
107
- pushConfig: PushConfig
108
- ) => {
109
- if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
110
- return;
111
- }
112
- clearPushWSEventSubscriptions();
113
- // no need to keep these references anymore
114
- voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
115
- voipCallkeepCallOnForegroundMap$.next(undefined);
116
- voipPushNotificationCallCId$.next(undefined);
117
- await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
118
- };
119
-
120
- /**
121
- * Helper function to determine if the answer/end call event from callkeep must be processed
122
- * Just checks if we have a valid call_cid and acts as a type guard for call_cid
123
- */
124
- const shouldProcessCallFromCallkeep = (
125
- call_cid: string | undefined,
126
- callUUIDFromCallkeep: string
127
- ): call_cid is string => {
128
- if (!call_cid || !callUUIDFromCallkeep) {
129
- return false;
130
- }
131
- return true;
132
- };