@stream-io/video-react-native-sdk 0.0.1-alpha.201 → 0.0.1-alpha.202

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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.1-alpha.202](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-0.0.1-alpha.201...@stream-io/video-react-native-sdk-0.0.1-alpha.202) (2023-06-22)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * navigate to incoming call screen when push notification is tapped ([#697](https://github.com/GetStream/stream-video-js/issues/697)) ([85488a2](https://github.com/GetStream/stream-video-js/commit/85488a213abb0482c7aedefb5c3aa999131c746a))
11
+
12
+
13
+
5
14
  ## [0.0.1-alpha.201](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-0.0.1-alpha.200...@stream-io/video-react-native-sdk-0.0.1-alpha.201) (2023-06-22)
6
15
 
7
16
 
@@ -23,22 +23,15 @@ const useProcessPushCallEffect = () => {
23
23
  return;
24
24
  }
25
25
  // if the user accepts the call from push notification we join the call
26
- const acceptedCallSubscription = rxSubjects_1.pushAcceptedIncomingCallCId$
27
- .pipe((0, operators_1.filter)(cidIsNotUndefined))
28
- .subscribe(async (callCId) => {
29
- await (0, utils_2.processCallFromPush)(client, callCId, 'accept');
30
- rxSubjects_1.pushAcceptedIncomingCallCId$.next(undefined); // remove the current call id to avoid processing again
31
- });
26
+ const acceptedCallSubscription = createCallSubscription(rxSubjects_1.pushAcceptedIncomingCallCId$, client, pushConfig, 'accept');
32
27
  // if the user rejects the call from push notification we leave the call
33
- const declinedCallSubscription = rxSubjects_1.pushRejectedIncomingCallCId$
34
- .pipe((0, operators_1.filter)(cidIsNotUndefined))
35
- .subscribe(async (callCId) => {
36
- await (0, utils_2.processCallFromPush)(client, callCId, 'decline');
37
- rxSubjects_1.pushRejectedIncomingCallCId$.next(undefined); // remove the current call id to avoid processing again
38
- });
28
+ const declinedCallSubscription = createCallSubscription(rxSubjects_1.pushRejectedIncomingCallCId$, client, pushConfig, 'decline');
29
+ // if the user taps the call from push notification we do nothing as the only thing is to get the call which adds it to the client
30
+ const pressedCallSubscription = createCallSubscription(rxSubjects_1.pushTappedIncomingCallCId$, client, pushConfig, 'pressed');
39
31
  return () => {
40
32
  acceptedCallSubscription.unsubscribe();
41
33
  declinedCallSubscription.unsubscribe();
34
+ pressedCallSubscription.unsubscribe();
42
35
  };
43
36
  }, [client, connectedUserId]);
44
37
  };
@@ -49,4 +42,21 @@ exports.useProcessPushCallEffect = useProcessPushCallEffect;
49
42
  function cidIsNotUndefined(cid) {
50
43
  return cid !== undefined;
51
44
  }
45
+ /**
46
+ * The common logic to create a subscription for the given call cid and action
47
+ */
48
+ const createCallSubscription = (behaviourSubjectWithCallCid, client, pushConfig, action) => {
49
+ return behaviourSubjectWithCallCid
50
+ .pipe((0, operators_1.filter)(cidIsNotUndefined))
51
+ .subscribe(async (callCId) => {
52
+ await (0, utils_2.processCallFromPush)(client, callCId, action);
53
+ if (action === 'accept') {
54
+ pushConfig.navigateAcceptCall();
55
+ }
56
+ else if (action === 'pressed') {
57
+ pushConfig.navigateToIncomingCall();
58
+ }
59
+ behaviourSubjectWithCallCid.next(undefined); // remove the current call id to avoid processing again
60
+ });
61
+ };
52
62
  //# sourceMappingURL=useProcessPushCallEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProcessPushCallEffect.js","sourceRoot":"","sources":["../../../../src/hooks/push/useProcessPushCallEffect.ts"],"names":[],"mappings":";;;AAAA,4DAGqC;AACrC,iCAAkC;AAClC,uCAA4C;AAC5C,0EAGyC;AACzC,8CAAwC;AACxC,kDAA6D;AAE7D;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAA,2CAAoB,GAAE,CAAC;IACtC,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{"version":3,"file":"useProcessPushCallEffect.js","sourceRoot":"","sources":["../../../../src/hooks/push/useProcessPushCallEffect.ts"],"names":[],"mappings":";;;AAAA,4DAIqC;AACrC,iCAAkC;AAClC,uCAA4C;AAC5C,0EAGyC;AAEzC,8CAAwC;AACxC,kDAA6D;AAI7D;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAA,2CAAoB,GAAE,CAAC;IACtC,MAAM,eAAe,GAAG,IAAA,uCAAgB,GAAE,EAAE,EAAE,CAAC;IAC/C,oHAAoH;IACpH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,qBAAa,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC;QAClD,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE;YAC9C,OAAO;SACR;QAED,uEAAuE;QACvE,MAAM,wBAAwB,GAAG,sBAAsB,CACrD,yCAA4B,EAC5B,MAAM,EACN,UAAU,EACV,QAAQ,CACT,CAAC;QAEF,wEAAwE;QACxE,MAAM,wBAAwB,GAAG,sBAAsB,CACrD,yCAA4B,EAC5B,MAAM,EACN,UAAU,EACV,SAAS,CACV,CAAC;QAEF,kIAAkI;QAClI,MAAM,uBAAuB,GAAG,sBAAsB,CACpD,uCAA0B,EAC1B,MAAM,EACN,UAAU,EACV,SAAS,CACV,CAAC;QAEF,OAAO,GAAG,EAAE;YACV,wBAAwB,CAAC,WAAW,EAAE,CAAC;YACvC,wBAAwB,CAAC,WAAW,EAAE,CAAC;YACvC,uBAAuB,CAAC,WAAW,EAAE,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;AAChC,CAAC,CAAC;AAxCW,QAAA,wBAAwB,4BAwCnC;AAEF;;GAEG;AACH,SAAS,iBAAiB,CAAC,GAAuB;IAChD,OAAO,GAAG,KAAK,SAAS,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,sBAAsB,GAAG,CAC7B,2BAAgE,EAChE,MAAyB,EACzB,UAAkD,EAClD,MAAwC,EACxC,EAAE;IACF,OAAO,2BAA2B;SAC/B,IAAI,CAAC,IAAA,kBAAM,EAAC,iBAAiB,CAAC,CAAC;SAC/B,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC3B,MAAM,IAAA,2BAAmB,EAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACnD,IAAI,MAAM,KAAK,QAAQ,EAAE;YACvB,UAAU,CAAC,kBAAkB,EAAE,CAAC;SACjC;aAAM,IAAI,MAAM,KAAK,SAAS,EAAE;YAC/B,UAAU,CAAC,sBAAsB,EAAE,CAAC;SACrC;QACD,2BAA2B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,uDAAuD;IACtG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -72,6 +72,8 @@ export type StreamVideoConfig = {
72
72
  createStreamVideoClient: () => Promise<StreamVideoClient | undefined>;
73
73
  /** The callback that is called when a call is accepted, used for navigation */
74
74
  navigateAcceptCall: () => void;
75
+ /** The callback that is called when a push notification is tapped but user did not press accept or decline, used for navigation */
76
+ navigateToIncomingCall: () => void;
75
77
  };
76
78
  foregroundService: {
77
79
  android: {
@@ -129,6 +129,9 @@ const onNotifeeEvent = async (event, pushConfig) => {
129
129
  }
130
130
  // we can safely cast to string because the data is from "stream.video"
131
131
  const call_cid = data.call_cid;
132
+ // check if we have observers for the call cid (this means the app is in the foreground state)
133
+ const hasObservers = rxSubjects_1.pushAcceptedIncomingCallCId$.observed &&
134
+ rxSubjects_1.pushRejectedIncomingCallCId$.observed;
132
135
  // Check if we need to decline the call
133
136
  const didPressDecline = type === react_native_1.EventType.ACTION_PRESS &&
134
137
  pressAction.id === DECLINE_CALL_ACTION_ID;
@@ -138,18 +141,19 @@ const onNotifeeEvent = async (event, pushConfig) => {
138
141
  const mustAccept = type === react_native_1.EventType.ACTION_PRESS && pressAction.id === ACCEPT_CALL_ACTION_ID;
139
142
  if (mustAccept) {
140
143
  rxSubjects_1.pushAcceptedIncomingCallCId$.next(call_cid);
141
- pushConfig.navigateAcceptCall();
142
144
  // NOTE: accept will be handled by the app with rxjs observers as the app will go to foreground always
143
145
  }
144
146
  else if (mustDecline) {
145
147
  rxSubjects_1.pushRejectedIncomingCallCId$.next(call_cid);
146
- const hasObservers = rxSubjects_1.pushAcceptedIncomingCallCId$.observed &&
147
- rxSubjects_1.pushRejectedIncomingCallCId$.observed;
148
148
  if (hasObservers) {
149
149
  // if we had observers we can return here as the observers will handle the call as the app is in the foreground state
150
150
  return;
151
151
  }
152
- await (0, utils_1.declineCallFromPushInBackground)(pushConfig, call_cid);
152
+ await (0, utils_1.processCallFromPushInBackground)(pushConfig, call_cid, 'decline');
153
+ }
154
+ else if (type === react_native_1.EventType.PRESS) {
155
+ rxSubjects_1.pushTappedIncomingCallCId$.next(call_cid);
156
+ // pressed state will be handled by the app with rxjs observers as the app will go to foreground always
153
157
  }
154
158
  };
155
159
  //# sourceMappingURL=android.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"android.js","sourceRoot":"","sources":["../../../../src/utils/push/android.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAkE;AAGlE,+CAAwC;AAExC,iCAAiD;AACjD,6CAGsB;AACtB,mCAA0D;AAE1D,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AACvC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAIzC,2CAA2C;AAC3C,SAAgB,2BAA2B,CAAC,UAAsB;IAChE,IAAI,uBAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO;KACR;IACD,MAAM,SAAS,GAAG,IAAA,8BAAuB,GAAE,CAAC;IAC5C,SAAS,EAAE,CAAC,2BAA2B,CACrC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,iCAAiC,CAA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AC,QAAkB,CAAC;IAEzC,8FAA8F;IAC9F,MAAM,YAAY,GAChB,yCAA4B,CAAC,QAAQ;QACrC,yCAA4B,CAAC,QAAQ,CAAC;IAExC,uCAAuC;IACvC,MAAM,eAAe,GACnB,IAAI,KAAK,wBAAS,CAAC,YAAY;QAC/B,WAAW,CAAC,EAAE,KAAK,sBAAsB,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,KAAK,wBAAS,CAAC,SAAS,CAAC;IAChD,MAAM,WAAW,GAAG,eAAe,IAAI,UAAU,CAAC;IAClD,sCAAsC;IACtC,MAAM,UAAU,GACd,IAAI,KAAK,wBAAS,CAAC,YAAY,IAAI,WAAW,CAAC,EAAE,KAAK,qBAAqB,CAAC;IAC9E,IAAI,UAAU,EAAE;QACd,yCAA4B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,sGAAsG;KACvG;SAAM,IAAI,WAAW,EAAE;QACtB,yCAA4B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,YAAY,EAAE;YAChB,qHAAqH;YACrH,OAAO;SACR;QACD,MAAM,IAAA,uCAA+B,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;KACxE;SAAM,IAAI,IAAI,KAAK,wBAAS,CAAC,KAAK,EAAE;QACnC,uCAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,uGAAuG;KACxG;AACH,CAAC,CAAC"}
@@ -23,7 +23,7 @@ const iosCallkeepRejectCall = async (call_cid, callUUIDFromCallkeep, pushConfig)
23
23
  // we have observed the rejected call cid, so nothing to do here
24
24
  return;
25
25
  }
26
- await (0, utils_1.declineCallFromPushInBackground)(pushConfig, call_cid);
26
+ await (0, utils_1.processCallFromPushInBackground)(pushConfig, call_cid, 'decline');
27
27
  };
28
28
  exports.iosCallkeepRejectCall = iosCallkeepRejectCall;
29
29
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["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ehaviorSubject } from 'rxjs';
4
4
  * Note: it is should be subscribed only when a user has connected to the websocket of Stream
5
5
  */
6
6
  export declare const pushAcceptedIncomingCallCId$: BehaviorSubject<string | undefined>;
7
+ /**
8
+ * This rxjs subject is used to store the call cid of the tapped incoming call from push notification it is neither accepted nor rejected yet
9
+ * Note: it should be subscribed only when a user has connected to the websocket of Stream
10
+ */
11
+ export declare const pushTappedIncomingCallCId$: BehaviorSubject<string | undefined>;
7
12
  /**
8
13
  * This rxjs subject is used to store the call cid of the accepted incoming call from push notification
9
14
  * Note: it should be subscribed only when a user has connected to the websocket of Stream
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.voipPushNotificationCallCId$ = exports.pushRejectedIncomingCallCId$ = exports.pushAcceptedIncomingCallCId$ = void 0;
3
+ exports.voipPushNotificationCallCId$ = exports.pushRejectedIncomingCallCId$ = exports.pushTappedIncomingCallCId$ = exports.pushAcceptedIncomingCallCId$ = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  /**
6
6
  * This rxjs subject is used to store the call cid of the accepted incoming call from push notification
7
7
  * Note: it is should be subscribed only when a user has connected to the websocket of Stream
8
8
  */
9
9
  exports.pushAcceptedIncomingCallCId$ = new rxjs_1.BehaviorSubject(undefined);
10
+ /**
11
+ * This rxjs subject is used to store the call cid of the tapped incoming call from push notification it is neither accepted nor rejected yet
12
+ * Note: it should be subscribed only when a user has connected to the websocket of Stream
13
+ */
14
+ exports.pushTappedIncomingCallCId$ = new rxjs_1.BehaviorSubject(undefined);
10
15
  /**
11
16
  * This rxjs subject is used to store the call cid of the accepted incoming call from push notification
12
17
  * Note: it should be subscribed only when a user has connected to the websocket of Stream
@@ -1 +1 @@
1
- {"version":3,"file":"rxSubjects.js","sourceRoot":"","sources":["../../../../src/utils/push/rxSubjects.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AAEvC;;;GAGG;AACU,QAAA,4BAA4B,GAAG,IAAI,sBAAe,CAE7D,SAAS,CAAC,CAAC;AAEb;;;GAGG;AACU,QAAA,4BAA4B,GAAG,IAAI,sBAAe,CAE7D,SAAS,CAAC,CAAC;AAEb;;GAEG;AACU,QAAA,4BAA4B,GAAG,IAAI,sBAAe,CAE7D,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"rxSubjects.js","sourceRoot":"","sources":["../../../../src/utils/push/rxSubjects.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AAEvC;;;GAGG;AACU,QAAA,4BAA4B,GAAG,IAAI,sBAAe,CAE7D,SAAS,CAAC,CAAC;AAEb;;;GAGG;AACU,QAAA,0BAA0B,GAAG,IAAI,sBAAe,CAE3D,SAAS,CAAC,CAAC;AAEb;;;GAGG;AACU,QAAA,4BAA4B,GAAG,IAAI,sBAAe,CAE7D,SAAS,CAAC,CAAC;AAEb;;GAEG;AACU,QAAA,4BAA4B,GAAG,IAAI,sBAAe,CAE7D,SAAS,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { StreamVideoClient } from '@stream-io/video-client';
2
2
  import type { StreamVideoConfig } from '../StreamVideoRN/types';
3
3
  type PushConfig = NonNullable<StreamVideoConfig['push']>;
4
- export declare const declineCallFromPushInBackground: (pushConfig: PushConfig, call_cid: string) => Promise<void>;
4
+ export declare const processCallFromPushInBackground: (pushConfig: PushConfig, call_cid: string, action: Parameters<typeof processCallFromPush>[2]) => Promise<void>;
5
5
  /**
6
6
  * This function is used process the call from push notifications due to incoming call
7
7
  * It does the following steps:
@@ -9,5 +9,5 @@ export declare const declineCallFromPushInBackground: (pushConfig: PushConfig, c
9
9
  * 2. Fetch the latest state of the call from the server if its not already in ringing state
10
10
  * 3. Join or leave the call based on the user's action.
11
11
  */
12
- export declare const processCallFromPush: (client: StreamVideoClient, call_cid: string, action: 'accept' | 'decline') => Promise<void>;
12
+ export declare const processCallFromPush: (client: StreamVideoClient, call_cid: string, action: 'accept' | 'decline' | 'pressed') => Promise<void>;
13
13
  export {};
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processCallFromPush = exports.declineCallFromPushInBackground = void 0;
4
- /* Call has been declined from the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
3
+ exports.processCallFromPush = exports.processCallFromPushInBackground = void 0;
4
+ /* An action for the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
5
5
  1. we need to create a new client and connect the user to decline the call
6
- 2. this is because the app is in background state and we don't have a client to decline the call
6
+ 2. this is because the app is in background state and we don't have a client to get the call and do an action
7
7
  */
8
- const declineCallFromPushInBackground = async (pushConfig, call_cid) => {
8
+ const processCallFromPushInBackground = async (pushConfig, call_cid, action) => {
9
9
  let videoClient;
10
10
  try {
11
11
  videoClient = await pushConfig.createStreamVideoClient();
@@ -18,9 +18,9 @@ const declineCallFromPushInBackground = async (pushConfig, call_cid) => {
18
18
  console.log('failed to create video client and connect user', e);
19
19
  return;
20
20
  }
21
- await (0, exports.processCallFromPush)(videoClient, call_cid, 'decline');
21
+ await (0, exports.processCallFromPush)(videoClient, call_cid, action);
22
22
  };
23
- exports.declineCallFromPushInBackground = declineCallFromPushInBackground;
23
+ exports.processCallFromPushInBackground = processCallFromPushInBackground;
24
24
  /**
25
25
  * This function is used process the call from push notifications due to incoming call
26
26
  * It does the following steps:
@@ -36,13 +36,20 @@ const processCallFromPush = async (client, call_cid, action) => {
36
36
  // if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
37
37
  const [callType, callId] = call_cid.split(':');
38
38
  callFromPush = client.call(callType, callId, true);
39
- await callFromPush.get();
39
+ try {
40
+ await callFromPush.get();
41
+ }
42
+ catch (e) {
43
+ console.log('failed to fetch call from push notification', e);
44
+ return;
45
+ }
40
46
  }
47
+ // note: when action was pressed, we dont need to do anything as the only thing is to do is to get the call which adds it to the client
41
48
  try {
42
49
  if (action === 'accept') {
43
50
  await callFromPush.join();
44
51
  }
45
- else {
52
+ else if (action === 'decline') {
46
53
  await callFromPush.leave({ reject: true });
47
54
  }
48
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/push/utils.ts"],"names":[],"mappings":";;;AAKA;;;EAGE;AACK,MAAM,+BAA+B,GAAG,KAAK,EAClD,UAAsB,EACtB,QAAgB,EAChB,EAAE;IACF,IAAI,WAA0C,CAAC;IAE/C,IAAI;QACF,WAAW,GAAG,MAAM,UAAU,CAAC,uBAAuB,EAAE,CAAC;QACzD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;SACR;QACD,MAAM,WAAW,CAAC,WAAW,EAAE,CAAC;KACjC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,gDAAgD,EAAE,CAAC,CAAC,CAAC;QACjE,OAAO;KACR;IACD,MAAM,IAAA,2BAAmB,EAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC9D,CAAC,CAAC;AAjBW,QAAA,+BAA+B,mCAiB1C;AAEF;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,KAAK,EACtC,MAAyB,EACzB,QAAgB,EAChB,MAA4B,EAC5B,EAAE;IACF,kFAAkF;IAClF,mHAAmH;IACnH,IAAI,YAAY,GAAG,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI,CACrD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,CAChD,CAAC;IACF,IAAI,CAAC,YAAY,EAAE;QACjB,2GAA2G;QAC3G,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACnD,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC;KAC1B;IACD,IAAI;QACF,IAAI,MAAM,KAAK,QAAQ,E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G;QAC3G,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACnD,IAAI;YACF,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC;SAC1B;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAC;YAC9D,OAAO;SACR;KACF;IACD,uIAAuI;IACvI,IAAI;QACF,IAAI,MAAM,KAAK,QAAQ,EAAE;YACvB,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;SAC3B;aAAM,IAAI,MAAM,KAAK,SAAS,EAAE;YAC/B,MAAM,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;SAC5C;KACF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;KACzE;AACH,CAAC,CAAC;AA/BW,QAAA,mBAAmB,uBA+B9B"}
package/package.json CHANGED
@@ -22,8 +22,8 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@stream-io/i18n": "^0.0.6",
25
- "@stream-io/video-client": "^0.0.22",
26
- "@stream-io/video-react-bindings": "^0.0.23"
25
+ "@stream-io/video-client": "^0.0.23",
26
+ "@stream-io/video-react-bindings": "^0.0.24"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@notifee/react-native": ">=7.7.0",
@@ -83,5 +83,5 @@
83
83
  "typedoc-plugin-markdown": "^3.15.3",
84
84
  "typescript": "^4.9.5"
85
85
  },
86
- "version": "0.0.1-alpha.201"
86
+ "version": "0.0.1-alpha.202"
87
87
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  pushAcceptedIncomingCallCId$,
3
3
  pushRejectedIncomingCallCId$,
4
+ pushTappedIncomingCallCId$,
4
5
  } from '../../utils/push/rxSubjects';
5
6
  import { useEffect } from 'react';
6
7
  import { StreamVideoRN } from '../../utils';
@@ -8,8 +9,11 @@ import {
8
9
  useConnectedUser,
9
10
  useStreamVideoClient,
10
11
  } from '@stream-io/video-react-bindings';
12
+ import { BehaviorSubject } from 'rxjs';
11
13
  import { filter } from 'rxjs/operators';
12
14
  import { processCallFromPush } from '../../utils/push/utils';
15
+ import { StreamVideoClient } from '@stream-io/video-client';
16
+ import type { StreamVideoConfig } from '../../utils/StreamVideoRN/types';
13
17
 
14
18
  /**
15
19
  * This hook is used to process the incoming call data via push notifications using the relevant rxjs subjects
@@ -28,22 +32,33 @@ export const useProcessPushCallEffect = () => {
28
32
  }
29
33
 
30
34
  // if the user accepts the call from push notification we join the call
31
- const acceptedCallSubscription = pushAcceptedIncomingCallCId$
32
- .pipe(filter(cidIsNotUndefined))
33
- .subscribe(async (callCId) => {
34
- await processCallFromPush(client, callCId, 'accept');
35
- pushAcceptedIncomingCallCId$.next(undefined); // remove the current call id to avoid processing again
36
- });
35
+ const acceptedCallSubscription = createCallSubscription(
36
+ pushAcceptedIncomingCallCId$,
37
+ client,
38
+ pushConfig,
39
+ 'accept',
40
+ );
41
+
37
42
  // if the user rejects the call from push notification we leave the call
38
- const declinedCallSubscription = pushRejectedIncomingCallCId$
39
- .pipe(filter(cidIsNotUndefined))
40
- .subscribe(async (callCId) => {
41
- await processCallFromPush(client, callCId, 'decline');
42
- pushRejectedIncomingCallCId$.next(undefined); // remove the current call id to avoid processing again
43
- });
43
+ const declinedCallSubscription = createCallSubscription(
44
+ pushRejectedIncomingCallCId$,
45
+ client,
46
+ pushConfig,
47
+ 'decline',
48
+ );
49
+
50
+ // if the user taps the call from push notification we do nothing as the only thing is to get the call which adds it to the client
51
+ const pressedCallSubscription = createCallSubscription(
52
+ pushTappedIncomingCallCId$,
53
+ client,
54
+ pushConfig,
55
+ 'pressed',
56
+ );
57
+
44
58
  return () => {
45
59
  acceptedCallSubscription.unsubscribe();
46
60
  declinedCallSubscription.unsubscribe();
61
+ pressedCallSubscription.unsubscribe();
47
62
  };
48
63
  }, [client, connectedUserId]);
49
64
  };
@@ -54,3 +69,25 @@ export const useProcessPushCallEffect = () => {
54
69
  function cidIsNotUndefined(cid: string | undefined): cid is string {
55
70
  return cid !== undefined;
56
71
  }
72
+
73
+ /**
74
+ * The common logic to create a subscription for the given call cid and action
75
+ */
76
+ const createCallSubscription = (
77
+ behaviourSubjectWithCallCid: BehaviorSubject<string | undefined>,
78
+ client: StreamVideoClient,
79
+ pushConfig: NonNullable<StreamVideoConfig['push']>,
80
+ action: 'accept' | 'decline' | 'pressed',
81
+ ) => {
82
+ return behaviourSubjectWithCallCid
83
+ .pipe(filter(cidIsNotUndefined))
84
+ .subscribe(async (callCId) => {
85
+ await processCallFromPush(client, callCId, action);
86
+ if (action === 'accept') {
87
+ pushConfig.navigateAcceptCall();
88
+ } else if (action === 'pressed') {
89
+ pushConfig.navigateToIncomingCall();
90
+ }
91
+ behaviourSubjectWithCallCid.next(undefined); // remove the current call id to avoid processing again
92
+ });
93
+ };
@@ -74,6 +74,8 @@ export type StreamVideoConfig = {
74
74
  createStreamVideoClient: () => Promise<StreamVideoClient | undefined>;
75
75
  /** The callback that is called when a call is accepted, used for navigation */
76
76
  navigateAcceptCall: () => void;
77
+ /** The callback that is called when a push notification is tapped but user did not press accept or decline, used for navigation */
78
+ navigateToIncomingCall: () => void;
77
79
  };
78
80
  foregroundService: {
79
81
  android: {
@@ -7,8 +7,9 @@ import { getFirebaseMessagingLib } from './libs';
7
7
  import {
8
8
  pushAcceptedIncomingCallCId$,
9
9
  pushRejectedIncomingCallCId$,
10
+ pushTappedIncomingCallCId$,
10
11
  } from './rxSubjects';
11
- import { declineCallFromPushInBackground } from './utils';
12
+ import { processCallFromPushInBackground } from './utils';
12
13
 
13
14
  const ACCEPT_CALL_ACTION_ID = 'accept';
14
15
  const DECLINE_CALL_ACTION_ID = 'decline';
@@ -127,6 +128,11 @@ const onNotifeeEvent = async (event: Event, pushConfig: PushConfig) => {
127
128
  // we can safely cast to string because the data is from "stream.video"
128
129
  const call_cid = data.call_cid as string;
129
130
 
131
+ // check if we have observers for the call cid (this means the app is in the foreground state)
132
+ const hasObservers =
133
+ pushAcceptedIncomingCallCId$.observed &&
134
+ pushRejectedIncomingCallCId$.observed;
135
+
130
136
  // Check if we need to decline the call
131
137
  const didPressDecline =
132
138
  type === EventType.ACTION_PRESS &&
@@ -138,17 +144,16 @@ const onNotifeeEvent = async (event: Event, pushConfig: PushConfig) => {
138
144
  type === EventType.ACTION_PRESS && pressAction.id === ACCEPT_CALL_ACTION_ID;
139
145
  if (mustAccept) {
140
146
  pushAcceptedIncomingCallCId$.next(call_cid);
141
- pushConfig.navigateAcceptCall();
142
147
  // NOTE: accept will be handled by the app with rxjs observers as the app will go to foreground always
143
148
  } else if (mustDecline) {
144
149
  pushRejectedIncomingCallCId$.next(call_cid);
145
- const hasObservers =
146
- pushAcceptedIncomingCallCId$.observed &&
147
- pushRejectedIncomingCallCId$.observed;
148
150
  if (hasObservers) {
149
151
  // if we had observers we can return here as the observers will handle the call as the app is in the foreground state
150
152
  return;
151
153
  }
152
- await declineCallFromPushInBackground(pushConfig, call_cid);
154
+ await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
155
+ } else if (type === EventType.PRESS) {
156
+ pushTappedIncomingCallCId$.next(call_cid);
157
+ // pressed state will be handled by the app with rxjs observers as the app will go to foreground always
153
158
  }
154
159
  };
@@ -4,7 +4,7 @@ import {
4
4
  voipPushNotificationCallCId$,
5
5
  pushRejectedIncomingCallCId$,
6
6
  } from './rxSubjects';
7
- import { declineCallFromPushInBackground } from './utils';
7
+ import { processCallFromPushInBackground } from './utils';
8
8
 
9
9
  type PushConfig = NonNullable<StreamVideoConfig['push']>;
10
10
 
@@ -36,7 +36,7 @@ export const iosCallkeepRejectCall = async (
36
36
  // we have observed the rejected call cid, so nothing to do here
37
37
  return;
38
38
  }
39
- await declineCallFromPushInBackground(pushConfig, call_cid);
39
+ await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
40
40
  };
41
41
 
42
42
  /**
@@ -8,6 +8,14 @@ export const pushAcceptedIncomingCallCId$ = new BehaviorSubject<
8
8
  string | undefined
9
9
  >(undefined);
10
10
 
11
+ /**
12
+ * This rxjs subject is used to store the call cid of the tapped incoming call from push notification it is neither accepted nor rejected yet
13
+ * Note: it should be subscribed only when a user has connected to the websocket of Stream
14
+ */
15
+ export const pushTappedIncomingCallCId$ = new BehaviorSubject<
16
+ string | undefined
17
+ >(undefined);
18
+
11
19
  /**
12
20
  * This rxjs subject is used to store the call cid of the accepted incoming call from push notification
13
21
  * Note: it should be subscribed only when a user has connected to the websocket of Stream
@@ -3,13 +3,14 @@ import type { StreamVideoConfig } from '../StreamVideoRN/types';
3
3
 
4
4
  type PushConfig = NonNullable<StreamVideoConfig['push']>;
5
5
 
6
- /* Call has been declined from the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
6
+ /* An action for the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
7
7
  1. we need to create a new client and connect the user to decline the call
8
- 2. this is because the app is in background state and we don't have a client to decline the call
8
+ 2. this is because the app is in background state and we don't have a client to get the call and do an action
9
9
  */
10
- export const declineCallFromPushInBackground = async (
10
+ export const processCallFromPushInBackground = async (
11
11
  pushConfig: PushConfig,
12
12
  call_cid: string,
13
+ action: Parameters<typeof processCallFromPush>[2],
13
14
  ) => {
14
15
  let videoClient: StreamVideoClient | undefined;
15
16
 
@@ -23,7 +24,7 @@ export const declineCallFromPushInBackground = async (
23
24
  console.log('failed to create video client and connect user', e);
24
25
  return;
25
26
  }
26
- await processCallFromPush(videoClient, call_cid, 'decline');
27
+ await processCallFromPush(videoClient, call_cid, action);
27
28
  };
28
29
 
29
30
  /**
@@ -36,7 +37,7 @@ export const declineCallFromPushInBackground = async (
36
37
  export const processCallFromPush = async (
37
38
  client: StreamVideoClient,
38
39
  call_cid: string,
39
- action: 'accept' | 'decline',
40
+ action: 'accept' | 'decline' | 'pressed',
40
41
  ) => {
41
42
  // if the we find the call and is already ringing, we don't need create a new call
42
43
  // as client would have received the call.ring state because the app had WS alive when receiving push notifications
@@ -47,12 +48,18 @@ export const processCallFromPush = async (
47
48
  // if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
48
49
  const [callType, callId] = call_cid.split(':');
49
50
  callFromPush = client.call(callType, callId, true);
50
- await callFromPush.get();
51
+ try {
52
+ await callFromPush.get();
53
+ } catch (e) {
54
+ console.log('failed to fetch call from push notification', e);
55
+ return;
56
+ }
51
57
  }
58
+ // note: when action was pressed, we dont need to do anything as the only thing is to do is to get the call which adds it to the client
52
59
  try {
53
60
  if (action === 'accept') {
54
61
  await callFromPush.join();
55
- } else {
62
+ } else if (action === 'decline') {
56
63
  await callFromPush.leave({ reject: true });
57
64
  }
58
65
  } catch (e) {