@stream-io/video-react-native-sdk 0.3.18 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/commonjs/components/Call/CallControls/AcceptCallButton.js +0 -5
- package/dist/commonjs/components/Call/CallControls/AcceptCallButton.js.map +1 -1
- package/dist/commonjs/components/Call/CallControls/RejectCallButton.js +0 -5
- package/dist/commonjs/components/Call/CallControls/RejectCallButton.js.map +1 -1
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +58 -7
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +15 -6
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/providers/MediaStreamManagement.js +25 -34
- package/dist/commonjs/providers/MediaStreamManagement.js.map +1 -1
- package/dist/commonjs/providers/StreamCall.js +22 -5
- package/dist/commonjs/providers/StreamCall.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +60 -1
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/ios.js +2 -0
- package/dist/commonjs/utils/push/ios.js.map +1 -1
- package/dist/commonjs/utils/push/rxSubjects.js +6 -1
- package/dist/commonjs/utils/push/rxSubjects.js.map +1 -1
- package/dist/commonjs/utils/push/utils.js +68 -1
- package/dist/commonjs/utils/push/utils.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/commonjs/version.js.map +1 -1
- package/dist/module/components/Call/CallControls/AcceptCallButton.js +0 -5
- package/dist/module/components/Call/CallControls/AcceptCallButton.js.map +1 -1
- package/dist/module/components/Call/CallControls/RejectCallButton.js +0 -5
- package/dist/module/components/Call/CallControls/RejectCallButton.js.map +1 -1
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +61 -9
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +16 -7
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/providers/MediaStreamManagement.js +25 -34
- package/dist/module/providers/MediaStreamManagement.js.map +1 -1
- package/dist/module/providers/StreamCall.js +19 -3
- package/dist/module/providers/StreamCall.js.map +1 -1
- package/dist/module/utils/push/android.js +63 -4
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/ios.js +3 -1
- package/dist/module/utils/push/ios.js.map +1 -1
- package/dist/module/utils/push/rxSubjects.js +5 -0
- package/dist/module/utils/push/rxSubjects.js.map +1 -1
- package/dist/module/utils/push/utils.js +65 -0
- package/dist/module/utils/push/utils.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/version.js.map +1 -1
- package/dist/typescript/components/Call/CallControls/AcceptCallButton.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallControls/RejectCallButton.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts +1 -0
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
- package/dist/typescript/providers/MediaStreamManagement.d.ts.map +1 -1
- package/dist/typescript/providers/StreamCall.d.ts +3 -1
- package/dist/typescript/providers/StreamCall.d.ts.map +1 -1
- package/dist/typescript/utils/push/android.d.ts.map +1 -1
- package/dist/typescript/utils/push/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/rxSubjects.d.ts +6 -0
- package/dist/typescript/utils/push/rxSubjects.d.ts.map +1 -1
- package/dist/typescript/utils/push/utils.d.ts +22 -1
- package/dist/typescript/utils/push/utils.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/dist/typescript/version.d.ts.map +1 -1
- package/expo-config-plugin/dist/withAndroidPermissions.js +1 -0
- package/expo-config-plugin/dist/withPushAppDelegate.js +7 -1
- package/ios/StreamVideoReactNative.h +3 -1
- package/ios/StreamVideoReactNative.m +24 -1
- package/package.json +1 -1
- package/src/components/Call/CallControls/AcceptCallButton.tsx +0 -5
- package/src/components/Call/CallControls/RejectCallButton.tsx +0 -5
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +76 -8
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +18 -7
- package/src/providers/MediaStreamManagement.tsx +30 -39
- package/src/providers/StreamCall.tsx +25 -3
- package/src/utils/push/android.ts +82 -4
- package/src/utils/push/ios.ts +6 -1
- package/src/utils/push/rxSubjects.ts +10 -0
- package/src/utils/push/utils.ts +70 -1
- package/src/version.ts +1 -1
|
@@ -61,3 +61,13 @@ export const voipCallkeepCallOnForegroundMap$ = new BehaviorSubject<
|
|
|
61
61
|
export const voipCallkeepAcceptedCallOnNativeDialerMap$ = new BehaviorSubject<
|
|
62
62
|
CallkeepMap | undefined
|
|
63
63
|
>(undefined);
|
|
64
|
+
|
|
65
|
+
type UnsubscribeCallback = () => void;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* This rxjs subject is used to store the unsubscribe callbacks (if any) of the push notification processing
|
|
69
|
+
* Note: it should be used to clear it when app processes push notification from foreground
|
|
70
|
+
*/
|
|
71
|
+
export const pushUnsubscriptionCallbacks$ = new BehaviorSubject<
|
|
72
|
+
UnsubscribeCallback[] | undefined
|
|
73
|
+
>(undefined);
|
package/src/utils/push/utils.ts
CHANGED
|
@@ -1,12 +1,59 @@
|
|
|
1
|
-
import { Call, StreamVideoClient } from '@stream-io/video-client';
|
|
1
|
+
import { Call, RxUtils, StreamVideoClient } from '@stream-io/video-client';
|
|
2
2
|
import type {
|
|
3
3
|
NonRingingPushEvent,
|
|
4
4
|
StreamVideoConfig,
|
|
5
5
|
} from '../StreamVideoRN/types';
|
|
6
6
|
import { onNewCallNotification } from '../internal/newNotificationCallbacks';
|
|
7
|
+
import { pushUnsubscriptionCallbacks$ } from './rxSubjects';
|
|
7
8
|
|
|
8
9
|
type PushConfig = NonNullable<StreamVideoConfig['push']>;
|
|
9
10
|
|
|
11
|
+
type CanAddPushWSSubscriptionsRef = { current: boolean };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This function is used to check if the call should be ended based on the push notification
|
|
15
|
+
* Useful for callkeep management to end the call if necessary (with reportEndCallWithUUID)
|
|
16
|
+
*/
|
|
17
|
+
export const shouldCallBeEnded = (
|
|
18
|
+
callFromPush: Call,
|
|
19
|
+
created_by_id: string | undefined,
|
|
20
|
+
receiver_id: string | undefined,
|
|
21
|
+
) => {
|
|
22
|
+
/* callkeep reasons for ending a call
|
|
23
|
+
FAILED: 1,
|
|
24
|
+
REMOTE_ENDED: 2,
|
|
25
|
+
UNANSWERED: 3,
|
|
26
|
+
ANSWERED_ELSEWHERE: 4,
|
|
27
|
+
DECLINED_ELSEWHERE: 5,
|
|
28
|
+
MISSED: 6
|
|
29
|
+
*/
|
|
30
|
+
const callSession = callFromPush.state.session;
|
|
31
|
+
const rejected_by = callSession?.rejected_by;
|
|
32
|
+
const accepted_by = callSession?.accepted_by;
|
|
33
|
+
let mustEndCall = false;
|
|
34
|
+
let callkeepReason = 0;
|
|
35
|
+
if (created_by_id && rejected_by) {
|
|
36
|
+
if (rejected_by[created_by_id]) {
|
|
37
|
+
// call was cancelled by the caller
|
|
38
|
+
mustEndCall = true;
|
|
39
|
+
callkeepReason = 2;
|
|
40
|
+
}
|
|
41
|
+
} else if (receiver_id && rejected_by) {
|
|
42
|
+
if (rejected_by[receiver_id]) {
|
|
43
|
+
// call was rejected by the receiver in some other device
|
|
44
|
+
mustEndCall = true;
|
|
45
|
+
callkeepReason = 5;
|
|
46
|
+
}
|
|
47
|
+
} else if (receiver_id && accepted_by) {
|
|
48
|
+
if (accepted_by[receiver_id]) {
|
|
49
|
+
// call was accepted by the receiver in some other device
|
|
50
|
+
mustEndCall = true;
|
|
51
|
+
callkeepReason = 4;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { mustEndCall, callkeepReason };
|
|
55
|
+
};
|
|
56
|
+
|
|
10
57
|
/* An action for the notification or callkeep and app does not have JS context setup yet, so we need to do two steps:
|
|
11
58
|
1. we need to create a new client and connect the user to decline the call
|
|
12
59
|
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
|
|
@@ -90,3 +137,25 @@ export const processNonIncomingCallFromPush = async (
|
|
|
90
137
|
}
|
|
91
138
|
onNewCallNotification(callFromPush, nonRingingNotificationType);
|
|
92
139
|
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* This function is used to clear all the push related WS subscriptions
|
|
143
|
+
* note: events are subscribed in push for accept/decline through WS
|
|
144
|
+
*/
|
|
145
|
+
export const clearPushWSEventSubscriptions = () => {
|
|
146
|
+
const unsubscriptionCallbacks = RxUtils.getCurrentValue(
|
|
147
|
+
pushUnsubscriptionCallbacks$,
|
|
148
|
+
);
|
|
149
|
+
if (unsubscriptionCallbacks) {
|
|
150
|
+
unsubscriptionCallbacks.forEach((cb) => cb());
|
|
151
|
+
}
|
|
152
|
+
pushUnsubscriptionCallbacks$.next(undefined);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* This ref is used to check if the push WS subscriptions can be added
|
|
157
|
+
* It is used to avoid adding the push WS subscriptions when the client is connected to WS in the foreground
|
|
158
|
+
*/
|
|
159
|
+
export const canAddPushWSSubscriptionsRef: CanAddPushWSSubscriptionsRef = {
|
|
160
|
+
current: true,
|
|
161
|
+
};
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.4.0';
|