react-native-visit-rn-sdk 7.0.0 → 7.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/README.md +35 -20
- package/lib/commonjs/index.android.js +31 -153
- package/lib/commonjs/index.android.js.map +1 -1
- package/lib/commonjs/index.ios.js +8 -117
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/module/index.android.js +30 -152
- package/lib/module/index.android.js.map +1 -1
- package/lib/module/index.ios.js +9 -117
- package/lib/module/index.ios.js.map +1 -1
- package/lib/typescript/index.android.d.ts +4 -22
- package/lib/typescript/index.android.d.ts.map +1 -1
- package/lib/typescript/index.ios.d.ts +4 -18
- package/lib/typescript/index.ios.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/index.android.js +40 -234
- package/src/index.ios.js +6 -151
- package/lib/commonjs/Services.js +0 -35
- package/lib/commonjs/Services.js.map +0 -1
- package/lib/commonjs/constants.js +0 -11
- package/lib/commonjs/constants.js.map +0 -1
- package/lib/module/Services.js +0 -27
- package/lib/module/Services.js.map +0 -1
- package/lib/module/constants.js +0 -5
- package/lib/module/constants.js.map +0 -1
- package/lib/typescript/Services.d.ts +0 -3
- package/lib/typescript/Services.d.ts.map +0 -1
- package/lib/typescript/constants.d.ts +0 -6
- package/lib/typescript/constants.d.ts.map +0 -1
- package/src/Services.js +0 -37
- package/src/constants.js +0 -4
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
export const httpClient: any;
|
|
2
1
|
export function fetchDailyFitnessData(startTimeStamp: any, isLoggingEnabled: any): Promise<any>;
|
|
3
2
|
export function fetchHourlyFitnessData(startTimeStamp: any, isLoggingEnabled: any): Promise<any>;
|
|
4
3
|
export default VisitRnSdkView;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
token: any;
|
|
10
|
-
moduleName: any;
|
|
11
|
-
environment: any;
|
|
12
|
-
magicLink: any;
|
|
13
|
-
isLoggingEnabled: any;
|
|
4
|
+
/** @param {{ ssoURL: string, isLoggingEnabled?: boolean }} props */
|
|
5
|
+
declare function VisitRnSdkView({ ssoURL, isLoggingEnabled }: {
|
|
6
|
+
ssoURL: string;
|
|
7
|
+
isLoggingEnabled?: boolean;
|
|
14
8
|
}): React.JSX.Element;
|
|
15
|
-
declare namespace VisitRnSdkView {
|
|
16
|
-
namespace defaultProps {
|
|
17
|
-
let cpsid: string;
|
|
18
|
-
let token: string;
|
|
19
|
-
let baseUrl: string;
|
|
20
|
-
let errorBaseUrl: string;
|
|
21
|
-
let moduleName: string;
|
|
22
|
-
let environment: string;
|
|
23
|
-
let magicLink: string;
|
|
24
|
-
let isLoggingEnabled: boolean;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
9
|
import React from 'react';
|
|
28
10
|
//# sourceMappingURL=index.android.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.android.d.ts","sourceRoot":"","sources":["../../src/index.android.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.android.d.ts","sourceRoot":"","sources":["../../src/index.android.js"],"names":[],"mappings":"AAghBO,gGAUN;AAEM,iGAYN;;AA9gBD,oEAAoE;AACpE,8DADY;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,qBAofzD;kBA9gB+D,OAAO"}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
export default VisitRnSdkView;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
token: any;
|
|
7
|
-
moduleName: any;
|
|
8
|
-
environment: any;
|
|
9
|
-
magicLink: any;
|
|
10
|
-
isLoggingEnabled: any;
|
|
2
|
+
/** @param {{ ssoURL: string, isLoggingEnabled?: boolean }} props */
|
|
3
|
+
declare function VisitRnSdkView({ ssoURL, isLoggingEnabled }: {
|
|
4
|
+
ssoURL: string;
|
|
5
|
+
isLoggingEnabled?: boolean;
|
|
11
6
|
}): React.JSX.Element;
|
|
12
|
-
declare namespace VisitRnSdkView {
|
|
13
|
-
namespace defaultProps {
|
|
14
|
-
let id: string;
|
|
15
|
-
let token: string;
|
|
16
|
-
let baseUrl: string;
|
|
17
|
-
let errorBaseUrl: string;
|
|
18
|
-
let moduleName: string;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
7
|
import React from 'react';
|
|
22
8
|
//# sourceMappingURL=index.ios.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.ios.d.ts","sourceRoot":"","sources":["../../src/index.ios.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.ios.d.ts","sourceRoot":"","sources":["../../src/index.ios.js"],"names":[],"mappings":";AAqDA,oEAAoE;AACpE,8DADY;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,qBA0NzD;kBAzQM,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-visit-rn-sdk",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "a package to inject data into visit health pwa",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -93,6 +93,9 @@
|
|
|
93
93
|
"packageManager": "^yarn@1.22.15",
|
|
94
94
|
"jest": {
|
|
95
95
|
"preset": "react-native",
|
|
96
|
+
"roots": [
|
|
97
|
+
"<rootDir>/src"
|
|
98
|
+
],
|
|
96
99
|
"modulePathIgnorePatterns": [
|
|
97
100
|
"<rootDir>/example/node_modules",
|
|
98
101
|
"<rootDir>/lib/"
|
|
@@ -165,7 +168,6 @@
|
|
|
165
168
|
]
|
|
166
169
|
},
|
|
167
170
|
"dependencies": {
|
|
168
|
-
"axios": "^1.8.2",
|
|
169
171
|
"moment": "^2.29.4"
|
|
170
172
|
},
|
|
171
173
|
"directories": {
|
package/src/index.android.js
CHANGED
|
@@ -16,16 +16,6 @@ import WebView from 'react-native-webview';
|
|
|
16
16
|
|
|
17
17
|
import LocationEnabler from 'react-native-location-enabler';
|
|
18
18
|
|
|
19
|
-
import DeviceInfo from 'react-native-device-info';
|
|
20
|
-
|
|
21
|
-
import axios from 'axios';
|
|
22
|
-
|
|
23
|
-
import constants from './constants';
|
|
24
|
-
|
|
25
|
-
export const httpClient = axios.create({
|
|
26
|
-
timeout: 60000,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
19
|
const messageEmitter = new NativeEventEmitter(NativeModules.VisitFitnessModule);
|
|
30
20
|
|
|
31
21
|
const {
|
|
@@ -34,17 +24,9 @@ const {
|
|
|
34
24
|
addListener,
|
|
35
25
|
} = LocationEnabler;
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
errorBaseUrl,
|
|
41
|
-
token,
|
|
42
|
-
moduleName,
|
|
43
|
-
environment,
|
|
44
|
-
magicLink,
|
|
45
|
-
isLoggingEnabled,
|
|
46
|
-
}) => {
|
|
47
|
-
const [source, setSource] = useState('');
|
|
27
|
+
/** @param {{ ssoURL: string, isLoggingEnabled?: boolean }} props */
|
|
28
|
+
const VisitRnSdkView = ({ ssoURL, isLoggingEnabled = false }) => {
|
|
29
|
+
const source = ssoURL?.trim();
|
|
48
30
|
const [appState, setAppState] = useState(AppState.currentState);
|
|
49
31
|
|
|
50
32
|
const [
|
|
@@ -58,161 +40,7 @@ const VisitRnSdkView = ({
|
|
|
58
40
|
}
|
|
59
41
|
|
|
60
42
|
NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
|
|
61
|
-
|
|
62
|
-
if ((magicLink?.trim()?.length || 0) > 0) {
|
|
63
|
-
setSource(magicLink);
|
|
64
|
-
} else {
|
|
65
|
-
DeviceInfo.getAndroidId()
|
|
66
|
-
.then((deviceId) => {
|
|
67
|
-
var buildNumber = DeviceInfo.getBuildNumber();
|
|
68
|
-
let systemVersion = DeviceInfo.getSystemVersion();
|
|
69
|
-
let version = DeviceInfo.getVersion();
|
|
70
|
-
|
|
71
|
-
if (isLoggingEnabled) {
|
|
72
|
-
console.log(
|
|
73
|
-
' baseUrl : ' +
|
|
74
|
-
baseUrl +
|
|
75
|
-
'token: ' +
|
|
76
|
-
token +
|
|
77
|
-
' cpsid: ' +
|
|
78
|
-
cpsid +
|
|
79
|
-
' environment: ' +
|
|
80
|
-
environment +
|
|
81
|
-
'buildNumber:' +
|
|
82
|
-
buildNumber +
|
|
83
|
-
' systemVersion:' +
|
|
84
|
-
systemVersion +
|
|
85
|
-
' version : ' +
|
|
86
|
-
version +
|
|
87
|
-
' deviceId',
|
|
88
|
-
deviceId
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
var finalEndPoint = `${baseUrl}/partners/v3/generate-magic-link-star-health`;
|
|
93
|
-
|
|
94
|
-
if (isLoggingEnabled) {
|
|
95
|
-
console.log('finalEndPoint: ' + finalEndPoint);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
httpClient
|
|
99
|
-
.post(finalEndPoint, {
|
|
100
|
-
cpsid: cpsid,
|
|
101
|
-
token: token,
|
|
102
|
-
srcClientId: 'Android',
|
|
103
|
-
deviceId: deviceId,
|
|
104
|
-
appVersion: version,
|
|
105
|
-
deviceVersion: systemVersion,
|
|
106
|
-
userEnv: environment,
|
|
107
|
-
})
|
|
108
|
-
.then((response) => {
|
|
109
|
-
let data = response.data;
|
|
110
|
-
// let visitMagicLink = data.result; //@Deprecated. Superseded by magic code usage.
|
|
111
|
-
const errorMessage = data.errorMessage;
|
|
112
|
-
const magicCode = data.magicCode;
|
|
113
|
-
const responseReferenceId = data.responseReferenceId;
|
|
114
|
-
const otherValues = data.otherValues;
|
|
115
|
-
|
|
116
|
-
let finalBaseUrl = '';
|
|
117
|
-
|
|
118
|
-
if (environment.toUpperCase() === 'PROD') {
|
|
119
|
-
finalBaseUrl = constants.PROD_BASE_URL;
|
|
120
|
-
} else {
|
|
121
|
-
finalBaseUrl = constants.STAGE_BASE_URL;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
let finalUrl = `${finalBaseUrl}=${magicCode}`;
|
|
125
|
-
|
|
126
|
-
if (data.message === 'success') {
|
|
127
|
-
if ((moduleName?.trim()?.length || 0) > 0) {
|
|
128
|
-
finalUrl += `&tab=${moduleName}`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
typeof responseReferenceId === 'string' &&
|
|
133
|
-
responseReferenceId.trim().length > 0
|
|
134
|
-
) {
|
|
135
|
-
finalUrl += `&responseReferenceId=${responseReferenceId}`;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
typeof otherValues === 'string' &&
|
|
140
|
-
otherValues.trim().length > 0
|
|
141
|
-
) {
|
|
142
|
-
finalUrl += `&otherValues=${otherValues}`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (isLoggingEnabled) {
|
|
146
|
-
console.log('magicLink: ' + finalUrl);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
setSource(finalUrl);
|
|
150
|
-
} else {
|
|
151
|
-
var errorUrl = `${errorBaseUrl}/star-health?error=${errorMessage}`;
|
|
152
|
-
setSource(errorUrl);
|
|
153
|
-
|
|
154
|
-
if (errorMessage != null) {
|
|
155
|
-
if (errorMessage === 'Please login again') {
|
|
156
|
-
EventRegister.emitEvent('visit-event', {
|
|
157
|
-
message: 'unauthorized-wellness-access',
|
|
158
|
-
errorMessage: errorMessage,
|
|
159
|
-
});
|
|
160
|
-
} else if (errorMessage.includes('External Server Error')) {
|
|
161
|
-
EventRegister.emitEvent('visit-event', {
|
|
162
|
-
message: 'external-server-error',
|
|
163
|
-
errorMessage: errorMessage,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (isLoggingEnabled) {
|
|
169
|
-
console.log(
|
|
170
|
-
'erorMessage: ' +
|
|
171
|
-
data.errorMessage +
|
|
172
|
-
' errorUrl: ' +
|
|
173
|
-
errorUrl
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
})
|
|
178
|
-
.catch((error) => {
|
|
179
|
-
var errorUrl = `${errorBaseUrl}/star-health?error=${error}`;
|
|
180
|
-
setSource(errorUrl);
|
|
181
|
-
|
|
182
|
-
EventRegister.emitEvent('visit-event', {
|
|
183
|
-
message: 'generate-magic-link-failed',
|
|
184
|
-
errorMessage: `${error}`,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
if (isLoggingEnabled) {
|
|
188
|
-
console.log('error: ' + error);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
})
|
|
192
|
-
.catch((err) => {
|
|
193
|
-
var errorUrl = `${errorBaseUrl}/star-health?error=${err}`;
|
|
194
|
-
setSource(errorUrl);
|
|
195
|
-
|
|
196
|
-
EventRegister.emitEvent('visit-event', {
|
|
197
|
-
message: 'getDeviceInfo-failed',
|
|
198
|
-
errorMessage: `${err}`,
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
if (isLoggingEnabled) {
|
|
202
|
-
console.log('getDeviceInfo err', err);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}, [
|
|
207
|
-
cpsid,
|
|
208
|
-
token,
|
|
209
|
-
baseUrl,
|
|
210
|
-
errorBaseUrl,
|
|
211
|
-
moduleName,
|
|
212
|
-
environment,
|
|
213
|
-
magicLink,
|
|
214
|
-
isLoggingEnabled,
|
|
215
|
-
]);
|
|
43
|
+
}, [isLoggingEnabled]);
|
|
216
44
|
|
|
217
45
|
useEffect(() => {
|
|
218
46
|
const subscription = messageEmitter.addListener('onMessage', (message) => {
|
|
@@ -239,35 +67,24 @@ const VisitRnSdkView = ({
|
|
|
239
67
|
}, []);
|
|
240
68
|
|
|
241
69
|
useEffect(() => {
|
|
242
|
-
const subscription = AppState.addEventListener(
|
|
243
|
-
'
|
|
244
|
-
|
|
245
|
-
|
|
70
|
+
const subscription = AppState.addEventListener('change', (nextAppState) => {
|
|
71
|
+
if (appState?.match(/inactive|background/) && nextAppState === 'active') {
|
|
72
|
+
if (isLoggingEnabled) {
|
|
73
|
+
console.log('App has come to the foreground!');
|
|
74
|
+
}
|
|
75
|
+
console.log(
|
|
76
|
+
'getHealthConnectStatus commented out, because it it not required for MCHI since we rely on callback from the web to get the health connect status.'
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setAppState(nextAppState);
|
|
81
|
+
});
|
|
246
82
|
console.log(`AppState.addEventListener added, current state: ${appState}`);
|
|
247
83
|
|
|
248
84
|
return () => {
|
|
249
85
|
subscription.remove();
|
|
250
86
|
};
|
|
251
|
-
}, [appState]);
|
|
252
|
-
|
|
253
|
-
const handleAppStateChange = (nextAppState) => {
|
|
254
|
-
// console.log(
|
|
255
|
-
// "nextAppState: " + nextAppState + ", previousState: " + appState
|
|
256
|
-
// );
|
|
257
|
-
|
|
258
|
-
// Instead of relying on the old appState, use the nextAppState directly
|
|
259
|
-
if (appState.match(/inactive|background/) && nextAppState === 'active') {
|
|
260
|
-
if (isLoggingEnabled) {
|
|
261
|
-
console.log('App has come to the foreground!');
|
|
262
|
-
}
|
|
263
|
-
console.log(
|
|
264
|
-
'getHealthConnectStatus commented out, because it it not required for MCHI since we rely on callback from the web to get the health connect status.'
|
|
265
|
-
);
|
|
266
|
-
// getHealthConnectStatus();
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
setAppState(nextAppState); // Update the state with the new app state
|
|
270
|
-
};
|
|
87
|
+
}, [appState, isLoggingEnabled]);
|
|
271
88
|
|
|
272
89
|
const [enabled, requestResolution] = useLocationSettings(
|
|
273
90
|
{
|
|
@@ -636,6 +453,28 @@ const VisitRnSdkView = ({
|
|
|
636
453
|
}, [canGoBack]);
|
|
637
454
|
|
|
638
455
|
useEffect(() => {
|
|
456
|
+
const checkLocationPermissionAndSendCallback = async () => {
|
|
457
|
+
const isLocationPermissionAvailable = await PermissionsAndroid.check(
|
|
458
|
+
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
if (isLoggingEnabled) {
|
|
462
|
+
console.log(
|
|
463
|
+
'checkLocationPermissionAndSendCallback() isLocationPermissionAvailable: ' +
|
|
464
|
+
isLocationPermissionAvailable +
|
|
465
|
+
'isGPSPermissionAvailabe: true'
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (isLocationPermissionAvailable) {
|
|
470
|
+
var finalString = `window.checkTheGpsPermission(true)`;
|
|
471
|
+
|
|
472
|
+
console.log('listener: ' + finalString);
|
|
473
|
+
|
|
474
|
+
webviewRef.current?.injectJavaScript(finalString);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
|
|
639
478
|
// Subscribe to GPS/location setting changes
|
|
640
479
|
const locationSub = addListener(({ locationEnabled }) => {
|
|
641
480
|
if (locationEnabled) {
|
|
@@ -654,29 +493,7 @@ const VisitRnSdkView = ({
|
|
|
654
493
|
backSub?.remove();
|
|
655
494
|
locationSub?.remove();
|
|
656
495
|
};
|
|
657
|
-
}, [handleBack]);
|
|
658
|
-
|
|
659
|
-
const checkLocationPermissionAndSendCallback = async () => {
|
|
660
|
-
const isLocationPermissionAvailable = await PermissionsAndroid.check(
|
|
661
|
-
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
|
|
662
|
-
);
|
|
663
|
-
|
|
664
|
-
if (isLoggingEnabled) {
|
|
665
|
-
console.log(
|
|
666
|
-
'checkLocationPermissionAndSendCallback() isLocationPermissionAvailable: ' +
|
|
667
|
-
isLocationPermissionAvailable +
|
|
668
|
-
'isGPSPermissionAvailabe: true'
|
|
669
|
-
);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
if (isLocationPermissionAvailable) {
|
|
673
|
-
var finalString = `window.checkTheGpsPermission(true)`;
|
|
674
|
-
|
|
675
|
-
console.log('listener: ' + finalString);
|
|
676
|
-
|
|
677
|
-
webviewRef.current?.injectJavaScript(finalString);
|
|
678
|
-
}
|
|
679
|
-
};
|
|
496
|
+
}, [handleBack, isLoggingEnabled]);
|
|
680
497
|
|
|
681
498
|
return (
|
|
682
499
|
// eslint-disable-next-line react-native/no-inline-styles
|
|
@@ -760,14 +577,3 @@ export const fetchHourlyFitnessData = (startTimeStamp, isLoggingEnabled) => {
|
|
|
760
577
|
// }
|
|
761
578
|
|
|
762
579
|
export default VisitRnSdkView;
|
|
763
|
-
|
|
764
|
-
VisitRnSdkView.defaultProps = {
|
|
765
|
-
cpsid: '',
|
|
766
|
-
token: '',
|
|
767
|
-
baseUrl: '',
|
|
768
|
-
errorBaseUrl: '',
|
|
769
|
-
moduleName: '',
|
|
770
|
-
environment: '',
|
|
771
|
-
magicLink: '',
|
|
772
|
-
isLoggingEnabled: false,
|
|
773
|
-
};
|
package/src/index.ios.js
CHANGED
|
@@ -11,16 +11,12 @@ import {
|
|
|
11
11
|
NativeModules,
|
|
12
12
|
Linking,
|
|
13
13
|
Platform,
|
|
14
|
-
ActivityIndicator,
|
|
15
14
|
Dimensions,
|
|
16
15
|
Alert,
|
|
17
16
|
AppState,
|
|
18
17
|
} from 'react-native';
|
|
19
18
|
import { EventRegister } from 'react-native-event-listeners';
|
|
20
19
|
import { WebView } from 'react-native-webview';
|
|
21
|
-
import DeviceInfo from 'react-native-device-info';
|
|
22
|
-
import { getWebViewLink } from './Services';
|
|
23
|
-
import constants from './constants';
|
|
24
20
|
|
|
25
21
|
const LINKING_ERROR =
|
|
26
22
|
`The package 'react-native-visit-rn-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -55,119 +51,9 @@ const unescapeHTML = (str) =>
|
|
|
55
51
|
|
|
56
52
|
const visitEvent = 'visit-event';
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
errorBaseUrl,
|
|
62
|
-
token,
|
|
63
|
-
moduleName,
|
|
64
|
-
environment,
|
|
65
|
-
magicLink,
|
|
66
|
-
isLoggingEnabled,
|
|
67
|
-
}) => {
|
|
68
|
-
const [source, setSource] = useState('');
|
|
69
|
-
const [loading, setLoading] = useState(true);
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (magicLink?.trim()?.length) {
|
|
72
|
-
setSource(magicLink);
|
|
73
|
-
setLoading(false);
|
|
74
|
-
} else {
|
|
75
|
-
const systemVersion = DeviceInfo.getSystemVersion();
|
|
76
|
-
const version = DeviceInfo.getVersion();
|
|
77
|
-
DeviceInfo.getUniqueId()
|
|
78
|
-
.then((uniqueId) =>
|
|
79
|
-
getWebViewLink(
|
|
80
|
-
baseUrl,
|
|
81
|
-
token,
|
|
82
|
-
cpsid,
|
|
83
|
-
'iPhone',
|
|
84
|
-
uniqueId,
|
|
85
|
-
version,
|
|
86
|
-
systemVersion,
|
|
87
|
-
environment
|
|
88
|
-
)
|
|
89
|
-
)
|
|
90
|
-
.then((res) => {
|
|
91
|
-
if (res.data?.errorMessage) {
|
|
92
|
-
const { errorMessage } = res.data;
|
|
93
|
-
const errorUrl = `${errorBaseUrl}/star-health?error=${errorMessage}`;
|
|
94
|
-
setSource(errorUrl);
|
|
95
|
-
if (res.data?.errorMessage === 'Please login again') {
|
|
96
|
-
EventRegister.emitEvent(visitEvent, {
|
|
97
|
-
message: 'unauthorized-wellness-access',
|
|
98
|
-
errorMessage: errorMessage,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
if (res.data?.errorMessage.includes('External Server Error')) {
|
|
102
|
-
EventRegister.emitEvent('visit-event', {
|
|
103
|
-
message: 'external-server-error',
|
|
104
|
-
errorMessage: errorMessage,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
} else if (res.data.message === 'success') {
|
|
108
|
-
const magicCode = res.data?.magicCode;
|
|
109
|
-
const responseReferenceId = res.data?.responseReferenceId;
|
|
110
|
-
const otherValues = res.data?.otherValues;
|
|
111
|
-
|
|
112
|
-
let finalBaseUrl = '';
|
|
113
|
-
if (magicCode) {
|
|
114
|
-
if (environment.toUpperCase() === 'PROD') {
|
|
115
|
-
finalBaseUrl = constants.PROD_BASE_URL;
|
|
116
|
-
} else {
|
|
117
|
-
finalBaseUrl = constants.STAGE_BASE_URL;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (finalBaseUrl && magicCode) {
|
|
121
|
-
let finalUrl = `${finalBaseUrl}=${magicCode}`;
|
|
122
|
-
if (moduleName?.trim()) {
|
|
123
|
-
finalUrl += `&tab=${moduleName}`;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
typeof responseReferenceId === 'string' &&
|
|
128
|
-
responseReferenceId.trim().length > 0
|
|
129
|
-
) {
|
|
130
|
-
finalUrl += `&responseReferenceId=${responseReferenceId}`;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
typeof otherValues === 'string' &&
|
|
135
|
-
otherValues.trim().length > 0
|
|
136
|
-
) {
|
|
137
|
-
finalUrl += `&otherValues=${otherValues}`;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
setSource(finalUrl);
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
EventRegister.emitEvent('visit-event', {
|
|
144
|
-
message: 'generate-magic-link-failed',
|
|
145
|
-
errorMessage: `${res.data}`,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
.catch((err) => {
|
|
150
|
-
console.log('getWebViewLink err', { err });
|
|
151
|
-
EventRegister.emitEvent('visit-event', {
|
|
152
|
-
message: 'generate-magic-link-failed',
|
|
153
|
-
errorMessage: `${err}`,
|
|
154
|
-
});
|
|
155
|
-
})
|
|
156
|
-
.finally(() => {
|
|
157
|
-
setLoading(false);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}, [
|
|
161
|
-
cpsid,
|
|
162
|
-
token,
|
|
163
|
-
baseUrl,
|
|
164
|
-
errorBaseUrl,
|
|
165
|
-
moduleName,
|
|
166
|
-
environment,
|
|
167
|
-
magicLink,
|
|
168
|
-
isLoggingEnabled,
|
|
169
|
-
]);
|
|
170
|
-
|
|
54
|
+
/** @param {{ ssoURL: string, isLoggingEnabled?: boolean }} props */
|
|
55
|
+
const VisitRnSdkView = ({ ssoURL, isLoggingEnabled = false }) => {
|
|
56
|
+
const source = ssoURL?.trim();
|
|
171
57
|
const VisitRnSdkViewManager = useMemo(
|
|
172
58
|
() =>
|
|
173
59
|
NativeModules.VisitRnSdkViewManager
|
|
@@ -258,7 +144,7 @@ const VisitRnSdkView = ({
|
|
|
258
144
|
webviewRef.current?.injectJavaScript('window.setSdkPlatform("IOS")');
|
|
259
145
|
break;
|
|
260
146
|
case 'CONNECT_TO_GOOGLE_FIT':
|
|
261
|
-
if (
|
|
147
|
+
if (Platform.isPad) {
|
|
262
148
|
console.log('unsupportedHealthKitDevice triggered');
|
|
263
149
|
webviewRef.current?.injectJavaScript(
|
|
264
150
|
'window.unsupportedHealthKitDevice(true)'
|
|
@@ -363,9 +249,7 @@ const VisitRnSdkView = ({
|
|
|
363
249
|
return (
|
|
364
250
|
// eslint-disable-next-line react-native/no-inline-styles
|
|
365
251
|
<SafeAreaView style={{ flex: 1, backgroundColor: 'white', height, width }}>
|
|
366
|
-
{
|
|
367
|
-
<LoadingIndicator />
|
|
368
|
-
) : (
|
|
252
|
+
{source ? (
|
|
369
253
|
<WebView
|
|
370
254
|
ref={webviewRef}
|
|
371
255
|
source={{ uri: source }}
|
|
@@ -382,7 +266,7 @@ const VisitRnSdkView = ({
|
|
|
382
266
|
}
|
|
383
267
|
}}
|
|
384
268
|
/>
|
|
385
|
-
)}
|
|
269
|
+
) : null}
|
|
386
270
|
</SafeAreaView>
|
|
387
271
|
);
|
|
388
272
|
};
|
|
@@ -397,33 +281,4 @@ const styles = StyleSheet.create({
|
|
|
397
281
|
},
|
|
398
282
|
});
|
|
399
283
|
|
|
400
|
-
VisitRnSdkView.defaultProps = {
|
|
401
|
-
id: '',
|
|
402
|
-
token: '',
|
|
403
|
-
baseUrl: '',
|
|
404
|
-
errorBaseUrl: '',
|
|
405
|
-
moduleName: '',
|
|
406
|
-
};
|
|
407
|
-
|
|
408
284
|
export default VisitRnSdkView;
|
|
409
|
-
|
|
410
|
-
const LoadingIndicator = () => {
|
|
411
|
-
return (
|
|
412
|
-
<ActivityIndicator
|
|
413
|
-
color="#000"
|
|
414
|
-
size="small"
|
|
415
|
-
// eslint-disable-next-line react-native/no-inline-styles
|
|
416
|
-
style={{
|
|
417
|
-
flex: 1,
|
|
418
|
-
zIndex: 100,
|
|
419
|
-
position: 'absolute',
|
|
420
|
-
backgroundColor: '#fff',
|
|
421
|
-
opacity: 0.4,
|
|
422
|
-
width: '100%',
|
|
423
|
-
height: '100%',
|
|
424
|
-
justifyContent: 'center',
|
|
425
|
-
alignItems: 'center',
|
|
426
|
-
}}
|
|
427
|
-
/>
|
|
428
|
-
);
|
|
429
|
-
};
|
package/lib/commonjs/Services.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.httpClient = exports.getWebViewLink = void 0;
|
|
7
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const httpClient = exports.httpClient = _axios.default.create({
|
|
10
|
-
timeout: 60000
|
|
11
|
-
});
|
|
12
|
-
const getWebViewLink = (baseUrl, token, cpsid, srcClientId, deviceId, appVersion, deviceVersion, userEnv) => {
|
|
13
|
-
const data = {
|
|
14
|
-
cpsid,
|
|
15
|
-
token,
|
|
16
|
-
srcClientId,
|
|
17
|
-
deviceId,
|
|
18
|
-
appVersion,
|
|
19
|
-
deviceVersion,
|
|
20
|
-
userEnv
|
|
21
|
-
};
|
|
22
|
-
return httpClient.post(`${baseUrl}/partners/v3/generate-magic-link-star-health`, data).then(res => {
|
|
23
|
-
console.log('getWebViewLink res', {
|
|
24
|
-
res
|
|
25
|
-
});
|
|
26
|
-
return res;
|
|
27
|
-
}).catch(err => {
|
|
28
|
-
console.log('getWebViewLink err', {
|
|
29
|
-
err
|
|
30
|
-
});
|
|
31
|
-
return err;
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
exports.getWebViewLink = getWebViewLink;
|
|
35
|
-
//# sourceMappingURL=Services.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_axios","_interopRequireDefault","require","e","__esModule","default","httpClient","exports","axios","create","timeout","getWebViewLink","baseUrl","token","cpsid","srcClientId","deviceId","appVersion","deviceVersion","userEnv","data","post","then","res","console","log","catch","err"],"sourceRoot":"../../src","sources":["Services.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnB,MAAMG,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAGE,cAAK,CAACC,MAAM,CAAC;EACrCC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,MAAMC,cAAc,GAAGA,CAC5BC,OAAO,EACPC,KAAK,EACLC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRC,UAAU,EACVC,aAAa,EACbC,OAAO,KACJ;EACH,MAAMC,IAAI,GAAG;IACXN,KAAK;IACLD,KAAK;IACLE,WAAW;IACXC,QAAQ;IACRC,UAAU;IACVC,aAAa;IACbC;EACF,CAAC;EAED,OAAOb,UAAU,CACde,IAAI,CAAC,GAAGT,OAAO,8CAA8C,EAAEQ,IAAI,CAAC,CACpEE,IAAI,CAAEC,GAAG,IAAK;IACbC,OAAO,CAACC,GAAG,CAAC,oBAAoB,EAAE;MAAEF;IAAI,CAAC,CAAC;IAC1C,OAAOA,GAAG;EACZ,CAAC,CAAC,CACDG,KAAK,CAAEC,GAAG,IAAK;IACdH,OAAO,CAACC,GAAG,CAAC,oBAAoB,EAAE;MAAEE;IAAI,CAAC,CAAC;IAC1C,OAAOA,GAAG;EACZ,CAAC,CAAC;AACN,CAAC;AAACpB,OAAA,CAAAI,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = exports.default = {
|
|
8
|
-
STAGE_BASE_URL: 'https://star-health.getvisitapp.net/?mluib7c',
|
|
9
|
-
PROD_BASE_URL: 'https://star-health.getvisitapp.com/?mluib7c'
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["STAGE_BASE_URL","PROD_BASE_URL"],"sourceRoot":"../../src","sources":["constants.js"],"mappings":";;;;;;iCAAe;EACbA,cAAc,EAAE,8CAA8C;EAC9DC,aAAa,EAAE;AACjB,CAAC","ignoreList":[]}
|