react-native-visit-rn-sdk 6.0.3 → 7.0.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 +288 -122
- package/android/build.gradle +4 -1
- package/android/gradle.properties +4 -4
- package/android/src/main/AndroidManifest.xml +11 -5
- package/android/src/main/AndroidManifestNew.xml +11 -5
- package/android/src/main/java/com/visitrnsdk/VisitFitnessModule.kt +642 -0
- package/android/src/main/java/com/visitrnsdk/VisitRnSdkPackage.kt +1 -1
- package/android/src/main/java/com/visitrnsdk/VisitSessionStorage.kt +50 -0
- package/ios/VisitRnSdkViewManager.h +23 -1
- package/ios/VisitRnSdkViewManager.m +1259 -8
- package/lib/commonjs/Services.js +35 -0
- package/lib/commonjs/Services.js.map +1 -0
- package/lib/commonjs/constants.js +11 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/index.android.js +450 -205
- package/lib/commonjs/index.android.js.map +1 -1
- package/lib/commonjs/index.ios.js +266 -114
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/module/Services.js +27 -0
- package/lib/module/Services.js.map +1 -0
- package/lib/module/constants.js +5 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/index.android.js +450 -206
- package/lib/module/index.android.js.map +1 -1
- package/lib/module/index.ios.js +268 -116
- package/lib/module/index.ios.js.map +1 -1
- package/lib/typescript/Services.d.ts +3 -0
- package/lib/typescript/Services.d.ts.map +1 -0
- package/lib/typescript/constants.d.ts +6 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/index.android.d.ts +26 -3
- package/lib/typescript/index.android.d.ts.map +1 -1
- package/lib/typescript/index.ios.d.ts +20 -3
- package/lib/typescript/index.ios.d.ts.map +1 -1
- package/package.json +14 -25
- package/react-native-visit-rn-sdk.podspec +2 -1
- package/src/Services.js +37 -0
- package/src/constants.js +4 -0
- package/src/index.android.js +773 -0
- package/src/index.ios.js +429 -0
- package/android/src/main/java/com/visitrnsdk/VisitRnSdkLocationModule.kt +0 -37
- 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 +0 -1088
- package/lib/commonjs/components/VideoCallComponent.js.map +0 -1
- package/lib/commonjs/index.js +0 -6
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/shims.d.js +0 -2
- package/lib/commonjs/shims.d.js.map +0 -1
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -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 +0 -1081
- package/lib/module/components/VideoCallComponent.js.map +0 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +0 -1
- package/lib/module/shims.d.js +0 -2
- package/lib/module/shims.d.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/components/VideoCallComponent.d.ts +0 -79
- package/lib/typescript/components/VideoCallComponent.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -17
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -24
- package/lib/typescript/types.d.ts.map +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.tsx +0 -1484
- package/src/index.android.tsx +0 -459
- package/src/index.ios.tsx +0 -238
- package/src/index.tsx +0 -25
- package/src/shims.d.ts +0 -49
- package/src/types.ts +0 -25
package/src/index.ios.js
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useRef,
|
|
3
|
+
useEffect,
|
|
4
|
+
useState,
|
|
5
|
+
useMemo,
|
|
6
|
+
useCallback,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import {
|
|
9
|
+
StyleSheet,
|
|
10
|
+
SafeAreaView,
|
|
11
|
+
NativeModules,
|
|
12
|
+
Linking,
|
|
13
|
+
Platform,
|
|
14
|
+
ActivityIndicator,
|
|
15
|
+
Dimensions,
|
|
16
|
+
Alert,
|
|
17
|
+
AppState,
|
|
18
|
+
} from 'react-native';
|
|
19
|
+
import { EventRegister } from 'react-native-event-listeners';
|
|
20
|
+
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
|
+
|
|
25
|
+
const LINKING_ERROR =
|
|
26
|
+
`The package 'react-native-visit-rn-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
27
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
28
|
+
'- You rebuilt the app after installing the package\n' +
|
|
29
|
+
'- You are not using Expo Go\n';
|
|
30
|
+
|
|
31
|
+
const escapeChars = {
|
|
32
|
+
lt: '<',
|
|
33
|
+
gt: '>',
|
|
34
|
+
quot: '"',
|
|
35
|
+
apos: "'",
|
|
36
|
+
amp: '&',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const unescapeHTML = (str) =>
|
|
40
|
+
// modified from underscore.string and string.js
|
|
41
|
+
// eslint-disable-next-line no-useless-escape
|
|
42
|
+
str.replace(/\&([^;]+);/g, (entity, entityCode) => {
|
|
43
|
+
let match;
|
|
44
|
+
|
|
45
|
+
if (entityCode in escapeChars) {
|
|
46
|
+
return escapeChars[entityCode];
|
|
47
|
+
} else if ((match = entityCode.match(/^#x([\da-fA-F]+)$/))) {
|
|
48
|
+
return String.fromCharCode(parseInt(match[1], 16));
|
|
49
|
+
} else if ((match = entityCode.match(/^#(\d+)$/))) {
|
|
50
|
+
return String.fromCharCode(match[1]);
|
|
51
|
+
} else {
|
|
52
|
+
return entity;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const visitEvent = 'visit-event';
|
|
57
|
+
|
|
58
|
+
const VisitRnSdkView = ({
|
|
59
|
+
cpsid,
|
|
60
|
+
baseUrl,
|
|
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
|
+
|
|
171
|
+
const VisitRnSdkViewManager = useMemo(
|
|
172
|
+
() =>
|
|
173
|
+
NativeModules.VisitRnSdkViewManager
|
|
174
|
+
? NativeModules.VisitRnSdkViewManager
|
|
175
|
+
: new Proxy(
|
|
176
|
+
{},
|
|
177
|
+
{
|
|
178
|
+
get() {
|
|
179
|
+
throw new Error(LINKING_ERROR);
|
|
180
|
+
},
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
[]
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const webviewRef = useRef(null);
|
|
187
|
+
const [hasLoadedOnce, setHasLoadedOnce] = useState(false);
|
|
188
|
+
|
|
189
|
+
const refreshHealthKitPermissionState = useCallback(async () => {
|
|
190
|
+
try {
|
|
191
|
+
const status = await VisitRnSdkViewManager?.getHealthKitConnectStatus?.();
|
|
192
|
+
|
|
193
|
+
if (isLoggingEnabled) {
|
|
194
|
+
console.log('getHealthKitConnectStatus on foreground: ', status);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (status === 'NOT_SUPPORTED') {
|
|
198
|
+
webviewRef.current?.injectJavaScript(
|
|
199
|
+
'window.unsupportedHealthKitDevice(true)'
|
|
200
|
+
);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (status === 'CONNECTED') {
|
|
205
|
+
const [steps, sleep] = await Promise.allSettled([
|
|
206
|
+
VisitRnSdkViewManager?.getTodayStepCount?.(),
|
|
207
|
+
VisitRnSdkViewManager?.getTodaySleepMinutes?.(),
|
|
208
|
+
]);
|
|
209
|
+
const stepCount =
|
|
210
|
+
steps.status === 'fulfilled' ? Number(steps.value) || 0 : 0;
|
|
211
|
+
const sleepMinutes =
|
|
212
|
+
sleep.status === 'fulfilled' ? Number(sleep.value) || 0 : 0;
|
|
213
|
+
webviewRef.current?.injectJavaScript(
|
|
214
|
+
`window.updateFitnessPermissions(true,${stepCount},${sleepMinutes})`
|
|
215
|
+
);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
webviewRef.current?.injectJavaScript(
|
|
220
|
+
'window.updateFitnessPermissions(false,0,0)'
|
|
221
|
+
);
|
|
222
|
+
} catch (err) {
|
|
223
|
+
if (isLoggingEnabled) {
|
|
224
|
+
console.warn('refreshHealthKitPermissionState failed: ', err?.message);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}, [VisitRnSdkViewManager, isLoggingEnabled]);
|
|
228
|
+
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
const subscription = AppState.addEventListener('change', (nextAppState) => {
|
|
231
|
+
if (nextAppState === 'active') {
|
|
232
|
+
refreshHealthKitPermissionState();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return () => {
|
|
237
|
+
subscription.remove();
|
|
238
|
+
};
|
|
239
|
+
}, [refreshHealthKitPermissionState]);
|
|
240
|
+
|
|
241
|
+
const handleMessage = async (event) => {
|
|
242
|
+
const data = JSON.parse(unescapeHTML(event.nativeEvent.data));
|
|
243
|
+
const {
|
|
244
|
+
method,
|
|
245
|
+
type,
|
|
246
|
+
frequency,
|
|
247
|
+
timestamp,
|
|
248
|
+
apiBaseUrl,
|
|
249
|
+
authtoken,
|
|
250
|
+
googleFitLastSync,
|
|
251
|
+
gfHourlyLastSync,
|
|
252
|
+
url,
|
|
253
|
+
} = data;
|
|
254
|
+
console.log('handleMessage data is', data);
|
|
255
|
+
console.log(unescapeHTML(event.nativeEvent.data));
|
|
256
|
+
switch (method) {
|
|
257
|
+
case 'UPDATE_PLATFORM':
|
|
258
|
+
webviewRef.current?.injectJavaScript('window.setSdkPlatform("IOS")');
|
|
259
|
+
break;
|
|
260
|
+
case 'CONNECT_TO_GOOGLE_FIT':
|
|
261
|
+
if (DeviceInfo.getModel() === 'iPad') {
|
|
262
|
+
console.log('unsupportedHealthKitDevice triggered');
|
|
263
|
+
webviewRef.current?.injectJavaScript(
|
|
264
|
+
'window.unsupportedHealthKitDevice(true)'
|
|
265
|
+
);
|
|
266
|
+
} else {
|
|
267
|
+
VisitRnSdkViewManager?.connectToAppleHealth((res) => {
|
|
268
|
+
const authStatus = res?.authStatus;
|
|
269
|
+
const steps = Number(res?.numberOfSteps) || 0;
|
|
270
|
+
const sleep = Number(res?.sleepTime) || 0;
|
|
271
|
+
|
|
272
|
+
if (authStatus === 'GRANTED') {
|
|
273
|
+
webviewRef.current?.injectJavaScript(
|
|
274
|
+
`window.updateFitnessPermissions(true,${steps},${sleep})`
|
|
275
|
+
);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Denied / unavailable: tell the WebView permission isn't granted
|
|
280
|
+
// and offer to open the Apple Health app so the user can toggle
|
|
281
|
+
// it manually (mirrors Android's Health Connect flow).
|
|
282
|
+
webviewRef.current?.injectJavaScript(
|
|
283
|
+
'window.updateFitnessPermissions(false,0,0)'
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
if (authStatus === 'DENIED') {
|
|
287
|
+
Alert.alert(
|
|
288
|
+
'Permission Denied',
|
|
289
|
+
'To allow permission, please follow these steps:\n\n' +
|
|
290
|
+
'1. Open Settings\n' +
|
|
291
|
+
'2. Tap on Apps → Health\n' +
|
|
292
|
+
'3. Tap Data Access & Devices\n' +
|
|
293
|
+
'4. Select this app and enable all categories',
|
|
294
|
+
[
|
|
295
|
+
{ text: 'Cancel', style: 'cancel' },
|
|
296
|
+
{
|
|
297
|
+
text: 'Open Settings',
|
|
298
|
+
onPress: () => {
|
|
299
|
+
VisitRnSdkViewManager?.openAppleHealthApp?.().catch(
|
|
300
|
+
(err) =>
|
|
301
|
+
console.log(
|
|
302
|
+
'openAppleHealthApp failed:',
|
|
303
|
+
err?.message
|
|
304
|
+
)
|
|
305
|
+
);
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
]
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
break;
|
|
314
|
+
case 'GET_DATA_TO_GENERATE_GRAPH':
|
|
315
|
+
VisitRnSdkViewManager?.renderGraph(
|
|
316
|
+
{ type, frequency, timestamp },
|
|
317
|
+
(err, results) => {
|
|
318
|
+
if (err) {
|
|
319
|
+
console.log('error initializing Healthkit: ', err);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (results[0]) {
|
|
323
|
+
console.log('results initializing Healthkit: ', results[0]);
|
|
324
|
+
webviewRef.current?.injectJavaScript(`window.${results[0]}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
break;
|
|
329
|
+
case 'UPDATE_API_BASE_URL':
|
|
330
|
+
if (!hasLoadedOnce) {
|
|
331
|
+
VisitRnSdkViewManager?.updateApiUrl({
|
|
332
|
+
apiBaseUrl,
|
|
333
|
+
authToken: authtoken,
|
|
334
|
+
googleFitLastSync,
|
|
335
|
+
gfHourlyLastSync,
|
|
336
|
+
});
|
|
337
|
+
setHasLoadedOnce(true);
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
340
|
+
|
|
341
|
+
case 'OPEN_PDF':
|
|
342
|
+
Linking.openURL(url);
|
|
343
|
+
break;
|
|
344
|
+
case 'OPEN_FACE_SCAN_FLOW':
|
|
345
|
+
EventRegister.emitEvent('visit-event', {
|
|
346
|
+
message: 'OPEN_FACE_SCAN_FLOW',
|
|
347
|
+
});
|
|
348
|
+
break;
|
|
349
|
+
case 'CLOSE_VIEW':
|
|
350
|
+
break;
|
|
351
|
+
case 'GET_LOCATION_PERMISSIONS':
|
|
352
|
+
webviewRef.current?.injectJavaScript(
|
|
353
|
+
'window.checkTheGpsPermission(true)'
|
|
354
|
+
);
|
|
355
|
+
break;
|
|
356
|
+
|
|
357
|
+
default:
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const { height, width } = Dimensions.get('screen');
|
|
363
|
+
return (
|
|
364
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
365
|
+
<SafeAreaView style={{ flex: 1, backgroundColor: 'white', height, width }}>
|
|
366
|
+
{loading ? (
|
|
367
|
+
<LoadingIndicator />
|
|
368
|
+
) : (
|
|
369
|
+
<WebView
|
|
370
|
+
ref={webviewRef}
|
|
371
|
+
source={{ uri: source }}
|
|
372
|
+
style={styles.webView}
|
|
373
|
+
javascriptEnabled
|
|
374
|
+
onMessage={handleMessage}
|
|
375
|
+
onError={(errorMessage) => {
|
|
376
|
+
EventRegister.emitEvent(visitEvent, {
|
|
377
|
+
message: 'web-view-error',
|
|
378
|
+
errorMessage: errorMessage,
|
|
379
|
+
});
|
|
380
|
+
if (isLoggingEnabled) {
|
|
381
|
+
console.warn('Webview error: ', errorMessage);
|
|
382
|
+
}
|
|
383
|
+
}}
|
|
384
|
+
/>
|
|
385
|
+
)}
|
|
386
|
+
</SafeAreaView>
|
|
387
|
+
);
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const styles = StyleSheet.create({
|
|
391
|
+
webViewContainer: {
|
|
392
|
+
flex: 1,
|
|
393
|
+
backgroundColor: 'white',
|
|
394
|
+
},
|
|
395
|
+
webView: {
|
|
396
|
+
flex: 1,
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
VisitRnSdkView.defaultProps = {
|
|
401
|
+
id: '',
|
|
402
|
+
token: '',
|
|
403
|
+
baseUrl: '',
|
|
404
|
+
errorBaseUrl: '',
|
|
405
|
+
moduleName: '',
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
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
|
+
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
package com.visitrnsdk
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.location.LocationManager
|
|
5
|
-
import android.os.Build
|
|
6
|
-
import com.facebook.react.bridge.Promise
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
9
|
-
import com.facebook.react.bridge.ReactMethod
|
|
10
|
-
|
|
11
|
-
class VisitRnSdkLocationModule(
|
|
12
|
-
reactContext: ReactApplicationContext
|
|
13
|
-
) : ReactContextBaseJavaModule(reactContext) {
|
|
14
|
-
override fun getName() = "VisitRnSdkLocation"
|
|
15
|
-
|
|
16
|
-
@ReactMethod
|
|
17
|
-
fun isLocationServicesEnabled(promise: Promise) {
|
|
18
|
-
try {
|
|
19
|
-
val locationManager =
|
|
20
|
-
reactApplicationContext.getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
|
21
|
-
val isEnabled = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
22
|
-
locationManager.isLocationEnabled
|
|
23
|
-
} else {
|
|
24
|
-
locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) ||
|
|
25
|
-
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
promise.resolve(isEnabled)
|
|
29
|
-
} catch (error: Exception) {
|
|
30
|
-
promise.reject(
|
|
31
|
-
"LOCATION_SERVICES_CHECK_FAILED",
|
|
32
|
-
"Unable to determine whether Location Services are enabled.",
|
|
33
|
-
error
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|