react-native-visit-rn-sdk 5.0.2 → 6.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.
Files changed (139) hide show
  1. package/README.md +18 -2
  2. package/ios/VisitRnSdkViewManager.h +1 -19
  3. package/ios/VisitRnSdkViewManager.m +8 -1294
  4. package/lib/commonjs/components/VideoCallComponent.js +59 -73
  5. package/lib/commonjs/components/VideoCallComponent.js.map +1 -1
  6. package/lib/commonjs/index.android.js +30 -351
  7. package/lib/commonjs/index.android.js.map +1 -1
  8. package/lib/commonjs/index.ios.js +14 -222
  9. package/lib/commonjs/index.ios.js.map +1 -1
  10. package/lib/module/components/VideoCallComponent.js +57 -69
  11. package/lib/module/components/VideoCallComponent.js.map +1 -1
  12. package/lib/module/index.android.js +27 -343
  13. package/lib/module/index.android.js.map +1 -1
  14. package/lib/module/index.ios.js +13 -219
  15. package/lib/module/index.ios.js.map +1 -1
  16. package/package.json +3 -5
  17. package/src/index.android.js +29 -512
  18. package/src/index.ios.js +30 -317
  19. package/android/bin/build/generated/source/buildConfig/debug/com/visitrnsdk/BuildConfig.class +0 -0
  20. package/android/bin/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
  21. package/android/bin/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
  22. package/android/bin/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
  23. package/android/bin/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -5
  24. package/android/bin/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  25. package/android/bin/build/intermediates/annotations_typedef_file/debug/typedefs.txt +0 -0
  26. package/android/bin/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  27. package/android/bin/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  28. package/android/bin/build/intermediates/compile_symbol_list/debug/R.txt +0 -1954
  29. package/android/bin/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  30. package/android/bin/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  31. package/android/bin/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  32. package/android/bin/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  33. package/android/bin/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  34. package/android/bin/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
  35. package/android/bin/build/intermediates/library_java_res/debug/res.jar +0 -0
  36. package/android/bin/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
  37. package/android/bin/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -8
  38. package/android/bin/build/intermediates/merged_java_res/debug/feature-react-native-visit-rn-sdk.jar +0 -0
  39. package/android/bin/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
  40. package/android/bin/build/intermediates/navigation_json/debug/navigation.json +0 -1
  41. package/android/bin/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
  42. package/android/bin/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  43. package/android/bin/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1447
  44. package/android/bin/build/intermediates/variant_model/debug/variant_model.json +0 -0
  45. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  46. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  47. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  48. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  49. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  50. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  51. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  52. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  53. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  54. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  55. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  56. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  57. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  58. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  59. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  60. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  61. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  62. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  63. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  64. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  65. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  66. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  67. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  68. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  69. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  70. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  71. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  72. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  73. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  74. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  75. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  76. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  77. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  78. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  79. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  80. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  81. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  82. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  83. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  84. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  85. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  86. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  87. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  88. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  89. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  90. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  91. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  92. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  93. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  94. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  95. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  96. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  97. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  98. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  99. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  100. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  101. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
  102. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  103. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  104. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  105. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  106. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  107. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  108. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  109. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  110. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  111. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  112. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  113. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  114. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  115. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  116. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  117. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  118. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  119. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  120. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  121. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  122. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
  123. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  124. package/android/bin/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  125. package/android/bin/build/outputs/aar/react-native-visit-rn-sdk-debug.aar +0 -0
  126. package/android/bin/build/outputs/logs/manifest-merger-debug-report.txt +0 -25
  127. package/android/bin/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  128. package/android/bin/build/tmp/kotlin-classes/debug/META-INF/react-native-visit-rn-sdk_debug.kotlin_module +0 -0
  129. package/android/bin/local.properties +0 -8
  130. package/lib/commonjs/Services.js +0 -36
  131. package/lib/commonjs/Services.js.map +0 -1
  132. package/lib/commonjs/constants.js +0 -12
  133. package/lib/commonjs/constants.js.map +0 -1
  134. package/lib/module/Services.js +0 -27
  135. package/lib/module/Services.js.map +0 -1
  136. package/lib/module/constants.js +0 -5
  137. package/lib/module/constants.js.map +0 -1
  138. package/src/Services.js +0 -37
  139. package/src/constants.js +0 -4
@@ -3,271 +3,32 @@ import { EventRegister } from 'react-native-event-listeners';
3
3
 
4
4
  import {
5
5
  SafeAreaView,
6
- NativeModules,
7
6
  PermissionsAndroid,
8
7
  BackHandler,
9
8
  Linking,
10
9
  Alert,
11
- AppState,
12
- NativeEventEmitter,
13
10
  } from 'react-native';
14
11
 
15
-
16
12
  import WebView from 'react-native-webview';
17
13
 
18
- import LocationEnabler from 'react-native-location-enabler';
19
-
20
- import DeviceInfo from 'react-native-device-info';
14
+ import LocationEnabler from '@visit-health/react-native-location-enabler';
21
15
 
22
- import axios from 'axios';
23
16
  import VideoCallComponent from './components/VideoCallComponent';
24
17
 
25
- import constants from './constants';
26
-
27
- export const httpClient = axios.create({
28
- timeout: 60000,
29
- });
30
-
31
- const messageEmitter = new NativeEventEmitter(NativeModules.VisitFitnessModule);
32
-
33
18
  const {
34
19
  PRIORITIES: { HIGH_ACCURACY },
35
20
  useLocationSettings,
36
21
  addListener,
37
22
  } = LocationEnabler;
38
23
 
39
- const VisitRnSdkView = ({
40
- cpsid,
41
- baseUrl,
42
- errorBaseUrl,
43
- token,
44
- moduleName,
45
- environment,
46
- magicLink,
47
- isLoggingEnabled,
48
- }) => {
49
- const [source, setSource] = useState('');
50
- const [appState, setAppState] = useState(AppState.currentState);
24
+ const VisitRnSdkView = ({ magicLink, isLoggingEnabled }) => {
25
+ const source = typeof magicLink === 'string' ? magicLink.trim() : '';
51
26
 
52
27
  const [
53
28
  showPermissionAlreadyDeniedDialog,
54
29
  setShowPermissionAlreadyDeniedDialog,
55
30
  ] = useState(false);
56
31
 
57
- useEffect(() => {
58
- if (isLoggingEnabled) {
59
- console.log('useEffect ran');
60
- }
61
-
62
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
63
-
64
- if ((magicLink?.trim()?.length || 0) > 0) {
65
- setSource(magicLink);
66
- } else {
67
- DeviceInfo.getAndroidId()
68
- .then((deviceId) => {
69
- var buildNumber = DeviceInfo.getBuildNumber();
70
- let systemVersion = DeviceInfo.getSystemVersion();
71
- let version = DeviceInfo.getVersion();
72
-
73
- if (isLoggingEnabled) {
74
- console.log(
75
- ' baseUrl : ' +
76
- baseUrl +
77
- 'token: ' +
78
- token +
79
- ' cpsid: ' +
80
- cpsid +
81
- ' environment: ' +
82
- environment +
83
- 'buildNumber:' +
84
- buildNumber +
85
- ' systemVersion:' +
86
- systemVersion +
87
- ' version : ' +
88
- version +
89
- ' deviceId',
90
- deviceId
91
- );
92
- }
93
-
94
- var finalEndPoint = `${baseUrl}/partners/v3/generate-magic-link-star-health`;
95
-
96
- if (isLoggingEnabled) {
97
- console.log('finalEndPoint: ' + finalEndPoint);
98
- }
99
-
100
- httpClient
101
- .post(finalEndPoint, {
102
- cpsid: cpsid,
103
- token: token,
104
- srcClientId: 'Android',
105
- deviceId: deviceId,
106
- appVersion: version,
107
- deviceVersion: systemVersion,
108
- userEnv: environment,
109
- })
110
- .then((response) => {
111
- let data = response.data;
112
- // let visitMagicLink = data.result; //@Deprecated. Superseded by magic code usage.
113
- const errorMessage = data.errorMessage;
114
- const magicCode = data.magicCode;
115
- const responseReferenceId = data.responseReferenceId;
116
- const otherValues = data.otherValues;
117
-
118
- let finalBaseUrl = '';
119
-
120
- if (environment.toUpperCase() === 'PROD') {
121
- finalBaseUrl = constants.PROD_BASE_URL;
122
- } else {
123
- finalBaseUrl = constants.STAGE_BASE_URL;
124
- }
125
-
126
- let finalUrl = `${finalBaseUrl}=${magicCode}`;
127
-
128
- if (data.message === 'success') {
129
- if ((moduleName?.trim()?.length || 0) > 0) {
130
- finalUrl += `&tab=${moduleName}`;
131
- }
132
-
133
- if (
134
- typeof responseReferenceId === 'string' &&
135
- responseReferenceId.trim().length > 0
136
- ) {
137
- finalUrl += `&responseReferenceId=${responseReferenceId}`;
138
- }
139
-
140
- if (
141
- typeof otherValues === 'string' &&
142
- otherValues.trim().length > 0
143
- ) {
144
- finalUrl += `&otherValues=${otherValues}`;
145
- }
146
-
147
- if (isLoggingEnabled) {
148
- console.log('magicLink: ' + finalUrl);
149
- }
150
-
151
- setSource(finalUrl);
152
- } else {
153
- var errorUrl = `${errorBaseUrl}/star-health?error=${errorMessage}`;
154
- setSource(errorUrl);
155
-
156
- if (errorMessage != null) {
157
- if (errorMessage === 'Please login again') {
158
- EventRegister.emitEvent('visit-event', {
159
- message: 'unauthorized-wellness-access',
160
- errorMessage: errorMessage,
161
- });
162
- } else if (errorMessage.includes('External Server Error')) {
163
- EventRegister.emitEvent('visit-event', {
164
- message: 'external-server-error',
165
- errorMessage: errorMessage,
166
- });
167
- }
168
- }
169
-
170
- if (isLoggingEnabled) {
171
- console.log(
172
- 'erorMessage: ' +
173
- data.errorMessage +
174
- ' errorUrl: ' +
175
- errorUrl
176
- );
177
- }
178
- }
179
- })
180
- .catch((error) => {
181
- var errorUrl = `${errorBaseUrl}/star-health?error=${error}`;
182
- setSource(errorUrl);
183
-
184
- EventRegister.emitEvent('visit-event', {
185
- message: 'generate-magic-link-failed',
186
- errorMessage: `${error}`,
187
- });
188
-
189
- if (isLoggingEnabled) {
190
- console.log('error: ' + error);
191
- }
192
- });
193
- })
194
- .catch((err) => {
195
- var errorUrl = `${errorBaseUrl}/star-health?error=${err}`;
196
- setSource(errorUrl);
197
-
198
- EventRegister.emitEvent('visit-event', {
199
- message: 'getDeviceInfo-failed',
200
- errorMessage: `${err}`,
201
- });
202
-
203
- if (isLoggingEnabled) {
204
- console.log('getDeviceInfo err', err);
205
- }
206
- });
207
- }
208
- }, [
209
- cpsid,
210
- token,
211
- baseUrl,
212
- errorBaseUrl,
213
- moduleName,
214
- environment,
215
- magicLink,
216
- isLoggingEnabled,
217
- ]);
218
-
219
- useEffect(() => {
220
- const subscription = messageEmitter.addListener('onMessage', (message) => {
221
- console.log('Received message:', message);
222
-
223
- if (typeof message === 'string' && message.includes('RemoteException')) {
224
- Alert.alert(
225
- 'Error!',
226
- 'Something went wrong while connecting to Health Connect. Please try again.',
227
- []
228
- );
229
- }
230
-
231
- EventRegister.emitEvent('visit-event', {
232
- message: 'health-connect-error-event',
233
- errorMessage: message,
234
- });
235
- });
236
-
237
- return () => {
238
- // Clean up the subscription when the component unmounts
239
- subscription.remove();
240
- };
241
- }, []);
242
-
243
- useEffect(() => {
244
- const subscription = AppState.addEventListener(
245
- 'change',
246
- handleAppStateChange
247
- );
248
- console.log(`AppState.addEventListener added, current state: ${appState}`);
249
-
250
- return () => {
251
- subscription.remove();
252
- };
253
- }, [appState]); // Include appState in the dependency array to ensure it's up to date.
254
-
255
- const handleAppStateChange = (nextAppState) => {
256
- // console.log(
257
- // "nextAppState: " + nextAppState + ", previousState: " + appState
258
- // );
259
-
260
- // Instead of relying on the old appState, use the nextAppState directly
261
- if (appState.match(/inactive|background/) && nextAppState === 'active') {
262
- if (isLoggingEnabled) {
263
- console.log('App has come to the foreground!');
264
- }
265
- getHealthConnectStatus();
266
- }
267
-
268
- setAppState(nextAppState); // Update the state with the new app state
269
- };
270
-
271
32
  const [enabled, requestResolution] = useLocationSettings(
272
33
  {
273
34
  priority: HIGH_ACCURACY, // default BALANCED_POWER_ACCURACY
@@ -362,159 +123,6 @@ const VisitRnSdkView = ({
362
123
  }
363
124
  };
364
125
 
365
- const showHealthConnectPermissionDeniedDialog = () => {
366
- Alert.alert(
367
- 'Permission Denied',
368
- 'Go to Health Connect App to allow app permission',
369
- [
370
- {
371
- text: 'Cancel',
372
- onPress: () => {
373
- console.log('Cancel clicked');
374
- },
375
- },
376
- {
377
- text: 'Open Health Connect',
378
- onPress: () => {
379
- openHealthConnectApp();
380
- },
381
- },
382
- ]
383
- );
384
- };
385
-
386
- const openHealthConnectApp = async () => {
387
- NativeModules.VisitFitnessModule.openHealthConnectApp();
388
- };
389
-
390
- const askForHealthConnectPermission = async () => {
391
- try {
392
- const isPermissionGranted =
393
- await NativeModules.VisitFitnessModule.askForFitnessPermission();
394
-
395
- if (isLoggingEnabled) {
396
- console.log('isPermissionGranted: ' + isPermissionGranted);
397
- }
398
-
399
- if (isPermissionGranted === 'GRANTED') {
400
- getHealthConnectStatus();
401
- // getDailyFitnessData();
402
- } else if (isPermissionGranted === 'CANCELLED') {
403
- showHealthConnectPermissionDeniedDialog();
404
- }
405
- } catch (e) {
406
- if (isLoggingEnabled) {
407
- console.error(e);
408
- }
409
- }
410
- };
411
-
412
- const getHealthConnectStatus = async () => {
413
- try {
414
- const healthConnectStatus =
415
- await NativeModules.VisitFitnessModule.getHealthConnectStatus();
416
-
417
- if (isLoggingEnabled) {
418
- console.log('getHealthConnectStatus: ' + healthConnectStatus);
419
- }
420
-
421
- if (healthConnectStatus === 'NOT_SUPPORTED') {
422
- webviewRef.current?.injectJavaScript(
423
- 'window.healthConnectNotSupported()'
424
- );
425
- } else if (healthConnectStatus === 'NOT_INSTALLED') {
426
- webviewRef.current?.injectJavaScript(
427
- 'window.healthConnectNotInstall()'
428
- );
429
- webviewRef.current?.injectJavaScript(
430
- 'window.updateFitnessPermissions(false,0,0)'
431
- );
432
- } else if (healthConnectStatus === 'INSTALLED') {
433
- webviewRef.current?.injectJavaScript('window.healthConnectAvailable()');
434
-
435
- webviewRef.current?.injectJavaScript(
436
- 'window.updateFitnessPermissions(false,0,0)'
437
- );
438
- } else if (healthConnectStatus === 'CONNECTED') {
439
- getDailyFitnessData();
440
- }
441
- } catch (e) {
442
- if (isLoggingEnabled) {
443
- console.error(e);
444
- }
445
- }
446
- };
447
-
448
- const getDailyFitnessData = async () => {
449
- if (isLoggingEnabled) {
450
- console.log('getDailyFitnessData() called');
451
- }
452
-
453
- try {
454
- const dailyFitnessData =
455
- await NativeModules.VisitFitnessModule.requestDailyFitnessData();
456
-
457
- webviewRef.current?.injectJavaScript(dailyFitnessData);
458
- } catch (error) {
459
- if (isLoggingEnabled) {
460
- console.log(error);
461
- }
462
- }
463
- };
464
-
465
- const requestActivityData = async (type, frequency, timeStamp) => {
466
- if (isLoggingEnabled) {
467
- console.log('requestActivityData() called');
468
- }
469
-
470
- try {
471
- const graphData =
472
- await NativeModules.VisitFitnessModule.requestActivityDataFromHealthConnect(
473
- type,
474
- frequency,
475
- timeStamp
476
- );
477
-
478
- if (isLoggingEnabled) {
479
- console.log(`requestActivityData() data: ` + graphData);
480
- }
481
-
482
- webviewRef.current?.injectJavaScript('window.' + graphData);
483
- } catch (error) {
484
- if (isLoggingEnabled) {
485
- console.log(error);
486
- }
487
- }
488
- };
489
-
490
- const updateApiBaseUrl = async (
491
- apiBaseUrl,
492
- authtoken,
493
- googleFitLastSync,
494
- gfHourlyLastSync
495
- ) => {
496
- if (isLoggingEnabled) {
497
- console.log('updateApiBaseUrl() called.');
498
- }
499
-
500
- try {
501
- const message = await NativeModules.VisitFitnessModule.updateApiBaseUrl(
502
- apiBaseUrl,
503
- authtoken,
504
- googleFitLastSync,
505
- gfHourlyLastSync
506
- );
507
-
508
- if (isLoggingEnabled) {
509
- console.log(message);
510
- }
511
- } catch (error) {
512
- if (isLoggingEnabled) {
513
- console.log(error);
514
- }
515
- }
516
- };
517
-
518
126
  const runBeforeFirst = `
519
127
  window.isNativeApp = true;
520
128
  window.platform = "ANDROID";
@@ -531,15 +139,13 @@ const VisitRnSdkView = ({
531
139
  rawDoctorName && rawDoctorName.indexOf('Dr.') > -1
532
140
  ? rawDoctorName.replace('Dr. ', '')
533
141
  : rawDoctorName && rawDoctorName.indexOf('Dr') > -1
534
- ? rawDoctorName.replace('Dr ', '')
535
- : null;
142
+ ? rawDoctorName.replace('Dr ', '')
143
+ : null;
536
144
  const userName = parsedObject?.userName;
537
145
 
538
146
  if (!roomName || !accessToken) {
539
147
  if (isLoggingEnabled) {
540
- console.warn(
541
- 'Video call payload missing roomName/accessToken.'
542
- );
148
+ console.warn('Video call payload missing roomName/accessToken.');
543
149
  }
544
150
  return;
545
151
  }
@@ -564,13 +170,6 @@ const VisitRnSdkView = ({
564
170
  const parsedObject = JSON.parse(event.nativeEvent.data);
565
171
  if (parsedObject.method != null) {
566
172
  switch (parsedObject.method) {
567
- case 'GET_HEALTH_CONNECT_STATUS':
568
- getHealthConnectStatus();
569
- break;
570
- case 'CONNECT_TO_GOOGLE_FIT':
571
- askForHealthConnectPermission();
572
-
573
- break;
574
173
  case 'startVideoCall':
575
174
  startVideoConsultation(parsedObject);
576
175
  break;
@@ -579,55 +178,6 @@ const VisitRnSdkView = ({
579
178
  'window.setSdkPlatform("ANDROID")'
580
179
  );
581
180
  break;
582
- case 'UPDATE_API_BASE_URL':
583
- {
584
- let apiBaseUrl = parsedObject.apiBaseUrl;
585
- let authtoken = parsedObject.authtoken;
586
-
587
- let googleFitLastSync = parsedObject.googleFitLastSync;
588
- let gfHourlyLastSync = parsedObject.gfHourlyLastSync;
589
-
590
- if (isLoggingEnabled) {
591
- console.log(
592
- 'apiBaseUrl: ' +
593
- 'NOT SHOWN' +
594
- ' authtoken: ' +
595
- 'NOT SHOWN' +
596
- ' googleFitLastSync: ' +
597
- googleFitLastSync +
598
- ' gfHourlyLastSync: ' +
599
- gfHourlyLastSync
600
- );
601
- }
602
-
603
- updateApiBaseUrl(
604
- apiBaseUrl,
605
- authtoken,
606
- googleFitLastSync,
607
- gfHourlyLastSync
608
- );
609
- }
610
- break;
611
- case 'GET_DATA_TO_GENERATE_GRAPH':
612
- {
613
- let type = parsedObject.type;
614
- let frequency = parsedObject.frequency;
615
- let timeStamp = parsedObject.timestamp;
616
-
617
- if (isLoggingEnabled) {
618
- console.log(
619
- 'type: ' +
620
- type +
621
- ' frequency:' +
622
- frequency +
623
- ' timeStamp: ' +
624
- timeStamp
625
- );
626
- }
627
-
628
- requestActivityData(type, frequency, timeStamp);
629
- }
630
- break;
631
181
  case 'GET_LOCATION_PERMISSIONS':
632
182
  console.log('GET_LOCATION_PERMISSIONS');
633
183
  requestLocationPermission();
@@ -668,28 +218,7 @@ const VisitRnSdkView = ({
668
218
  return false;
669
219
  }, [canGoBack]);
670
220
 
671
- useEffect(() => {
672
- // Subscribe to GPS/location setting changes
673
- const locationSub = addListener(({ locationEnabled }) => {
674
- if (locationEnabled) {
675
- checkLocationPermissionAndSendCallback();
676
- }
677
- });
678
-
679
- // Subscribe to Android hardware back press
680
- const backSub = BackHandler.addEventListener(
681
- 'hardwareBackPress',
682
- handleBack
683
- );
684
-
685
- // Cleanup subscriptions on unmount
686
- return () => {
687
- backSub?.remove();
688
- locationSub?.remove();
689
- };
690
- }, [handleBack]);
691
-
692
- const checkLocationPermissionAndSendCallback = async () => {
221
+ const checkLocationPermissionAndSendCallback = useCallback(async () => {
693
222
  const isLocationPermissionAvailable = await PermissionsAndroid.check(
694
223
  PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
695
224
  );
@@ -709,7 +238,28 @@ const VisitRnSdkView = ({
709
238
 
710
239
  webviewRef.current?.injectJavaScript(finalString);
711
240
  }
712
- };
241
+ }, [isLoggingEnabled]);
242
+
243
+ useEffect(() => {
244
+ // Subscribe to GPS/location setting changes
245
+ const locationSub = addListener(({ locationEnabled }) => {
246
+ if (locationEnabled) {
247
+ checkLocationPermissionAndSendCallback();
248
+ }
249
+ });
250
+
251
+ // Subscribe to Android hardware back press
252
+ const backSub = BackHandler.addEventListener(
253
+ 'hardwareBackPress',
254
+ handleBack
255
+ );
256
+
257
+ // Cleanup subscriptions on unmount
258
+ return () => {
259
+ backSub?.remove();
260
+ locationSub?.remove();
261
+ };
262
+ }, [handleBack, checkLocationPermissionAndSendCallback]);
713
263
 
714
264
  return (
715
265
  // eslint-disable-next-line react-native/no-inline-styles
@@ -760,33 +310,6 @@ const VisitRnSdkView = ({
760
310
  );
761
311
  };
762
312
 
763
- export const fetchDailyFitnessData = (startTimeStamp, isLoggingEnabled) => {
764
- return new Promise((resolve, reject) => {
765
- console.log('fetchDailyFitnessData called: ' + startTimeStamp);
766
-
767
- NativeModules.VisitFitnessModule.fetchDailyFitnessData(startTimeStamp)
768
- .then((result) => {
769
- resolve(result);
770
- })
771
- .catch((err) => reject(err));
772
- });
773
- };
774
-
775
- export const fetchHourlyFitnessData = (startTimeStamp, isLoggingEnabled) => {
776
- return new Promise((resolve, reject) => {
777
- if (isLoggingEnabled) {
778
- console.log('fetchHourlyFitnessData called: ' + startTimeStamp);
779
- }
780
-
781
- NativeModules.VisitFitnessModule.fetchHourlyFitnessData(startTimeStamp)
782
- .then((result) => {
783
- resolve(result);
784
- })
785
- .catch((err) => reject(err));
786
- });
787
- };
788
-
789
-
790
313
  // debounce, deferred
791
314
  // function debounce(task, ms) {
792
315
  // let t = { promise: null, cancel: (_) => void 0 };
@@ -814,12 +337,6 @@ export const fetchHourlyFitnessData = (startTimeStamp, isLoggingEnabled) => {
814
337
  export default VisitRnSdkView;
815
338
 
816
339
  VisitRnSdkView.defaultProps = {
817
- cpsid: '',
818
- token: '',
819
- baseUrl: '',
820
- errorBaseUrl: '',
821
- moduleName: '',
822
- environment: '',
823
340
  magicLink: '',
824
341
  isLoggingEnabled: false,
825
342
  };