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.
- package/README.md +2 -2
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/visitrnsdk/VisitFitnessModule.kt +15 -0
- package/ios/VisitRnSdkViewManager.h +1 -0
- package/ios/VisitRnSdkViewManager.m +16 -0
- package/lib/commonjs/Services.js +2 -3
- package/lib/commonjs/Services.js.map +1 -1
- package/lib/commonjs/constants.js +1 -2
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/healthConnectRouting.js +53 -0
- package/lib/commonjs/healthConnectRouting.js.map +1 -0
- package/lib/commonjs/index.android.js +61 -43
- package/lib/commonjs/index.android.js.map +1 -1
- package/lib/commonjs/index.ios.js +13 -16
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/module/Services.js.map +1 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/healthConnectRouting.js +46 -0
- package/lib/module/healthConnectRouting.js.map +1 -0
- package/lib/module/index.android.js +57 -36
- package/lib/module/index.android.js.map +1 -1
- package/lib/module/index.ios.js +10 -11
- package/lib/module/index.ios.js.map +1 -1
- package/package.json +1 -1
- package/src/healthConnectRouting.js +72 -0
- package/src/index.android.js +28 -2
package/src/index.android.js
CHANGED
|
@@ -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
|
-
|
|
560
|
+
handleHealthConnectConnectionRequest(
|
|
561
|
+
parsedObject.disclaimerAccepted
|
|
562
|
+
);
|
|
537
563
|
break;
|
|
538
564
|
case 'UPDATE_PLATFORM':
|
|
539
565
|
webviewRef.current?.injectJavaScript(
|