@stream-io/video-react-native-sdk 0.0.1-alpha.176 → 0.0.1-alpha.178
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 +13 -0
- package/README.md +7 -5
- package/dist/jest-setup.js +2 -0
- package/dist/jest-setup.js.map +1 -1
- package/dist/src/components/ParticipantReaction.js +29 -4
- package/dist/src/components/ParticipantReaction.js.map +1 -1
- package/dist/src/components/ReactionsModal.d.ts +1 -1
- package/dist/src/components/ReactionsModal.js +25 -2
- package/dist/src/components/ReactionsModal.js.map +1 -1
- package/dist/src/hooks/index.d.ts +2 -1
- package/dist/src/hooks/index.js +2 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/push/index.d.ts +5 -0
- package/dist/src/hooks/push/index.js +19 -0
- package/dist/src/hooks/push/index.js.map +1 -0
- package/dist/src/hooks/push/useInitAndroidTokenAndRest.d.ts +4 -0
- package/dist/src/hooks/push/useInitAndroidTokenAndRest.js +24 -0
- package/dist/src/hooks/push/useInitAndroidTokenAndRest.js.map +1 -0
- package/dist/src/hooks/push/useIosCallKeepEffect.d.ts +4 -0
- package/dist/src/hooks/push/useIosCallKeepEffect.js +80 -0
- package/dist/src/hooks/push/useIosCallKeepEffect.js.map +1 -0
- package/dist/src/hooks/push/useIosPushEffect.d.ts +5 -0
- package/dist/src/hooks/push/useIosPushEffect.js +66 -0
- package/dist/src/hooks/push/useIosPushEffect.js.map +1 -0
- package/dist/src/hooks/push/useProcessPushCallEffect.d.ts +6 -0
- package/dist/src/hooks/push/useProcessPushCallEffect.js +51 -0
- package/dist/src/hooks/push/useProcessPushCallEffect.js.map +1 -0
- package/dist/src/hooks/useAndroidKeepCallAliveEffect.d.ts +6 -0
- package/dist/src/hooks/useAndroidKeepCallAliveEffect.js +117 -0
- package/dist/src/hooks/useAndroidKeepCallAliveEffect.js.map +1 -0
- package/dist/src/providers/StreamCall.d.ts +1 -1
- package/dist/src/providers/StreamCall.js +17 -4
- package/dist/src/providers/StreamCall.js.map +1 -1
- package/dist/src/providers/StreamVideo.js +10 -0
- package/dist/src/providers/StreamVideo.js.map +1 -1
- package/dist/src/utils/StreamVideoRN/index.d.ts +24 -0
- package/dist/src/utils/StreamVideoRN/index.js +65 -0
- package/dist/src/utils/StreamVideoRN/index.js.map +1 -0
- package/dist/src/utils/StreamVideoRN/types.d.ts +103 -0
- package/dist/src/utils/StreamVideoRN/types.js +3 -0
- package/dist/src/utils/StreamVideoRN/types.js.map +1 -0
- package/dist/src/utils/push/libs.d.ts +9 -0
- package/dist/src/utils/push/libs.js +40 -0
- package/dist/src/utils/push/libs.js.map +1 -0
- package/dist/src/utils/push/rxSubjects.d.ts +3 -0
- package/dist/src/utils/push/rxSubjects.js +7 -0
- package/dist/src/utils/push/rxSubjects.js.map +1 -0
- package/dist/src/utils/push/utils.d.ts +17 -0
- package/dist/src/utils/push/utils.js +247 -0
- package/dist/src/utils/push/utils.js.map +1 -0
- package/dist/src/utils/verifyAndroidBluetoothPermissions.js +2 -1
- package/dist/src/utils/verifyAndroidBluetoothPermissions.js.map +1 -1
- package/package.json +25 -8
- package/src/components/ParticipantReaction.tsx +5 -4
- package/src/components/ReactionsModal.tsx +2 -2
- package/src/hooks/index.ts +2 -1
- package/src/hooks/push/index.ts +15 -0
- package/src/hooks/push/useInitAndroidTokenAndRest.ts +23 -0
- package/src/hooks/push/useIosCallKeepEffect.ts +103 -0
- package/src/hooks/push/useIosPushEffect.ts +66 -0
- package/src/hooks/push/useProcessPushCallEffect.ts +55 -0
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +99 -0
- package/src/providers/StreamCall.tsx +24 -6
- package/src/providers/StreamVideo.tsx +11 -0
- package/src/utils/StreamVideoRN/index.ts +69 -0
- package/src/utils/StreamVideoRN/types.ts +104 -0
- package/src/utils/push/libs.ts +50 -0
- package/src/utils/push/rxSubjects.ts +9 -0
- package/src/utils/push/utils.ts +255 -0
- package/src/utils/verifyAndroidBluetoothPermissions.ts +3 -1
- package/dist/src/hooks/useCallKeep.d.ts +0 -11
- package/dist/src/hooks/useCallKeep.js +0 -41
- package/dist/src/hooks/useCallKeep.js.map +0 -1
- package/dist/src/utils/StreamVideoRN.d.ts +0 -25
- package/dist/src/utils/StreamVideoRN.js +0 -23
- package/dist/src/utils/StreamVideoRN.js.map +0 -1
- package/src/hooks/useCallKeep.tsx +0 -51
- package/src/utils/StreamVideoRN.ts +0 -35
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { StreamVideoClient } from '@stream-io/video-client';
|
|
2
|
+
import notifee, { EventType, Event } from '@notifee/react-native';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import {
|
|
5
|
+
FirebaseMessagingTypes,
|
|
6
|
+
getCallKeepLib,
|
|
7
|
+
getFirebaseMessagingLib,
|
|
8
|
+
RNCallKeepType,
|
|
9
|
+
} from './libs';
|
|
10
|
+
import {
|
|
11
|
+
pushAcceptedIncomingCallCId$,
|
|
12
|
+
pushRejectedIncomingCallCId$,
|
|
13
|
+
} from './rxSubjects';
|
|
14
|
+
import type { StreamVideoConfig } from '../StreamVideoRN/types';
|
|
15
|
+
|
|
16
|
+
// const options: Parameters<RNCallKeepType['setup']>[0] = {
|
|
17
|
+
// ios: {
|
|
18
|
+
// appName: 'ReactNativeStreamDogFood',
|
|
19
|
+
// supportsVideo: true,
|
|
20
|
+
// },
|
|
21
|
+
// android: {
|
|
22
|
+
// alertTitle: 'Permissions Required',
|
|
23
|
+
// alertDescription:
|
|
24
|
+
// 'This application needs to access your phone calling accounts to make calls',
|
|
25
|
+
// cancelButton: 'Cancel',
|
|
26
|
+
// okButton: 'ok',
|
|
27
|
+
// additionalPermissions: [],
|
|
28
|
+
// // Required to get audio in background when using Android 11
|
|
29
|
+
// // foregroundService: {
|
|
30
|
+
// // channelId: 'com.company.my',
|
|
31
|
+
// // channelName: 'Foreground service for my app',
|
|
32
|
+
// // notificationTitle: 'My app is running on background',
|
|
33
|
+
// // notificationIcon: 'Path to the resource icon of the notification',
|
|
34
|
+
// // },
|
|
35
|
+
// },
|
|
36
|
+
// };
|
|
37
|
+
|
|
38
|
+
const ACCEPT_CALL_ACTION_ID = 'accept';
|
|
39
|
+
const DECLINE_CALL_ACTION_ID = 'decline';
|
|
40
|
+
|
|
41
|
+
type PushConfig = NonNullable<StreamVideoConfig['push']>;
|
|
42
|
+
|
|
43
|
+
export async function setupCallkeep(pushConfig: PushConfig) {
|
|
44
|
+
const callkeep = getCallKeepLib();
|
|
45
|
+
const options: Parameters<RNCallKeepType['setup']>[0] = {
|
|
46
|
+
ios: {
|
|
47
|
+
appName: pushConfig.ios.appName,
|
|
48
|
+
supportsVideo: true,
|
|
49
|
+
},
|
|
50
|
+
android: {
|
|
51
|
+
...pushConfig.android.phoneCallingAccountPermissionTexts,
|
|
52
|
+
additionalPermissions: [],
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
if (Platform.OS !== 'ios') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
return callkeep.setup(options).then((accepted) => {
|
|
59
|
+
if (accepted) {
|
|
60
|
+
callkeep.setAvailable(true);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Setup Firebase push message handler **/
|
|
66
|
+
export function setupFirebaseHandlerAndroid(pushConfig: PushConfig) {
|
|
67
|
+
if (Platform.OS !== 'android') {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const messaging = getFirebaseMessagingLib();
|
|
71
|
+
messaging().setBackgroundMessageHandler(
|
|
72
|
+
async (msg) => await firebaseMessagingOnMessageHandler(msg, pushConfig),
|
|
73
|
+
);
|
|
74
|
+
// messaging().onMessage(firebaseMessagingOnMessageHandler); // this is to listen to foreground messages, which we dont need for now
|
|
75
|
+
notifee.onBackgroundEvent(async (event) => {
|
|
76
|
+
// NOTE: When app was opened from a quit state, we will never hit this when on accept event as app will open and the click event will go to foreground
|
|
77
|
+
await onNotifeeEvent(event, pushConfig);
|
|
78
|
+
});
|
|
79
|
+
notifee.onForegroundEvent((event) => {
|
|
80
|
+
// NOTE: When app was opened from a quit state, we will never hit this when on accept event as app will open and go to foreground immediately
|
|
81
|
+
onNotifeeEvent(event, pushConfig);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Send token to stream, create notification channel, */
|
|
86
|
+
export async function initAndroidPushTokenAndAskPermissions(
|
|
87
|
+
client: StreamVideoClient,
|
|
88
|
+
pushConfig: PushConfig,
|
|
89
|
+
) {
|
|
90
|
+
if (Platform.OS !== 'android') {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const messaging = getFirebaseMessagingLib();
|
|
94
|
+
const token = await messaging().getToken();
|
|
95
|
+
const push_provider_name = pushConfig.android.pushProviderName;
|
|
96
|
+
await client.addDevice(token, 'firebase', push_provider_name);
|
|
97
|
+
await notifee.requestPermission();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const firebaseMessagingOnMessageHandler = async (
|
|
101
|
+
message: FirebaseMessagingTypes.RemoteMessage,
|
|
102
|
+
pushConfig: PushConfig,
|
|
103
|
+
) => {
|
|
104
|
+
if (Platform.OS !== 'android') {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
/* Example data from firebase
|
|
108
|
+
"message": {
|
|
109
|
+
"data": {
|
|
110
|
+
call_cid: 'audio_room:dcc1638c-e90d-4dcb-bf3b-8fa7767bfbb0',
|
|
111
|
+
call_display_name: '',
|
|
112
|
+
created_by_display_name: 'tommaso',
|
|
113
|
+
created_by_id: 'tommaso-03dcddb7-e9e2-42ec-b2f3-5043aac666ee',
|
|
114
|
+
receiver_id: 'martin-21824f17-319b-401b-a61b-fcab646f0d3f',
|
|
115
|
+
sender: 'stream.video',
|
|
116
|
+
type: 'call.live_started',
|
|
117
|
+
version: 'v2'
|
|
118
|
+
},
|
|
119
|
+
// other stuff
|
|
120
|
+
}
|
|
121
|
+
*/
|
|
122
|
+
const data = message.data;
|
|
123
|
+
if (!data || data.sender !== 'stream.video') {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
await notifee.createChannel(pushConfig.android.incomingCallChannel);
|
|
127
|
+
const { getTitle, getBody } =
|
|
128
|
+
pushConfig.android.incomingCallNotificationTextGetters;
|
|
129
|
+
const channelId = pushConfig.android.incomingCallChannel.id;
|
|
130
|
+
const createdUserName = data.created_by_display_name;
|
|
131
|
+
await notifee.displayNotification({
|
|
132
|
+
title: getTitle(createdUserName),
|
|
133
|
+
body: getBody(createdUserName),
|
|
134
|
+
data,
|
|
135
|
+
android: {
|
|
136
|
+
channelId,
|
|
137
|
+
pressAction: {
|
|
138
|
+
id: 'default',
|
|
139
|
+
launchActivity: 'default', // open the app when the notification is pressed
|
|
140
|
+
},
|
|
141
|
+
actions: [
|
|
142
|
+
{
|
|
143
|
+
title: 'Decline',
|
|
144
|
+
pressAction: {
|
|
145
|
+
id: DECLINE_CALL_ACTION_ID,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
title: 'Accept',
|
|
150
|
+
pressAction: {
|
|
151
|
+
id: ACCEPT_CALL_ACTION_ID,
|
|
152
|
+
launchActivity: 'default', // open the app when the notification is pressed
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
timeoutAfter: 60000, // 60 seconds, after which the notification will be dismissed automatically
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
// const callkeep = getCallKeepLib();
|
|
160
|
+
// const uuid = message.data.call_cid;
|
|
161
|
+
// const localizedCallerName = message.data.created_by_display_name;
|
|
162
|
+
// const handle = 'handle'; // Phone number of the caller // TODO: unclear what this is used for?!
|
|
163
|
+
// callkeep.displayIncomingCall(uuid, handle, localizedCallerName);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const onNotifeeEvent = async (event: Event, pushConfig: PushConfig) => {
|
|
167
|
+
const { type, detail } = event;
|
|
168
|
+
const { notification, pressAction } = detail;
|
|
169
|
+
const notificationId = notification?.id;
|
|
170
|
+
const data = notification?.data;
|
|
171
|
+
if (
|
|
172
|
+
!data ||
|
|
173
|
+
!pressAction ||
|
|
174
|
+
!notificationId ||
|
|
175
|
+
data.sender !== 'stream.video'
|
|
176
|
+
) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// we can safely cast to string because the data is from "stream.video"
|
|
181
|
+
const call_cid = data.call_cid as string;
|
|
182
|
+
|
|
183
|
+
// Check if we need to decline the call
|
|
184
|
+
const didPressDecline =
|
|
185
|
+
type === EventType.ACTION_PRESS &&
|
|
186
|
+
pressAction.id === DECLINE_CALL_ACTION_ID;
|
|
187
|
+
const didDismiss = type === EventType.DISMISSED;
|
|
188
|
+
const mustDecline = didPressDecline || didDismiss;
|
|
189
|
+
// Check if we need to accept the call
|
|
190
|
+
const mustAccept =
|
|
191
|
+
type === EventType.ACTION_PRESS && pressAction.id === ACCEPT_CALL_ACTION_ID;
|
|
192
|
+
if (mustAccept) {
|
|
193
|
+
pushAcceptedIncomingCallCId$.next(call_cid);
|
|
194
|
+
pushConfig.navigateAcceptCall();
|
|
195
|
+
// NOTE: accept will be handled by the app with rxjs observers as the app will go to foreground always
|
|
196
|
+
} else if (mustDecline) {
|
|
197
|
+
pushRejectedIncomingCallCId$.next(call_cid);
|
|
198
|
+
const hasObservers =
|
|
199
|
+
pushAcceptedIncomingCallCId$.observed &&
|
|
200
|
+
pushRejectedIncomingCallCId$.observed;
|
|
201
|
+
if (hasObservers) {
|
|
202
|
+
// if we had observers we can return here as the observers will handle the call as the app is in the foreground state
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
// call has been declined from the notification
|
|
206
|
+
// we need to create a new client and connect the user to decline the call
|
|
207
|
+
// this is because the app is in background state and we don't have a client to decline the call
|
|
208
|
+
let videoClient: StreamVideoClient | undefined;
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
videoClient = await pushConfig.createStreamVideoClient();
|
|
212
|
+
if (!videoClient) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
await videoClient.connectUser();
|
|
216
|
+
await processCallFromPush(videoClient, call_cid, 'decline');
|
|
217
|
+
} catch (e) {
|
|
218
|
+
console.log('failed to create video client and connect user', e);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* This function is used process the call from push notifications due to incoming call
|
|
225
|
+
* It does the following steps:
|
|
226
|
+
* 1. Get the call from the client if present or create a new call
|
|
227
|
+
* 2. Fetch the latest state of the call from the server if its not already in ringing state
|
|
228
|
+
* 3. Join or leave the call based on the user's action.
|
|
229
|
+
*/
|
|
230
|
+
export const processCallFromPush = async (
|
|
231
|
+
client: StreamVideoClient,
|
|
232
|
+
call_cid: string,
|
|
233
|
+
action: 'accept' | 'decline',
|
|
234
|
+
) => {
|
|
235
|
+
// if the we find the call and is already ringing, we don't need create a new call
|
|
236
|
+
// as client would have received the call.ring state because the app had WS alive when receiving push notifications
|
|
237
|
+
let callFromPush = client.readOnlyStateStore.calls.find(
|
|
238
|
+
(call) => call.cid === call_cid && call.ringing,
|
|
239
|
+
);
|
|
240
|
+
if (!callFromPush) {
|
|
241
|
+
// if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
|
|
242
|
+
const [callType, callId] = call_cid.split(':');
|
|
243
|
+
callFromPush = client.call(callType, callId, true);
|
|
244
|
+
await callFromPush.get();
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
if (action === 'accept') {
|
|
248
|
+
await callFromPush.join();
|
|
249
|
+
} else {
|
|
250
|
+
await callFromPush.leave({ reject: true });
|
|
251
|
+
}
|
|
252
|
+
} catch (e) {
|
|
253
|
+
console.log('failed to process call from push notification', e, action);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
@@ -2,7 +2,9 @@ import { Platform, PermissionsAndroid } from 'react-native';
|
|
|
2
2
|
|
|
3
3
|
export const verifyAndroidBluetoothPermissions = async () => {
|
|
4
4
|
const shouldCheckForPermissions = Number(Platform.Version) >= 31;
|
|
5
|
-
if (!shouldCheckForPermissions)
|
|
5
|
+
if (!shouldCheckForPermissions) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
6
8
|
const getCheckPermissionPromise = () => {
|
|
7
9
|
return PermissionsAndroid.check(
|
|
8
10
|
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useCallKeep = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const react_native_1 = require("react-native");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const video_react_bindings_1 = require("@stream-io/video-react-bindings");
|
|
8
|
-
let RNCallKeep;
|
|
9
|
-
try {
|
|
10
|
-
RNCallKeep = require('react-native-callkeep').default;
|
|
11
|
-
}
|
|
12
|
-
catch (e) { }
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @returns
|
|
16
|
-
*
|
|
17
|
-
* @category Call Operations
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
const useCallKeep = () => {
|
|
21
|
-
const activeCall = (0, video_react_bindings_1.useCall)();
|
|
22
|
-
if (!RNCallKeep) {
|
|
23
|
-
throw Error("react-native-callkeep library is not installed. Please install it using 'yarn add react-native-callkeep' or 'npm install react-native-callkeep'");
|
|
24
|
-
}
|
|
25
|
-
const users = activeCall?.state.getCurrentValue(activeCall.state.members$);
|
|
26
|
-
const userIds = (0, react_1.useMemo)(() => Object.keys(users || {}), [users]);
|
|
27
|
-
const callTitle = (0, utils_1.generateCallTitle)(userIds);
|
|
28
|
-
const startCall = (0, react_1.useCallback)(async () => {
|
|
29
|
-
if (react_native_1.Platform.OS === 'ios' && activeCall) {
|
|
30
|
-
await RNCallKeep?.startCall(activeCall.id, callTitle, userIds.join(','), 'generic');
|
|
31
|
-
}
|
|
32
|
-
}, [activeCall, callTitle, userIds]);
|
|
33
|
-
const endCall = (0, react_1.useCallback)(async () => {
|
|
34
|
-
if (react_native_1.Platform.OS === 'ios' && activeCall) {
|
|
35
|
-
await RNCallKeep?.endCall(activeCall.id);
|
|
36
|
-
}
|
|
37
|
-
}, [activeCall]);
|
|
38
|
-
return { startCall, endCall };
|
|
39
|
-
};
|
|
40
|
-
exports.useCallKeep = useCallKeep;
|
|
41
|
-
//# sourceMappingURL=useCallKeep.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCallKeep.js","sourceRoot":"","sources":["../../../src/hooks/useCallKeep.tsx"],"names":[],"mappings":";;;AAAA,iCAA6C;AAC7C,+CAAwC;AACxC,oCAA6C;AAC7C,0EAA0D;AAI1D,IAAI,UAAsC,CAAC;AAE3C,IAAI;IACF,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC;CACvD;AAAC,OAAO,CAAC,EAAE,GAAE;AAEd;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,UAAU,GAAG,IAAA,8BAAO,GAAE,CAAC;IAC7B,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,KAAK,CACT,iJAAiJ,CAClJ,CAAC;KACH;IAED,MAAM,KAAK,GAAG,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC3E,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,IAAA,yBAAiB,EAAC,OAAO,CAAC,CAAC;IAE7C,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QACvC,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,UAAU,EAAE;YACvC,MAAM,UAAU,EAAE,SAAS,CACzB,UAAU,CAAC,EAAE,EACb,SAAS,EACT,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EACjB,SAAS,CACV,CAAC;SACH;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QACrC,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,UAAU,EAAE;YACvC,MAAM,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;SAC1C;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC,CAAC;AA9BW,QAAA,WAAW,eA8BtB"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { StreamReaction } from '@stream-io/video-client';
|
|
2
|
-
type StreamReactionType = StreamReaction & {
|
|
3
|
-
icon: string | JSX.Element;
|
|
4
|
-
};
|
|
5
|
-
type StreamVideoConfig = {
|
|
6
|
-
/**
|
|
7
|
-
* Reactions that are to be supported in the app.
|
|
8
|
-
*
|
|
9
|
-
* Note: This is an array of reactions that is rendered in the Reaction list.
|
|
10
|
-
*/
|
|
11
|
-
supportedReactions: StreamReactionType[];
|
|
12
|
-
};
|
|
13
|
-
export declare class StreamVideoRN {
|
|
14
|
-
/**
|
|
15
|
-
* Global config for StreamVideoRN.
|
|
16
|
-
*/
|
|
17
|
-
static config: StreamVideoConfig;
|
|
18
|
-
/**
|
|
19
|
-
* Set global config for StreamVideoRN allows you to set wished CDN hosts for resizing images.
|
|
20
|
-
* This function accepts an config object that will be merged with the default config.
|
|
21
|
-
* @example StreamVideoRN.setConfig({ onOpenCallParticipantsInfoView: () => {} });
|
|
22
|
-
*/
|
|
23
|
-
static setConfig(config: Partial<StreamVideoConfig>): void;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StreamVideoRN = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const DEFAULT_STREAM_VIDEO_CONFIG = {
|
|
6
|
-
supportedReactions: constants_1.defaultEmojiReactions,
|
|
7
|
-
};
|
|
8
|
-
class StreamVideoRN {
|
|
9
|
-
/**
|
|
10
|
-
* Global config for StreamVideoRN.
|
|
11
|
-
*/
|
|
12
|
-
static config = DEFAULT_STREAM_VIDEO_CONFIG;
|
|
13
|
-
/**
|
|
14
|
-
* Set global config for StreamVideoRN allows you to set wished CDN hosts for resizing images.
|
|
15
|
-
* This function accepts an config object that will be merged with the default config.
|
|
16
|
-
* @example StreamVideoRN.setConfig({ onOpenCallParticipantsInfoView: () => {} });
|
|
17
|
-
*/
|
|
18
|
-
static setConfig(config) {
|
|
19
|
-
this.config = { ...this.config, ...config };
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.StreamVideoRN = StreamVideoRN;
|
|
23
|
-
//# sourceMappingURL=StreamVideoRN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StreamVideoRN.js","sourceRoot":"","sources":["../../../src/utils/StreamVideoRN.ts"],"names":[],"mappings":";;;AACA,4CAAqD;AAerD,MAAM,2BAA2B,GAAG;IAClC,kBAAkB,EAAE,iCAAqB;CAC1C,CAAC;AAEF,MAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,MAAM,GAAsB,2BAA2B,CAAC;IAE/D;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,MAAkC;QACjD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,CAAC;;AAbH,sCAcC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import { generateCallTitle } from '../utils';
|
|
4
|
-
import { useCall } from '@stream-io/video-react-bindings';
|
|
5
|
-
|
|
6
|
-
type RNCallKeepType = typeof import('react-native-callkeep').default;
|
|
7
|
-
|
|
8
|
-
let RNCallKeep: RNCallKeepType | undefined;
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
RNCallKeep = require('react-native-callkeep').default;
|
|
12
|
-
} catch (e) {}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @returns
|
|
17
|
-
*
|
|
18
|
-
* @category Call Operations
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export const useCallKeep = () => {
|
|
22
|
-
const activeCall = useCall();
|
|
23
|
-
if (!RNCallKeep) {
|
|
24
|
-
throw Error(
|
|
25
|
-
"react-native-callkeep library is not installed. Please install it using 'yarn add react-native-callkeep' or 'npm install react-native-callkeep'",
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const users = activeCall?.state.getCurrentValue(activeCall.state.members$);
|
|
30
|
-
const userIds = useMemo(() => Object.keys(users || {}), [users]);
|
|
31
|
-
const callTitle = generateCallTitle(userIds);
|
|
32
|
-
|
|
33
|
-
const startCall = useCallback(async () => {
|
|
34
|
-
if (Platform.OS === 'ios' && activeCall) {
|
|
35
|
-
await RNCallKeep?.startCall(
|
|
36
|
-
activeCall.id,
|
|
37
|
-
callTitle,
|
|
38
|
-
userIds.join(','),
|
|
39
|
-
'generic',
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}, [activeCall, callTitle, userIds]);
|
|
43
|
-
|
|
44
|
-
const endCall = useCallback(async () => {
|
|
45
|
-
if (Platform.OS === 'ios' && activeCall) {
|
|
46
|
-
await RNCallKeep?.endCall(activeCall.id);
|
|
47
|
-
}
|
|
48
|
-
}, [activeCall]);
|
|
49
|
-
|
|
50
|
-
return { startCall, endCall };
|
|
51
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { StreamReaction } from '@stream-io/video-client';
|
|
2
|
-
import { defaultEmojiReactions } from '../constants';
|
|
3
|
-
|
|
4
|
-
type StreamReactionType = StreamReaction & {
|
|
5
|
-
icon: string | JSX.Element;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type StreamVideoConfig = {
|
|
9
|
-
/**
|
|
10
|
-
* Reactions that are to be supported in the app.
|
|
11
|
-
*
|
|
12
|
-
* Note: This is an array of reactions that is rendered in the Reaction list.
|
|
13
|
-
*/
|
|
14
|
-
supportedReactions: StreamReactionType[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const DEFAULT_STREAM_VIDEO_CONFIG = {
|
|
18
|
-
supportedReactions: defaultEmojiReactions,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export class StreamVideoRN {
|
|
22
|
-
/**
|
|
23
|
-
* Global config for StreamVideoRN.
|
|
24
|
-
*/
|
|
25
|
-
static config: StreamVideoConfig = DEFAULT_STREAM_VIDEO_CONFIG;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Set global config for StreamVideoRN allows you to set wished CDN hosts for resizing images.
|
|
29
|
-
* This function accepts an config object that will be merged with the default config.
|
|
30
|
-
* @example StreamVideoRN.setConfig({ onOpenCallParticipantsInfoView: () => {} });
|
|
31
|
-
*/
|
|
32
|
-
static setConfig(config: Partial<StreamVideoConfig>) {
|
|
33
|
-
this.config = { ...this.config, ...config };
|
|
34
|
-
}
|
|
35
|
-
}
|