react-native-mytatva-rn-sdk 1.0.0 → 1.1.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/android/app/build.gradle +5 -0
- package/android/build.gradle +5 -5
- package/android/gradle.properties +13 -5
- package/android/settings.gradle +9 -0
- package/android/src/main/AndroidManifest.xml +22 -1
- package/android/src/main/AndroidManifestNew.xml +59 -1
- package/android/src/main/java/com/{visitrnsdk/VisitRnSdkPackage.kt → mytatvarnsdk/MyTatvaRnSdkPackage.kt} +2 -2
- package/android/src/main/java/com/{visitrnsdk/VisitRnSdkViewManager.kt → mytatvarnsdk/MyTatvaRnSdkViewManager.kt} +1 -1
- package/lib/commonjs/BcaDeviceListSheet.js +286 -0
- package/lib/commonjs/BcaDeviceListSheet.js.map +1 -0
- package/lib/commonjs/MainWebView.js +68 -0
- package/lib/commonjs/MainWebView.js.map +1 -0
- package/lib/commonjs/ProgressWebView.js +547 -0
- package/lib/commonjs/ProgressWebView.js.map +1 -0
- package/lib/commonjs/Services.js +27 -1
- package/lib/commonjs/Services.js.map +1 -1
- package/lib/commonjs/Sheets.js +7 -0
- package/lib/commonjs/Sheets.js.map +1 -0
- package/lib/commonjs/api/auth.js +167 -0
- package/lib/commonjs/api/auth.js.map +1 -0
- package/lib/commonjs/api/base.js +224 -0
- package/lib/commonjs/api/base.js.map +1 -0
- package/lib/commonjs/api/index.js +12 -0
- package/lib/commonjs/api/index.js.map +1 -0
- package/lib/commonjs/assets/icons/achieve.svg +3 -0
- package/lib/commonjs/assets/icons/heart.svg +3 -0
- package/lib/commonjs/assets/icons/smartWatch.svg +3 -0
- package/lib/commonjs/constants/asyncstorage.js +29 -0
- package/lib/commonjs/constants/asyncstorage.js.map +1 -0
- package/lib/commonjs/constants/constants.js +1373 -0
- package/lib/commonjs/constants/constants.js.map +1 -0
- package/lib/commonjs/constants.js +12 -2
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/helpers/Matrics.js +49 -0
- package/lib/commonjs/helpers/Matrics.js.map +1 -0
- package/lib/commonjs/helpers/bluetoothPermissionHelper.js +114 -0
- package/lib/commonjs/helpers/bluetoothPermissionHelper.js.map +1 -0
- package/lib/commonjs/helpers/colors.js +304 -0
- package/lib/commonjs/helpers/colors.js.map +1 -0
- package/lib/commonjs/helpers/common.js +46 -0
- package/lib/commonjs/helpers/common.js.map +1 -0
- package/lib/commonjs/helpers/fonts.js +33 -0
- package/lib/commonjs/helpers/fonts.js.map +1 -0
- package/lib/commonjs/helpers/globalStyles.js +188 -0
- package/lib/commonjs/helpers/globalStyles.js.map +1 -0
- package/lib/commonjs/helpers/icons.js +16 -0
- package/lib/commonjs/helpers/icons.js.map +1 -0
- package/lib/commonjs/index.android.js +163 -414
- package/lib/commonjs/index.android.js.map +1 -1
- package/lib/commonjs/index.ios.js +138 -187
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/redux/Store.js +42 -0
- package/lib/commonjs/redux/Store.js.map +1 -0
- package/lib/commonjs/redux/hooks.js +8 -0
- package/lib/commonjs/redux/hooks.js.map +1 -0
- package/lib/commonjs/redux/sagas/AuthSaga.js +44 -0
- package/lib/commonjs/redux/sagas/AuthSaga.js.map +1 -0
- package/lib/commonjs/redux/sagas/index.js +15 -0
- package/lib/commonjs/redux/sagas/index.js.map +1 -0
- package/lib/commonjs/redux/slices/authSlice.js +80 -0
- package/lib/commonjs/redux/slices/authSlice.js.map +1 -0
- package/lib/commonjs/redux/slices/index.js +44 -0
- package/lib/commonjs/redux/slices/index.js.map +1 -0
- package/lib/commonjs/types/auth.js +2 -0
- package/lib/commonjs/types/auth.js.map +1 -0
- package/lib/commonjs/types/common.js +2 -0
- package/lib/commonjs/types/common.js.map +1 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/module/BcaDeviceListSheet.js +277 -0
- package/lib/module/BcaDeviceListSheet.js.map +1 -0
- package/lib/module/MainWebView.js +61 -0
- package/lib/module/MainWebView.js.map +1 -0
- package/lib/module/ProgressWebView.js +536 -0
- package/lib/module/ProgressWebView.js.map +1 -0
- package/lib/module/Services.js +24 -0
- package/lib/module/Services.js.map +1 -1
- package/lib/module/Sheets.js +4 -0
- package/lib/module/Sheets.js.map +1 -0
- package/lib/module/api/auth.js +160 -0
- package/lib/module/api/auth.js.map +1 -0
- package/lib/module/api/base.js +212 -0
- package/lib/module/api/base.js.map +1 -0
- package/lib/module/api/index.js +5 -0
- package/lib/module/api/index.js.map +1 -0
- package/lib/module/assets/icons/achieve.svg +3 -0
- package/lib/module/assets/icons/heart.svg +3 -0
- package/lib/module/assets/icons/smartWatch.svg +3 -0
- package/lib/module/constants/asyncstorage.js +23 -0
- package/lib/module/constants/asyncstorage.js.map +1 -0
- package/lib/module/constants/constants.js +1367 -0
- package/lib/module/constants/constants.js.map +1 -0
- package/lib/module/constants.js +12 -2
- package/lib/module/constants.js.map +1 -1
- package/lib/module/helpers/Matrics.js +44 -0
- package/lib/module/helpers/Matrics.js.map +1 -0
- package/lib/module/helpers/bluetoothPermissionHelper.js +103 -0
- package/lib/module/helpers/bluetoothPermissionHelper.js.map +1 -0
- package/lib/module/helpers/colors.js +298 -0
- package/lib/module/helpers/colors.js.map +1 -0
- package/lib/module/helpers/common.js +34 -0
- package/lib/module/helpers/common.js.map +1 -0
- package/lib/module/helpers/fonts.js +27 -0
- package/lib/module/helpers/fonts.js.map +1 -0
- package/lib/module/helpers/globalStyles.js +181 -0
- package/lib/module/helpers/globalStyles.js.map +1 -0
- package/lib/module/helpers/icons.js +9 -0
- package/lib/module/helpers/icons.js.map +1 -0
- package/lib/module/index.android.js +165 -413
- package/lib/module/index.android.js.map +1 -1
- package/lib/module/index.ios.js +138 -187
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/redux/Store.js +34 -0
- package/lib/module/redux/Store.js.map +1 -0
- package/lib/module/redux/hooks.js +7 -0
- package/lib/module/redux/hooks.js.map +1 -0
- package/lib/module/redux/sagas/AuthSaga.js +34 -0
- package/lib/module/redux/sagas/AuthSaga.js.map +1 -0
- package/lib/module/redux/sagas/index.js +8 -0
- package/lib/module/redux/sagas/index.js.map +1 -0
- package/lib/module/redux/slices/authSlice.js +68 -0
- package/lib/module/redux/slices/authSlice.js.map +1 -0
- package/lib/module/redux/slices/index.js +24 -0
- package/lib/module/redux/slices/index.js.map +1 -0
- package/lib/module/types/auth.js +2 -0
- package/lib/module/types/auth.js.map +1 -0
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/BcaDeviceListSheet.d.ts +7 -0
- package/lib/typescript/BcaDeviceListSheet.d.ts.map +1 -0
- package/lib/typescript/MainWebView.d.ts +4 -0
- package/lib/typescript/MainWebView.d.ts.map +1 -0
- package/lib/typescript/ProgressWebView.d.ts +4 -0
- package/lib/typescript/ProgressWebView.d.ts.map +1 -0
- package/lib/typescript/Services.d.ts +5 -0
- package/lib/typescript/Services.d.ts.map +1 -0
- package/lib/typescript/Sheets.d.ts +2 -0
- package/lib/typescript/Sheets.d.ts.map +1 -0
- package/lib/typescript/api/auth.d.ts +33 -0
- package/lib/typescript/api/auth.d.ts.map +1 -0
- package/lib/typescript/api/base.d.ts +20 -0
- package/lib/typescript/api/base.d.ts.map +1 -0
- package/lib/typescript/api/index.d.ts +35 -0
- package/lib/typescript/api/index.d.ts.map +1 -0
- package/lib/typescript/constants/asyncstorage.d.ts +23 -0
- package/lib/typescript/constants/asyncstorage.d.ts.map +1 -0
- package/lib/typescript/constants/constants.d.ts +1081 -0
- package/lib/typescript/constants/constants.d.ts.map +1 -0
- package/lib/typescript/constants.d.ts +16 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/helpers/Matrics.d.ts +14 -0
- package/lib/typescript/helpers/Matrics.d.ts.map +1 -0
- package/lib/typescript/helpers/bluetoothPermissionHelper.d.ts +18 -0
- package/lib/typescript/helpers/bluetoothPermissionHelper.d.ts.map +1 -0
- package/lib/typescript/helpers/colors.d.ts +297 -0
- package/lib/typescript/helpers/colors.d.ts.map +1 -0
- package/lib/typescript/helpers/common.d.ts +8 -0
- package/lib/typescript/helpers/common.d.ts.map +1 -0
- package/lib/typescript/helpers/fonts.d.ts +23 -0
- package/lib/typescript/helpers/fonts.d.ts.map +1 -0
- package/lib/typescript/helpers/globalStyles.d.ts +176 -0
- package/lib/typescript/helpers/globalStyles.d.ts.map +1 -0
- package/lib/typescript/helpers/icons.d.ts +6 -0
- package/lib/typescript/helpers/icons.d.ts.map +1 -0
- package/lib/typescript/index.android.d.ts +30 -0
- package/lib/typescript/index.android.d.ts.map +1 -0
- package/lib/typescript/index.ios.d.ts +28 -0
- package/lib/typescript/index.ios.d.ts.map +1 -0
- package/lib/typescript/redux/Store.d.ts +13 -0
- package/lib/typescript/redux/Store.d.ts.map +1 -0
- package/lib/typescript/redux/hooks.d.ts +1 -0
- package/lib/typescript/redux/hooks.d.ts.map +1 -0
- package/lib/typescript/redux/sagas/AuthSaga.d.ts +3 -0
- package/lib/typescript/redux/sagas/AuthSaga.d.ts.map +1 -0
- package/lib/typescript/redux/sagas/index.d.ts +3 -0
- package/lib/typescript/redux/sagas/index.d.ts.map +1 -0
- package/lib/typescript/redux/slices/authSlice.d.ts +5 -0
- package/lib/typescript/redux/slices/authSlice.d.ts.map +1 -0
- package/lib/typescript/redux/slices/index.d.ts +6 -0
- package/lib/typescript/redux/slices/index.d.ts.map +1 -0
- package/lib/typescript/types/auth.d.ts +485 -0
- package/lib/typescript/types/auth.d.ts.map +1 -0
- package/lib/typescript/types/common.d.ts +19 -0
- package/lib/typescript/types/common.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +4 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/package.json +39 -8
- package/src/BcaDeviceListSheet.tsx +331 -0
- package/src/MainWebView.tsx +67 -0
- package/src/ProgressWebView.tsx +602 -0
- package/src/Services.js +40 -0
- package/src/Sheets.js +4 -0
- package/src/api/auth.ts +156 -0
- package/src/api/base.ts +247 -0
- package/src/api/index.ts +5 -0
- package/src/assets/icons/achieve.svg +3 -0
- package/src/assets/icons/heart.svg +3 -0
- package/src/assets/icons/smartWatch.svg +3 -0
- package/src/constants/asyncstorage.ts +23 -0
- package/src/constants/constants.ts +1204 -0
- package/src/constants.ts +14 -0
- package/src/helpers/Matrics.ts +48 -0
- package/src/helpers/bluetoothPermissionHelper.ts +198 -0
- package/src/helpers/colors.ts +320 -0
- package/src/helpers/common.ts +46 -0
- package/src/helpers/fonts.ts +28 -0
- package/src/helpers/globalStyles.ts +179 -0
- package/src/helpers/icons.ts +11 -0
- package/src/index.android.js +164 -577
- package/src/index.ios.js +147 -215
- package/src/redux/Store.ts +36 -0
- package/src/redux/hooks.ts +6 -0
- package/src/redux/sagas/AuthSaga.ts +49 -0
- package/src/redux/sagas/index.ts +9 -0
- package/src/redux/slices/authSlice.ts +81 -0
- package/src/redux/slices/index.ts +29 -0
- package/src/types/auth.ts +533 -0
- package/src/types/common.ts +19 -0
- package/src/types/index.ts +8 -0
- package/lib/typescript/index.test.d.ts +0 -1
- package/lib/typescript/index.test.d.ts.map +0 -1
- package/src/constants.js +0 -4
- /package/ios/{VisitRnSdk.xcodeproj → MyTatvaRnSdk.xcodeproj}/project.pbxproj +0 -0
- /package/ios/{VisitRnSdkViewManager.h → MyTatvaRnSdkViewManager.h} +0 -0
- /package/ios/{VisitRnSdkViewManager.m → MyTatvaRnSdkViewManager.m} +0 -0
- /package/{react-native-visit-rn-sdk.podspec → react-native-mytatva-rn-sdk.podspec} +0 -0
package/src/index.android.js
CHANGED
|
@@ -1,207 +1,94 @@
|
|
|
1
1
|
import React, { useRef, useEffect, useState, useCallback } from 'react';
|
|
2
2
|
import { EventRegister } from 'react-native-event-listeners';
|
|
3
|
+
import { NavigationContainer } from '@react-navigation/native';
|
|
4
|
+
// import { createStackNavigator } from '@react-navigation/stack';
|
|
3
5
|
|
|
4
6
|
import {
|
|
5
7
|
SafeAreaView,
|
|
6
|
-
NativeModules,
|
|
7
|
-
PermissionsAndroid,
|
|
8
8
|
BackHandler,
|
|
9
9
|
Linking,
|
|
10
|
-
Alert,
|
|
11
10
|
AppState,
|
|
11
|
+
ActivityIndicator,
|
|
12
|
+
View,
|
|
13
|
+
Text,
|
|
12
14
|
} from 'react-native';
|
|
15
|
+
import '../src/Sheets';
|
|
16
|
+
import { Provider } from 'react-redux';
|
|
17
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
18
|
+
import createSagaMiddleware from '@redux-saga/core';
|
|
19
|
+
import rootReducer from './redux/slices';
|
|
20
|
+
import rootSaga from './redux/sagas';
|
|
13
21
|
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import LocationEnabler from 'react-native-location-enabler';
|
|
17
|
-
|
|
18
|
-
import DeviceInfo from 'react-native-device-info';
|
|
22
|
+
// import {enableScreens} from 'react-native-screens';
|
|
19
23
|
|
|
20
24
|
import axios from 'axios';
|
|
21
25
|
|
|
22
26
|
import constants from './constants';
|
|
27
|
+
import {getEncryptedText, getDecryptedData} from './Services';
|
|
28
|
+
import MainWebView from './MainWebView';
|
|
29
|
+
import ProgressWebView from './ProgressWebView';
|
|
30
|
+
import { SheetManager, SheetProvider } from 'react-native-actions-sheet';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// enableScreens();
|
|
34
|
+
|
|
35
|
+
// const Stack = createStackNavigator();
|
|
23
36
|
|
|
24
37
|
export const httpClient = axios.create({
|
|
25
38
|
timeout: 60000,
|
|
39
|
+
headers: {
|
|
40
|
+
'api-key': 'lChjFRJce3bxmoS3TSQk5w==',
|
|
41
|
+
'Content-Type': 'text/plain',
|
|
42
|
+
},
|
|
26
43
|
});
|
|
27
44
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
45
|
+
const sagaMiddleware = createSagaMiddleware();
|
|
46
|
+
const store = configureStore({
|
|
47
|
+
reducer: rootReducer,
|
|
48
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(sagaMiddleware)
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
sagaMiddleware.run(rootSaga);
|
|
33
52
|
|
|
34
53
|
const MyTatvaRnSdkView = ({
|
|
35
|
-
|
|
54
|
+
mobileNumber,
|
|
55
|
+
uuid,
|
|
36
56
|
baseUrl,
|
|
37
57
|
errorBaseUrl,
|
|
38
58
|
token,
|
|
39
|
-
moduleName,
|
|
40
59
|
environment,
|
|
41
|
-
|
|
42
|
-
|
|
60
|
+
userMetaInfo,
|
|
61
|
+
clientSource,
|
|
62
|
+
moduleName,
|
|
63
|
+
navigation
|
|
43
64
|
}) => {
|
|
44
65
|
const [source, setSource] = useState('');
|
|
45
66
|
const [appState, setAppState] = useState(AppState.currentState);
|
|
67
|
+
const [loading, setLoading] = useState(false);
|
|
68
|
+
const [isError, setError] = useState(false);
|
|
46
69
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
// useEffect(() => {
|
|
71
|
+
// if ((baseUrl?.trim()?.length || 0) > 0) {
|
|
72
|
+
// setSource(baseUrl);
|
|
73
|
+
// }
|
|
74
|
+
// }, [
|
|
75
|
+
// baseUrl,
|
|
76
|
+
// ]);
|
|
51
77
|
|
|
52
78
|
useEffect(() => {
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if ((magicLink?.trim()?.length || 0) > 0) {
|
|
60
|
-
setSource(magicLink);
|
|
61
|
-
} else {
|
|
62
|
-
DeviceInfo.getAndroidId()
|
|
63
|
-
.then((deviceId) => {
|
|
64
|
-
var buildNumber = DeviceInfo.getBuildNumber();
|
|
65
|
-
let systemVersion = DeviceInfo.getSystemVersion();
|
|
66
|
-
let version = DeviceInfo.getVersion();
|
|
67
|
-
|
|
68
|
-
if (isLoggingEnabled) {
|
|
69
|
-
console.log(
|
|
70
|
-
' baseUrl : ' +
|
|
71
|
-
baseUrl +
|
|
72
|
-
'token: ' +
|
|
73
|
-
token +
|
|
74
|
-
' cpsid: ' +
|
|
75
|
-
cpsid +
|
|
76
|
-
' environment: ' +
|
|
77
|
-
environment +
|
|
78
|
-
'buildNumber:' +
|
|
79
|
-
buildNumber +
|
|
80
|
-
' systemVersion:' +
|
|
81
|
-
systemVersion +
|
|
82
|
-
' version : ' +
|
|
83
|
-
version +
|
|
84
|
-
' deviceId',
|
|
85
|
-
deviceId
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
var finalEndPoint = `${baseUrl}/partners/v3/generate-magic-link-star-health`;
|
|
90
|
-
|
|
91
|
-
if (isLoggingEnabled) {
|
|
92
|
-
console.log('finalEndPoint: ' + finalEndPoint);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
httpClient
|
|
96
|
-
.post(finalEndPoint, {
|
|
97
|
-
cpsid: cpsid,
|
|
98
|
-
token: token,
|
|
99
|
-
srcClientId: 'Android',
|
|
100
|
-
deviceId: deviceId,
|
|
101
|
-
appVersion: version,
|
|
102
|
-
deviceVersion: systemVersion,
|
|
103
|
-
userEnv: environment,
|
|
104
|
-
})
|
|
105
|
-
.then((response) => {
|
|
106
|
-
let data = response.data;
|
|
107
|
-
// let visitMagicLink = data.result; //@Deprecated. Superseded by magic code usage.
|
|
108
|
-
const errorMessage = data.errorMessage;
|
|
109
|
-
const magicCode = data.magicCode;
|
|
110
|
-
const responseReferenceId = data.responseReferenceId;
|
|
111
|
-
|
|
112
|
-
let finalBaseUrl = '';
|
|
113
|
-
|
|
114
|
-
if (environment.toUpperCase() === 'PROD') {
|
|
115
|
-
finalBaseUrl = constants.PROD_BASE_URL;
|
|
116
|
-
} else {
|
|
117
|
-
finalBaseUrl = constants.STAGE_BASE_URL;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let finalUrl = `${finalBaseUrl}=${magicCode}`;
|
|
121
|
-
|
|
122
|
-
if (data.message === 'success') {
|
|
123
|
-
if ((moduleName?.trim()?.length || 0) > 0) {
|
|
124
|
-
finalUrl += `&tab=${moduleName}`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
typeof responseReferenceId === 'string' &&
|
|
129
|
-
responseReferenceId.trim().length > 0
|
|
130
|
-
) {
|
|
131
|
-
finalUrl += `&responseReferenceId=${responseReferenceId}`;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (isLoggingEnabled) {
|
|
135
|
-
console.log('magicLink: ' + finalUrl);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setSource(finalUrl);
|
|
139
|
-
} else {
|
|
140
|
-
var errorUrl = `${errorBaseUrl}/star-health?error=${errorMessage}`;
|
|
141
|
-
setSource(errorUrl);
|
|
142
|
-
|
|
143
|
-
if (errorMessage != null) {
|
|
144
|
-
if (errorMessage === 'Please login again') {
|
|
145
|
-
EventRegister.emitEvent('visit-event', {
|
|
146
|
-
message: 'unauthorized-wellness-access',
|
|
147
|
-
errorMessage: errorMessage,
|
|
148
|
-
});
|
|
149
|
-
} else if (errorMessage.includes('External Server Error')) {
|
|
150
|
-
EventRegister.emitEvent('visit-event', {
|
|
151
|
-
message: 'external-server-error',
|
|
152
|
-
errorMessage: errorMessage,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (isLoggingEnabled) {
|
|
158
|
-
console.log(
|
|
159
|
-
'erorMessage: ' +
|
|
160
|
-
data.errorMessage +
|
|
161
|
-
' errorUrl: ' +
|
|
162
|
-
errorUrl
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
.catch((error) => {
|
|
168
|
-
var errorUrl = `${errorBaseUrl}/star-health?error=${error}`;
|
|
169
|
-
setSource(errorUrl);
|
|
170
|
-
|
|
171
|
-
EventRegister.emitEvent('visit-event', {
|
|
172
|
-
message: 'generate-magic-link-failed',
|
|
173
|
-
errorMessage: `${error}`,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (isLoggingEnabled) {
|
|
177
|
-
console.log('error: ' + error);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
})
|
|
181
|
-
.catch((err) => {
|
|
182
|
-
var errorUrl = `${errorBaseUrl}/star-health?error=${err}`;
|
|
183
|
-
setSource(errorUrl);
|
|
184
|
-
|
|
185
|
-
EventRegister.emitEvent('visit-event', {
|
|
186
|
-
message: 'getDeviceInfo-failed',
|
|
187
|
-
errorMessage: `${err}`,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
if (isLoggingEnabled) {
|
|
191
|
-
console.log('getDeviceInfo err', err);
|
|
192
|
-
}
|
|
79
|
+
if (!uuid && !mobileNumber) {
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
EventRegister.emitEvent('mytatva-event', {
|
|
82
|
+
message: 'unique-identifier',
|
|
83
|
+
errorMessage: 'contact number or patientId is required',
|
|
193
84
|
});
|
|
85
|
+
}, 1000)
|
|
86
|
+
setError(true)
|
|
87
|
+
} else {
|
|
88
|
+
authenticateSDK()
|
|
89
|
+
setError(false)
|
|
194
90
|
}
|
|
195
|
-
}, [
|
|
196
|
-
cpsid,
|
|
197
|
-
token,
|
|
198
|
-
baseUrl,
|
|
199
|
-
errorBaseUrl,
|
|
200
|
-
moduleName,
|
|
201
|
-
environment,
|
|
202
|
-
magicLink,
|
|
203
|
-
isLoggingEnabled,
|
|
204
|
-
]);
|
|
91
|
+
}, [uuid, mobileNumber])
|
|
205
92
|
|
|
206
93
|
useEffect(() => {
|
|
207
94
|
const subscription = AppState.addEventListener(
|
|
@@ -215,6 +102,43 @@ const MyTatvaRnSdkView = ({
|
|
|
215
102
|
};
|
|
216
103
|
}, [appState]); // Include appState in the dependency array to ensure it's up to date.
|
|
217
104
|
|
|
105
|
+
|
|
106
|
+
const authenticateSDK = () => {
|
|
107
|
+
setLoading(true)
|
|
108
|
+
let baseUrl = environment.toUpperCase() === 'PROD' ? constants.PROD_BASE_URL : constants.STAGE_BASE_URL
|
|
109
|
+
const finalUrl = baseUrl + '/helper/authenticateClient';
|
|
110
|
+
const data = {
|
|
111
|
+
source : clientSource,
|
|
112
|
+
sourceKey : token
|
|
113
|
+
}
|
|
114
|
+
axios({
|
|
115
|
+
method: 'post',
|
|
116
|
+
url: finalUrl,
|
|
117
|
+
headers: {
|
|
118
|
+
'api-key': environment.toUpperCase() === 'PROD' ? constants.PROD_API_KEY : constants.STAGE_API_KEY,
|
|
119
|
+
'Content-Type': 'text/plain',
|
|
120
|
+
},
|
|
121
|
+
data: getEncryptedText(data, environment),
|
|
122
|
+
})
|
|
123
|
+
.then(async response => {
|
|
124
|
+
const parsedResponse = await JSON.parse(getDecryptedData(response?.data, environment));
|
|
125
|
+
if (parsedResponse?.data == 0) {
|
|
126
|
+
setError(true);
|
|
127
|
+
EventRegister.emitEvent('mytatva-event', {
|
|
128
|
+
message: 'unauthorized-client',
|
|
129
|
+
errorMessage: 'Unauthorized Access',
|
|
130
|
+
});
|
|
131
|
+
} else {
|
|
132
|
+
getSourceUrl();
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
.catch((error) => {
|
|
136
|
+
console.log("error", error)
|
|
137
|
+
}).finally(() => {
|
|
138
|
+
setLoading(false);
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
218
142
|
const handleAppStateChange = (nextAppState) => {
|
|
219
143
|
// console.log(
|
|
220
144
|
// "nextAppState: " + nextAppState + ", previousState: " + appState
|
|
@@ -225,252 +149,14 @@ const MyTatvaRnSdkView = ({
|
|
|
225
149
|
if (isLoggingEnabled) {
|
|
226
150
|
console.log('App has come to the foreground!');
|
|
227
151
|
}
|
|
228
|
-
getHealthConnectStatus();
|
|
152
|
+
// getHealthConnectStatus();
|
|
229
153
|
}
|
|
230
154
|
|
|
231
|
-
setAppState(nextAppState); // Update the state with the new app state
|
|
155
|
+
// setAppState(nextAppState); // Update the state with the new app state
|
|
232
156
|
};
|
|
233
157
|
|
|
234
|
-
const [enabled, requestResolution] = useLocationSettings(
|
|
235
|
-
{
|
|
236
|
-
priority: HIGH_ACCURACY, // default BALANCED_POWER_ACCURACY
|
|
237
|
-
alwaysShow: true, // default false
|
|
238
|
-
needBle: true, // default false
|
|
239
|
-
},
|
|
240
|
-
false /* optional: default undefined */
|
|
241
|
-
);
|
|
242
|
-
|
|
243
158
|
const webviewRef = useRef(null);
|
|
244
159
|
|
|
245
|
-
const showLocationPermissionAlert = () => {
|
|
246
|
-
Alert.alert(
|
|
247
|
-
'Permission Required',
|
|
248
|
-
'Allow location permission from app settings',
|
|
249
|
-
[
|
|
250
|
-
{
|
|
251
|
-
text: 'Cancel',
|
|
252
|
-
onPress: () => {
|
|
253
|
-
console.log('Cancel clicked');
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
text: 'Go to Settings',
|
|
258
|
-
onPress: () => {
|
|
259
|
-
Linking.openSettings();
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
]
|
|
263
|
-
);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const requestLocationPermission = async () => {
|
|
267
|
-
try {
|
|
268
|
-
console.log('requestLocationPermission called');
|
|
269
|
-
|
|
270
|
-
const isLocationPermissionPresent = await PermissionsAndroid.check(
|
|
271
|
-
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
console.log(
|
|
275
|
-
'isLocationPermissionPresent: ' +
|
|
276
|
-
isLocationPermissionPresent +
|
|
277
|
-
' showPermissionAlreadyDeniedDialog: ' +
|
|
278
|
-
showPermissionAlreadyDeniedDialog
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
if (!isLocationPermissionPresent && showPermissionAlreadyDeniedDialog) {
|
|
282
|
-
console.log('showLocationPermissionAlert() called');
|
|
283
|
-
|
|
284
|
-
showLocationPermissionAlert();
|
|
285
|
-
} else {
|
|
286
|
-
console.log('requesting location permission');
|
|
287
|
-
|
|
288
|
-
const granted = await PermissionsAndroid.request(
|
|
289
|
-
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
|
|
290
|
-
{
|
|
291
|
-
title: 'Need Location Permission',
|
|
292
|
-
message: 'Need access to location permission',
|
|
293
|
-
buttonNeutral: 'Ask Me Later',
|
|
294
|
-
buttonNegative: 'Cancel',
|
|
295
|
-
buttonPositive: 'OK',
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
299
|
-
if (isLoggingEnabled) {
|
|
300
|
-
console.log('Location permission granted');
|
|
301
|
-
}
|
|
302
|
-
setShowPermissionAlreadyDeniedDialog(false);
|
|
303
|
-
|
|
304
|
-
if (!enabled) {
|
|
305
|
-
requestResolution();
|
|
306
|
-
} else {
|
|
307
|
-
var finalString = `window.checkTheGpsPermission(true)`;
|
|
308
|
-
console.log('requestLocationPermission: ' + finalString);
|
|
309
|
-
|
|
310
|
-
webviewRef.current?.injectJavaScript(finalString);
|
|
311
|
-
}
|
|
312
|
-
} else {
|
|
313
|
-
setShowPermissionAlreadyDeniedDialog(true);
|
|
314
|
-
console.log('Location permission denied');
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
} catch (e) {
|
|
318
|
-
console.error(e);
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
const showHealthConnectPermissionDeniedDialog = () => {
|
|
323
|
-
Alert.alert(
|
|
324
|
-
'Permission Denied',
|
|
325
|
-
'Go to Health Connect App to allow app permission',
|
|
326
|
-
[
|
|
327
|
-
{
|
|
328
|
-
text: 'Cancel',
|
|
329
|
-
onPress: () => {
|
|
330
|
-
console.log('Cancel clicked');
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
text: 'Open Health Connect',
|
|
335
|
-
onPress: () => {
|
|
336
|
-
openHealthConnectApp();
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
]
|
|
340
|
-
);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
const openHealthConnectApp = async () => {
|
|
344
|
-
NativeModules.VisitFitnessModule.openHealthConnectApp();
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const askForHealthConnectPermission = async () => {
|
|
348
|
-
try {
|
|
349
|
-
const isPermissionGranted =
|
|
350
|
-
await NativeModules.VisitFitnessModule.askForFitnessPermission();
|
|
351
|
-
|
|
352
|
-
if (isLoggingEnabled) {
|
|
353
|
-
console.log('isPermissionGranted: ' + isPermissionGranted);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (isPermissionGranted === 'GRANTED') {
|
|
357
|
-
getHealthConnectStatus();
|
|
358
|
-
// getDailyFitnessData();
|
|
359
|
-
} else if (isPermissionGranted === 'CANCELLED') {
|
|
360
|
-
showHealthConnectPermissionDeniedDialog();
|
|
361
|
-
}
|
|
362
|
-
} catch (e) {
|
|
363
|
-
if (isLoggingEnabled) {
|
|
364
|
-
console.error(e);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
const getHealthConnectStatus = async () => {
|
|
370
|
-
try {
|
|
371
|
-
const healthConnectStatus =
|
|
372
|
-
await NativeModules.VisitFitnessModule.getHealthConnectStatus();
|
|
373
|
-
|
|
374
|
-
if (isLoggingEnabled) {
|
|
375
|
-
console.log('getHealthConnectStatus: ' + healthConnectStatus);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (healthConnectStatus === 'NOT_SUPPORTED') {
|
|
379
|
-
webviewRef.current?.injectJavaScript(
|
|
380
|
-
'window.healthConnectNotSupported()'
|
|
381
|
-
);
|
|
382
|
-
} else if (healthConnectStatus === 'NOT_INSTALLED') {
|
|
383
|
-
webviewRef.current?.injectJavaScript(
|
|
384
|
-
'window.healthConnectNotInstall()'
|
|
385
|
-
);
|
|
386
|
-
webviewRef.current?.injectJavaScript(
|
|
387
|
-
'window.updateFitnessPermissions(false,0,0)'
|
|
388
|
-
);
|
|
389
|
-
} else if (healthConnectStatus === 'INSTALLED') {
|
|
390
|
-
webviewRef.current?.injectJavaScript('window.healthConnectAvailable()');
|
|
391
|
-
|
|
392
|
-
webviewRef.current?.injectJavaScript(
|
|
393
|
-
'window.updateFitnessPermissions(false,0,0)'
|
|
394
|
-
);
|
|
395
|
-
} else if (healthConnectStatus === 'CONNECTED') {
|
|
396
|
-
getDailyFitnessData();
|
|
397
|
-
}
|
|
398
|
-
} catch (e) {
|
|
399
|
-
if (isLoggingEnabled) {
|
|
400
|
-
console.error(e);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
const getDailyFitnessData = async () => {
|
|
406
|
-
if (isLoggingEnabled) {
|
|
407
|
-
console.log('getDailyFitnessData() called');
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
try {
|
|
411
|
-
const dailyFitnessData =
|
|
412
|
-
await NativeModules.VisitFitnessModule.requestDailyFitnessData();
|
|
413
|
-
|
|
414
|
-
webviewRef.current?.injectJavaScript(dailyFitnessData);
|
|
415
|
-
} catch (error) {
|
|
416
|
-
if (isLoggingEnabled) {
|
|
417
|
-
console.log(error);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
const requestActivityData = async (type, frequency, timeStamp) => {
|
|
423
|
-
if (isLoggingEnabled) {
|
|
424
|
-
console.log('requestActivityData() called');
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
try {
|
|
428
|
-
const graphData =
|
|
429
|
-
await NativeModules.VisitFitnessModule.requestActivityDataFromHealthConnect(
|
|
430
|
-
type,
|
|
431
|
-
frequency,
|
|
432
|
-
timeStamp
|
|
433
|
-
);
|
|
434
|
-
|
|
435
|
-
if (isLoggingEnabled) {
|
|
436
|
-
console.log(`requestActivityData() data: ` + graphData);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
webviewRef.current?.injectJavaScript('window.' + graphData);
|
|
440
|
-
} catch (error) {
|
|
441
|
-
if (isLoggingEnabled) {
|
|
442
|
-
console.log(error);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
const updateApiBaseUrl = async (
|
|
448
|
-
apiBaseUrl,
|
|
449
|
-
authtoken,
|
|
450
|
-
googleFitLastSync,
|
|
451
|
-
gfHourlyLastSync
|
|
452
|
-
) => {
|
|
453
|
-
if (isLoggingEnabled) {
|
|
454
|
-
console.log('updateApiBaseUrl() called.');
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
try {
|
|
458
|
-
const message = await NativeModules.VisitFitnessModule.updateApiBaseUrl(
|
|
459
|
-
apiBaseUrl,
|
|
460
|
-
authtoken,
|
|
461
|
-
googleFitLastSync,
|
|
462
|
-
gfHourlyLastSync
|
|
463
|
-
);
|
|
464
|
-
|
|
465
|
-
if (isLoggingEnabled) {
|
|
466
|
-
console.log(message);
|
|
467
|
-
}
|
|
468
|
-
} catch (error) {
|
|
469
|
-
if (isLoggingEnabled) {
|
|
470
|
-
console.log(error);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
160
|
|
|
475
161
|
const runBeforeFirst = `
|
|
476
162
|
window.isNativeApp = true;
|
|
@@ -479,78 +165,19 @@ const MyTatvaRnSdkView = ({
|
|
|
479
165
|
true; // note: this is required, or you'll sometimes get silent failures
|
|
480
166
|
`;
|
|
481
167
|
|
|
168
|
+
// console.log("runBeforeFirst====", runBeforeFirst)
|
|
482
169
|
const handleMessage = (event) => {
|
|
170
|
+
console.log("event====", event)
|
|
483
171
|
if (event.nativeEvent.data != null) {
|
|
484
172
|
try {
|
|
485
|
-
if (isLoggingEnabled) {
|
|
486
|
-
console.log('Event :' + event.nativeEvent.data);
|
|
487
|
-
}
|
|
488
173
|
const parsedObject = JSON.parse(event.nativeEvent.data);
|
|
489
174
|
if (parsedObject.method != null) {
|
|
490
175
|
switch (parsedObject.method) {
|
|
491
|
-
case 'GET_HEALTH_CONNECT_STATUS':
|
|
492
|
-
getHealthConnectStatus();
|
|
493
|
-
break;
|
|
494
|
-
case 'CONNECT_TO_GOOGLE_FIT':
|
|
495
|
-
askForHealthConnectPermission();
|
|
496
|
-
break;
|
|
497
176
|
case 'UPDATE_PLATFORM':
|
|
498
177
|
webviewRef.current?.injectJavaScript(
|
|
499
178
|
'window.setSdkPlatform("ANDROID")'
|
|
500
179
|
);
|
|
501
|
-
|
|
502
|
-
case 'UPDATE_API_BASE_URL':
|
|
503
|
-
{
|
|
504
|
-
let apiBaseUrl = parsedObject.apiBaseUrl;
|
|
505
|
-
let authtoken = parsedObject.authtoken;
|
|
506
|
-
|
|
507
|
-
let googleFitLastSync = parsedObject.googleFitLastSync;
|
|
508
|
-
let gfHourlyLastSync = parsedObject.gfHourlyLastSync;
|
|
509
|
-
|
|
510
|
-
if (isLoggingEnabled) {
|
|
511
|
-
console.log(
|
|
512
|
-
'apiBaseUrl: ' +
|
|
513
|
-
'NOT SHOWN' +
|
|
514
|
-
' authtoken: ' +
|
|
515
|
-
'NOT SHOWN' +
|
|
516
|
-
' googleFitLastSync: ' +
|
|
517
|
-
googleFitLastSync +
|
|
518
|
-
' gfHourlyLastSync: ' +
|
|
519
|
-
gfHourlyLastSync
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
updateApiBaseUrl(
|
|
524
|
-
apiBaseUrl,
|
|
525
|
-
authtoken,
|
|
526
|
-
googleFitLastSync,
|
|
527
|
-
gfHourlyLastSync
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
break;
|
|
531
|
-
case 'GET_DATA_TO_GENERATE_GRAPH':
|
|
532
|
-
{
|
|
533
|
-
let type = parsedObject.type;
|
|
534
|
-
let frequency = parsedObject.frequency;
|
|
535
|
-
let timeStamp = parsedObject.timestamp;
|
|
536
|
-
|
|
537
|
-
if (isLoggingEnabled) {
|
|
538
|
-
console.log(
|
|
539
|
-
'type: ' +
|
|
540
|
-
type +
|
|
541
|
-
' frequency:' +
|
|
542
|
-
frequency +
|
|
543
|
-
' timeStamp: ' +
|
|
544
|
-
timeStamp
|
|
545
|
-
);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
requestActivityData(type, frequency, timeStamp);
|
|
549
|
-
}
|
|
550
|
-
break;
|
|
551
|
-
case 'GET_LOCATION_PERMISSIONS':
|
|
552
|
-
console.log('GET_LOCATION_PERMISSIONS');
|
|
553
|
-
requestLocationPermission();
|
|
180
|
+
|
|
554
181
|
break;
|
|
555
182
|
case 'OPEN_PDF':
|
|
556
183
|
{
|
|
@@ -562,13 +189,15 @@ const MyTatvaRnSdkView = ({
|
|
|
562
189
|
break;
|
|
563
190
|
case 'CLOSE_VIEW':
|
|
564
191
|
break;
|
|
565
|
-
|
|
192
|
+
case 'OPEN_URL_HANDLER':
|
|
193
|
+
navigation.navigate('UrlHandler', { url: parsedObject.url });
|
|
194
|
+
break;
|
|
566
195
|
default:
|
|
567
196
|
break;
|
|
568
197
|
}
|
|
569
198
|
}
|
|
570
199
|
} catch (exception) {
|
|
571
|
-
console.log('Exception
|
|
200
|
+
console.log('Exception occurred:' + exception.message);
|
|
572
201
|
}
|
|
573
202
|
}
|
|
574
203
|
};
|
|
@@ -584,131 +213,89 @@ const MyTatvaRnSdkView = ({
|
|
|
584
213
|
}, [canGoBack]);
|
|
585
214
|
|
|
586
215
|
useEffect(() => {
|
|
587
|
-
const gpsListener = addListener(({ locationEnabled }) => {
|
|
588
|
-
if (locationEnabled) {
|
|
589
|
-
checkLocationPermissionAndSendCallback();
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
|
|
593
216
|
BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
594
217
|
return () => {
|
|
595
218
|
BackHandler.removeEventListener('hardwareBackPress', handleBack);
|
|
596
|
-
gpsListener.remove();
|
|
219
|
+
// gpsListener.remove();
|
|
597
220
|
};
|
|
598
221
|
}, [handleBack]);
|
|
599
222
|
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
'isGPSPermissionAvailabe: true'
|
|
610
|
-
);
|
|
223
|
+
const getSourceUrl = () => {
|
|
224
|
+
let finalUrl = ''
|
|
225
|
+
const params = {
|
|
226
|
+
uuid,
|
|
227
|
+
mobileNumber,
|
|
228
|
+
clientSource,
|
|
229
|
+
moduleName,
|
|
230
|
+
environment,
|
|
231
|
+
...userMetaInfo
|
|
611
232
|
}
|
|
612
|
-
|
|
613
|
-
if
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
webviewRef.current?.injectJavaScript(finalString);
|
|
233
|
+
let baseUrl = environment.toUpperCase() === 'PROD' ? constants.PROD_BASE_URL : constants.STAGE_BASE_URL
|
|
234
|
+
if(baseUrl) {
|
|
235
|
+
finalUrl = baseUrl + '?data=' + encodeURIComponent(JSON.stringify(params));
|
|
236
|
+
setSource(finalUrl);
|
|
237
|
+
} else {
|
|
238
|
+
console.log("No baseUrl")
|
|
619
239
|
}
|
|
620
|
-
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
621
243
|
|
|
622
244
|
return (
|
|
623
|
-
|
|
624
|
-
<
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
245
|
+
<SafeAreaView style={{ flex: 1, backgroundColor: 'white' }}>
|
|
246
|
+
<Provider store={store}>
|
|
247
|
+
<SheetProvider>
|
|
248
|
+
{moduleName === 'progress' ? (
|
|
249
|
+
<ProgressWebView
|
|
250
|
+
token={token}
|
|
251
|
+
environment={environment}
|
|
252
|
+
source={source}
|
|
253
|
+
loading={loading}
|
|
254
|
+
isError={isError}
|
|
255
|
+
webviewRef={webviewRef}
|
|
256
|
+
runBeforeFirst={runBeforeFirst}
|
|
257
|
+
setCanGoBack={setCanGoBack}
|
|
258
|
+
mobileNumber={mobileNumber}
|
|
259
|
+
moduleName={moduleName}
|
|
260
|
+
uuid={uuid}
|
|
261
|
+
clientSource={clientSource}
|
|
262
|
+
/>
|
|
263
|
+
) : (
|
|
264
|
+
<MainWebView
|
|
265
|
+
token={token}
|
|
266
|
+
environment={environment}
|
|
267
|
+
source={source}
|
|
268
|
+
loading={loading}
|
|
269
|
+
isError={isError}
|
|
270
|
+
webviewRef={webviewRef}
|
|
271
|
+
handleMessage={handleMessage}
|
|
272
|
+
runBeforeFirst={runBeforeFirst}
|
|
273
|
+
setCanGoBack={setCanGoBack}
|
|
274
|
+
clientSource={clientSource}
|
|
275
|
+
moduleName={moduleName}
|
|
647
276
|
/>
|
|
648
|
-
)
|
|
277
|
+
)}
|
|
278
|
+
</SheetProvider>
|
|
279
|
+
</Provider>
|
|
649
280
|
</SafeAreaView>
|
|
650
281
|
);
|
|
651
282
|
};
|
|
652
283
|
|
|
653
|
-
export const fetchDailyFitnessData = (startTimeStamp, isLoggingEnabled) => {
|
|
654
|
-
return new Promise((resolve, reject) => {
|
|
655
|
-
console.log('fetchDailyFitnessData called: ' + startTimeStamp);
|
|
656
284
|
|
|
657
|
-
|
|
658
|
-
.then((result) => {
|
|
659
|
-
resolve(result);
|
|
660
|
-
})
|
|
661
|
-
.catch((err) => reject(err));
|
|
662
|
-
});
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
export const fetchHourlyFitnessData = (startTimeStamp, isLoggingEnabled) => {
|
|
666
|
-
return new Promise((resolve, reject) => {
|
|
667
|
-
if (isLoggingEnabled) {
|
|
668
|
-
console.log('fetchHourlyFitnessData called: ' + startTimeStamp);
|
|
669
|
-
}
|
|
285
|
+
export default MyTatvaRnSdkView;
|
|
670
286
|
|
|
671
|
-
NativeModules.VisitFitnessModule.fetchHourlyFitnessData(startTimeStamp)
|
|
672
|
-
.then((result) => {
|
|
673
|
-
resolve(result);
|
|
674
|
-
})
|
|
675
|
-
.catch((err) => reject(err));
|
|
676
|
-
});
|
|
677
|
-
};
|
|
678
287
|
|
|
679
|
-
// debounce, deferred
|
|
680
|
-
// function debounce(task, ms) {
|
|
681
|
-
// let t = { promise: null, cancel: (_) => void 0 };
|
|
682
|
-
// return async (...args) => {
|
|
683
|
-
// try {
|
|
684
|
-
// t.cancel();
|
|
685
|
-
// t = deferred(ms);
|
|
686
|
-
// await t.promise;
|
|
687
|
-
// await task(...args);
|
|
688
|
-
// } catch (_) {
|
|
689
|
-
// console.log('cleaning up cancelled promise');
|
|
690
|
-
// }
|
|
691
|
-
// };
|
|
692
|
-
// }
|
|
693
|
-
|
|
694
|
-
// function deferred(ms) {
|
|
695
|
-
// let cancel,
|
|
696
|
-
// promise = new Promise((resolve, reject) => {
|
|
697
|
-
// cancel = reject;
|
|
698
|
-
// setTimeout(resolve, ms);
|
|
699
|
-
// });
|
|
700
|
-
// return { promise, cancel };
|
|
701
|
-
// }
|
|
702
288
|
|
|
703
|
-
export default MyTatvaRnSdkView;
|
|
704
289
|
|
|
705
290
|
MyTatvaRnSdkView.defaultProps = {
|
|
706
|
-
|
|
291
|
+
mobileNumber: '',
|
|
292
|
+
uuid: '',
|
|
707
293
|
token: '',
|
|
708
294
|
baseUrl: '',
|
|
709
295
|
errorBaseUrl: '',
|
|
710
|
-
moduleName: '',
|
|
711
296
|
environment: '',
|
|
712
|
-
|
|
713
|
-
|
|
297
|
+
metaInfo: {},
|
|
298
|
+
clientSource: '',
|
|
299
|
+
moduleName: '',
|
|
300
|
+
navigation: {}
|
|
714
301
|
};
|