react-native-visit-rn-sdk 3.0.6 → 3.0.7

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.
@@ -12,7 +12,6 @@ import {
12
12
  NativeEventEmitter,
13
13
  } from 'react-native';
14
14
 
15
-
16
15
  import WebView from 'react-native-webview';
17
16
 
18
17
  import LocationEnabler from 'react-native-location-enabler';
@@ -22,6 +21,7 @@ import DeviceInfo from 'react-native-device-info';
22
21
  import axios from 'axios';
23
22
 
24
23
  import constants from './constants';
24
+ import { routeHealthConnectConnectionRequest } from './healthConnectRouting';
25
25
 
26
26
  export const httpClient = axios.create({
27
27
  timeout: 60000,
@@ -277,6 +277,7 @@ const VisitRnSdkView = ({
277
277
  );
278
278
 
279
279
  const webviewRef = useRef(null);
280
+ const healthConnectFlowInFlightRef = useRef(false);
280
281
 
281
282
  const showLocationPermissionAlert = () => {
282
283
  Alert.alert(
@@ -407,6 +408,29 @@ const VisitRnSdkView = ({
407
408
  }
408
409
  };
409
410
 
411
+ const handleHealthConnectConnectionRequest = async (disclaimerAccepted) => {
412
+ await routeHealthConnectConnectionRequest({
413
+ disclaimerAccepted,
414
+ inFlightRef: healthConnectFlowInFlightRef,
415
+ isLoggingEnabled,
416
+ isNativeStepTrackingAvailable: () =>
417
+ NativeModules.VisitFitnessModule.isNativeStepTrackingAvailable(),
418
+ startPermissionFlow: askForHealthConnectPermission,
419
+ showDisclaimer: () =>
420
+ webviewRef.current?.injectJavaScript(`
421
+ if (typeof window.showHealthConnectDisclaimer === 'function') {
422
+ window.showHealthConnectDisclaimer();
423
+ }
424
+ true;
425
+ `),
426
+ onCapabilityCheckError: (error) => {
427
+ if (isLoggingEnabled) {
428
+ console.error('Native step tracking capability check failed', error);
429
+ }
430
+ },
431
+ });
432
+ };
433
+
410
434
  const getHealthConnectStatus = async () => {
411
435
  try {
412
436
  const healthConnectStatus =
@@ -533,7 +557,9 @@ const VisitRnSdkView = ({
533
557
  getHealthConnectStatus();
534
558
  break;
535
559
  case 'CONNECT_TO_GOOGLE_FIT':
536
- askForHealthConnectPermission();
560
+ handleHealthConnectConnectionRequest(
561
+ parsedObject.disclaimerAccepted
562
+ );
537
563
  break;
538
564
  case 'UPDATE_PLATFORM':
539
565
  webviewRef.current?.injectJavaScript(