react-native-visit-rn-sdk 2.0.12 → 5.0.1
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/README.md +31 -0
- package/android/build.gradle +1 -0
- package/lib/commonjs/assets/video-call/connecting-lottie.gif +0 -0
- package/lib/commonjs/assets/video-call/end-call.png +0 -0
- package/lib/commonjs/assets/video-call/mic-off.png +0 -0
- package/lib/commonjs/assets/video-call/reconnecting.gif +0 -0
- package/lib/commonjs/assets/video-call/switch-camera.png +0 -0
- package/lib/commonjs/assets/video-call/toggle-down.png +0 -0
- package/lib/commonjs/assets/video-call/toggle-up.png +0 -0
- package/lib/commonjs/assets/video-call/video-off.png +0 -0
- package/lib/commonjs/components/VideoCallComponent.js +1107 -0
- package/lib/commonjs/components/VideoCallComponent.js.map +1 -0
- package/lib/commonjs/index.android.js +49 -1
- package/lib/commonjs/index.android.js.map +1 -1
- package/lib/commonjs/index.ios.js +55 -0
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/module/assets/video-call/connecting-lottie.gif +0 -0
- package/lib/module/assets/video-call/end-call.png +0 -0
- package/lib/module/assets/video-call/mic-off.png +0 -0
- package/lib/module/assets/video-call/reconnecting.gif +0 -0
- package/lib/module/assets/video-call/switch-camera.png +0 -0
- package/lib/module/assets/video-call/toggle-down.png +0 -0
- package/lib/module/assets/video-call/toggle-up.png +0 -0
- package/lib/module/assets/video-call/video-off.png +0 -0
- package/lib/module/components/VideoCallComponent.js +1098 -0
- package/lib/module/components/VideoCallComponent.js.map +1 -0
- package/lib/module/index.android.js +49 -1
- package/lib/module/index.android.js.map +1 -1
- package/lib/module/index.ios.js +55 -0
- package/lib/module/index.ios.js.map +1 -1
- package/package.json +3 -2
- package/react-native-visit-rn-sdk.podspec +0 -1
- package/src/assets/video-call/connecting-lottie.gif +0 -0
- package/src/assets/video-call/end-call.png +0 -0
- package/src/assets/video-call/mic-off.png +0 -0
- package/src/assets/video-call/reconnecting.gif +0 -0
- package/src/assets/video-call/switch-camera.png +0 -0
- package/src/assets/video-call/toggle-down.png +0 -0
- package/src/assets/video-call/toggle-up.png +0 -0
- package/src/assets/video-call/video-off.png +0 -0
- package/src/components/VideoCallComponent.js +1305 -0
- package/src/index.android.js +64 -0
- package/src/index.ios.js +90 -20
package/src/index.android.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
NativeEventEmitter,
|
|
13
13
|
} from 'react-native';
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
import WebView from 'react-native-webview';
|
|
16
17
|
|
|
17
18
|
import LocationEnabler from 'react-native-location-enabler';
|
|
@@ -19,6 +20,7 @@ import LocationEnabler from 'react-native-location-enabler';
|
|
|
19
20
|
import DeviceInfo from 'react-native-device-info';
|
|
20
21
|
|
|
21
22
|
import axios from 'axios';
|
|
23
|
+
import VideoCallComponent from './components/VideoCallComponent';
|
|
22
24
|
|
|
23
25
|
import constants from './constants';
|
|
24
26
|
|
|
@@ -276,6 +278,7 @@ const VisitRnSdkView = ({
|
|
|
276
278
|
);
|
|
277
279
|
|
|
278
280
|
const webviewRef = useRef(null);
|
|
281
|
+
const videoCallRef = useRef(null);
|
|
279
282
|
|
|
280
283
|
const showLocationPermissionAlert = () => {
|
|
281
284
|
Alert.alert(
|
|
@@ -519,6 +522,39 @@ const VisitRnSdkView = ({
|
|
|
519
522
|
true; // note: this is required, or you'll sometimes get silent failures
|
|
520
523
|
`;
|
|
521
524
|
|
|
525
|
+
const startVideoConsultation = useCallback(
|
|
526
|
+
(parsedObject) => {
|
|
527
|
+
const roomName = parsedObject?.roomName;
|
|
528
|
+
const accessToken = parsedObject?.token;
|
|
529
|
+
const rawDoctorName = parsedObject?.doctorName;
|
|
530
|
+
const visibleDoctorName =
|
|
531
|
+
rawDoctorName && rawDoctorName.indexOf('Dr.') > -1
|
|
532
|
+
? rawDoctorName.replace('Dr. ', '')
|
|
533
|
+
: rawDoctorName && rawDoctorName.indexOf('Dr') > -1
|
|
534
|
+
? rawDoctorName.replace('Dr ', '')
|
|
535
|
+
: null;
|
|
536
|
+
const userName = parsedObject?.userName;
|
|
537
|
+
|
|
538
|
+
if (!roomName || !accessToken) {
|
|
539
|
+
if (isLoggingEnabled) {
|
|
540
|
+
console.warn(
|
|
541
|
+
'Video call payload missing roomName/accessToken.'
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
videoCallRef.current?.startVideoCall({
|
|
548
|
+
roomName,
|
|
549
|
+
accessToken,
|
|
550
|
+
doctorName: rawDoctorName ?? '',
|
|
551
|
+
visibleDoctorName: visibleDoctorName ?? '',
|
|
552
|
+
userName,
|
|
553
|
+
});
|
|
554
|
+
},
|
|
555
|
+
[isLoggingEnabled]
|
|
556
|
+
);
|
|
557
|
+
|
|
522
558
|
const handleMessage = (event) => {
|
|
523
559
|
if (event.nativeEvent.data != null) {
|
|
524
560
|
try {
|
|
@@ -533,6 +569,10 @@ const VisitRnSdkView = ({
|
|
|
533
569
|
break;
|
|
534
570
|
case 'CONNECT_TO_GOOGLE_FIT':
|
|
535
571
|
askForHealthConnectPermission();
|
|
572
|
+
|
|
573
|
+
break;
|
|
574
|
+
case 'startVideoCall':
|
|
575
|
+
startVideoConsultation(parsedObject);
|
|
536
576
|
break;
|
|
537
577
|
case 'UPDATE_PLATFORM':
|
|
538
578
|
webviewRef.current?.injectJavaScript(
|
|
@@ -600,6 +640,11 @@ const VisitRnSdkView = ({
|
|
|
600
640
|
Linking.openURL(pdfUrl);
|
|
601
641
|
}
|
|
602
642
|
break;
|
|
643
|
+
case 'OPEN_FACE_SCAN_FLOW':
|
|
644
|
+
EventRegister.emitEvent('visit-event', {
|
|
645
|
+
message: 'OPEN_FACE_SCAN_FLOW',
|
|
646
|
+
});
|
|
647
|
+
break;
|
|
603
648
|
case 'CLOSE_VIEW':
|
|
604
649
|
break;
|
|
605
650
|
|
|
@@ -693,6 +738,24 @@ const VisitRnSdkView = ({
|
|
|
693
738
|
}}
|
|
694
739
|
/>
|
|
695
740
|
) : null}
|
|
741
|
+
<VideoCallComponent
|
|
742
|
+
ref={videoCallRef}
|
|
743
|
+
onCallConnected={(info) => {
|
|
744
|
+
if (isLoggingEnabled) {
|
|
745
|
+
console.log('Video call connected:', info);
|
|
746
|
+
}
|
|
747
|
+
}}
|
|
748
|
+
onCallEnded={(info) => {
|
|
749
|
+
if (isLoggingEnabled) {
|
|
750
|
+
console.log('Video call ended:', info);
|
|
751
|
+
}
|
|
752
|
+
}}
|
|
753
|
+
onError={(error) => {
|
|
754
|
+
if (isLoggingEnabled) {
|
|
755
|
+
console.error('Video call error:', error);
|
|
756
|
+
}
|
|
757
|
+
}}
|
|
758
|
+
/>
|
|
696
759
|
</SafeAreaView>
|
|
697
760
|
);
|
|
698
761
|
};
|
|
@@ -723,6 +786,7 @@ export const fetchHourlyFitnessData = (startTimeStamp, isLoggingEnabled) => {
|
|
|
723
786
|
});
|
|
724
787
|
};
|
|
725
788
|
|
|
789
|
+
|
|
726
790
|
// debounce, deferred
|
|
727
791
|
// function debounce(task, ms) {
|
|
728
792
|
// let t = { promise: null, cancel: (_) => void 0 };
|
package/src/index.ios.js
CHANGED
|
@@ -20,6 +20,7 @@ import { WebView } from 'react-native-webview';
|
|
|
20
20
|
import DeviceInfo from 'react-native-device-info';
|
|
21
21
|
import { getWebViewLink, httpClient } from './Services';
|
|
22
22
|
import constants from './constants';
|
|
23
|
+
import VideoCallComponent from './components/VideoCallComponent';
|
|
23
24
|
|
|
24
25
|
const LINKING_ERROR =
|
|
25
26
|
`The package 'react-native-visit-rn-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -183,10 +184,52 @@ const VisitRnSdkView = ({
|
|
|
183
184
|
);
|
|
184
185
|
|
|
185
186
|
const webviewRef = useRef(null);
|
|
187
|
+
const videoCallRef = useRef(null);
|
|
186
188
|
const [apiBaseUrl, setApiBaseUrl] = useState('');
|
|
187
189
|
const [authToken, setAuthToken] = useState('');
|
|
188
190
|
const [hasLoadedOnce, setHasLoadedOnce] = useState(false);
|
|
189
191
|
|
|
192
|
+
|
|
193
|
+
const runBeforeFirst = `
|
|
194
|
+
window.isNativeApp = true;
|
|
195
|
+
window.platform = "IOS";
|
|
196
|
+
window.setSdkPlatform('IOS');
|
|
197
|
+
true; // note: this is required, or you'll sometimes get silent failures
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
const startVideoConsultation = useCallback(
|
|
201
|
+
(payload) => {
|
|
202
|
+
const roomName = payload?.roomName;
|
|
203
|
+
const accessToken = payload?.token;
|
|
204
|
+
const rawDoctorName = payload?.doctorName;
|
|
205
|
+
const visibleDoctorName =
|
|
206
|
+
rawDoctorName && rawDoctorName.indexOf('Dr.') > -1
|
|
207
|
+
? rawDoctorName.replace('Dr. ', '')
|
|
208
|
+
: rawDoctorName && rawDoctorName.indexOf('Dr') > -1
|
|
209
|
+
? rawDoctorName.replace('Dr ', '')
|
|
210
|
+
: null;
|
|
211
|
+
const userName = payload?.userName;
|
|
212
|
+
|
|
213
|
+
if (!roomName || !accessToken) {
|
|
214
|
+
if (isLoggingEnabled) {
|
|
215
|
+
console.warn(
|
|
216
|
+
'Video call payload missing roomName/accessToken.'
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
videoCallRef.current?.startVideoCall({
|
|
223
|
+
roomName,
|
|
224
|
+
accessToken,
|
|
225
|
+
doctorName: rawDoctorName ?? '',
|
|
226
|
+
visibleDoctorName: visibleDoctorName ?? '',
|
|
227
|
+
userName,
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
[isLoggingEnabled]
|
|
231
|
+
);
|
|
232
|
+
|
|
190
233
|
const callSyncApi = useCallback(
|
|
191
234
|
(data) =>
|
|
192
235
|
httpClient
|
|
@@ -248,6 +291,9 @@ const VisitRnSdkView = ({
|
|
|
248
291
|
console.log('handleMessage data is', data);
|
|
249
292
|
console.log(unescapeHTML(event.nativeEvent.data));
|
|
250
293
|
switch (method) {
|
|
294
|
+
case 'startVideoCall':
|
|
295
|
+
startVideoConsultation(data);
|
|
296
|
+
break;
|
|
251
297
|
case 'UPDATE_PLATFORM':
|
|
252
298
|
webviewRef.current?.injectJavaScript('window.setSdkPlatform("IOS")');
|
|
253
299
|
break;
|
|
@@ -302,6 +348,11 @@ const VisitRnSdkView = ({
|
|
|
302
348
|
case 'OPEN_PDF':
|
|
303
349
|
Linking.openURL(url);
|
|
304
350
|
break;
|
|
351
|
+
case 'OPEN_FACE_SCAN_FLOW':
|
|
352
|
+
EventRegister.emitEvent('visit-event', {
|
|
353
|
+
message: 'OPEN_FACE_SCAN_FLOW',
|
|
354
|
+
});
|
|
355
|
+
break;
|
|
305
356
|
case 'CLOSE_VIEW':
|
|
306
357
|
break;
|
|
307
358
|
case 'GET_LOCATION_PERMISSIONS':
|
|
@@ -319,26 +370,45 @@ const VisitRnSdkView = ({
|
|
|
319
370
|
return (
|
|
320
371
|
// eslint-disable-next-line react-native/no-inline-styles
|
|
321
372
|
<SafeAreaView style={{ flex: 1, backgroundColor: 'white', height, width }}>
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
373
|
+
{loading ? (
|
|
374
|
+
<LoadingIndicator />
|
|
375
|
+
) : (
|
|
376
|
+
<WebView
|
|
377
|
+
ref={webviewRef}
|
|
378
|
+
source={{ uri: source }}
|
|
379
|
+
style={styles.webView}
|
|
380
|
+
javascriptEnabled
|
|
381
|
+
onMessage={handleMessage}
|
|
382
|
+
injectedJavaScriptBeforeContentLoaded={runBeforeFirst}
|
|
383
|
+
onError={(errorMessage) => {
|
|
384
|
+
EventRegister.emitEvent(visitEvent, {
|
|
385
|
+
message: 'web-view-error',
|
|
386
|
+
errorMessage: errorMessage,
|
|
387
|
+
});
|
|
388
|
+
if (isLoggingEnabled) {
|
|
389
|
+
console.warn('Webview error: ', errorMessage);
|
|
390
|
+
}
|
|
391
|
+
}}
|
|
392
|
+
/>
|
|
393
|
+
)}
|
|
394
|
+
<VideoCallComponent
|
|
395
|
+
ref={videoCallRef}
|
|
396
|
+
onCallConnected={(info) => {
|
|
397
|
+
if (isLoggingEnabled) {
|
|
398
|
+
console.log('Video call connected:', info);
|
|
399
|
+
}
|
|
400
|
+
}}
|
|
401
|
+
onCallEnded={(info) => {
|
|
402
|
+
if (isLoggingEnabled) {
|
|
403
|
+
console.log('Video call ended:', info);
|
|
404
|
+
}
|
|
405
|
+
}}
|
|
406
|
+
onError={(error) => {
|
|
407
|
+
if (isLoggingEnabled) {
|
|
408
|
+
console.error('Video call error:', error);
|
|
409
|
+
}
|
|
410
|
+
}}
|
|
411
|
+
/>
|
|
342
412
|
</SafeAreaView>
|
|
343
413
|
);
|
|
344
414
|
};
|