react-native-visit-rn-sdk 0.5.5 → 2.0.2

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.
@@ -27,6 +27,7 @@ const escapeChars = {
27
27
  };
28
28
  const unescapeHTML = str =>
29
29
  // modified from underscore.string and string.js
30
+ // eslint-disable-next-line no-useless-escape
30
31
  str.replace(/\&([^;]+);/g, (entity, entityCode) => {
31
32
  let match;
32
33
  if (entityCode in escapeChars) {
@@ -34,7 +35,7 @@ str.replace(/\&([^;]+);/g, (entity, entityCode) => {
34
35
  } else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
35
36
  return String.fromCharCode(parseInt(match[1], 16));
36
37
  } else if (match = entityCode.match(/^#(\d+)$/)) {
37
- return String.fromCharCode(~~match[1]);
38
+ return String.fromCharCode(match[1]);
38
39
  } else {
39
40
  return entity;
40
41
  }
@@ -83,8 +84,9 @@ const VisitRnSdkView = _ref => {
83
84
  });
84
85
  }
85
86
  } else if (res.data.message === 'success') {
86
- var _res$data4;
87
+ var _res$data4, _res$data5;
87
88
  const magicCode = (_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.magicCode;
89
+ const responseReferenceId = (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.responseReferenceId;
88
90
  let finalBaseUrl = '';
89
91
  if (magicCode) {
90
92
  if (environment.toUpperCase() === 'PROD') {
@@ -98,6 +100,9 @@ const VisitRnSdkView = _ref => {
98
100
  if (moduleName !== null && moduleName !== void 0 && moduleName.trim()) {
99
101
  finalUrl += `&tab=${moduleName}`;
100
102
  }
103
+ if (typeof responseReferenceId === 'string' && responseReferenceId.trim().length > 0) {
104
+ finalUrl += `&responseReferenceId=${responseReferenceId}`;
105
+ }
101
106
  setSource(finalUrl);
102
107
  }
103
108
  } else {
@@ -165,6 +170,7 @@ const VisitRnSdkView = _ref => {
165
170
  type,
166
171
  frequency,
167
172
  timestamp,
173
+ // eslint-disable-next-line no-shadow
168
174
  apiBaseUrl,
169
175
  authtoken,
170
176
  googleFitLastSync,
@@ -239,31 +245,35 @@ const VisitRnSdkView = _ref => {
239
245
  height,
240
246
  width
241
247
  } = _reactNative.Dimensions.get('screen');
242
- return /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, {
243
- style: {
244
- flex: 1,
245
- backgroundColor: 'white',
246
- height,
247
- width
248
- }
249
- }, loading ? /*#__PURE__*/_react.default.createElement(LoadingIndicator, null) : /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
250
- ref: webviewRef,
251
- source: {
252
- uri: source
253
- },
254
- style: styles.webView,
255
- javascriptEnabled: true,
256
- onMessage: handleMessage,
257
- onError: errorMessage => {
258
- _reactNativeEventListeners.EventRegister.emitEvent(visitEvent, {
259
- message: 'web-view-error',
260
- errorMessage: errorMessage
261
- });
262
- if (isLoggingEnabled) {
263
- console.warn('Webview error: ', errorMessage);
248
+ return (
249
+ /*#__PURE__*/
250
+ // eslint-disable-next-line react-native/no-inline-styles
251
+ _react.default.createElement(_reactNative.SafeAreaView, {
252
+ style: {
253
+ flex: 1,
254
+ backgroundColor: 'white',
255
+ height,
256
+ width
264
257
  }
265
- }
266
- }));
258
+ }, loading ? /*#__PURE__*/_react.default.createElement(LoadingIndicator, null) : /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
259
+ ref: webviewRef,
260
+ source: {
261
+ uri: source
262
+ },
263
+ style: styles.webView,
264
+ javascriptEnabled: true,
265
+ onMessage: handleMessage,
266
+ onError: errorMessage => {
267
+ _reactNativeEventListeners.EventRegister.emitEvent(visitEvent, {
268
+ message: 'web-view-error',
269
+ errorMessage: errorMessage
270
+ });
271
+ if (isLoggingEnabled) {
272
+ console.warn('Webview error: ', errorMessage);
273
+ }
274
+ }
275
+ }))
276
+ );
267
277
  };
268
278
  const styles = _reactNative.StyleSheet.create({
269
279
  webViewContainer: {
@@ -286,7 +296,9 @@ exports.default = _default;
286
296
  const LoadingIndicator = () => {
287
297
  return /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
288
298
  color: "#000",
289
- size: "small",
299
+ size: "small"
300
+ // eslint-disable-next-line react-native/no-inline-styles
301
+ ,
290
302
  style: {
291
303
  flex: 1,
292
304
  zIndex: 100,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeEventListeners","_reactNativeWebview","_reactNativeDeviceInfo","_interopRequireDefault","_Services","_constants","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","LINKING_ERROR","Platform","select","ios","escapeChars","lt","gt","quot","apos","amp","unescapeHTML","str","replace","entity","entityCode","match","String","fromCharCode","parseInt","visitEvent","VisitRnSdkView","_ref","cpsid","baseUrl","errorBaseUrl","token","moduleName","environment","magicLink","isLoggingEnabled","source","setSource","useState","loading","setLoading","useEffect","_magicLink$trim","trim","length","systemVersion","DeviceInfo","getSystemVersion","version","getVersion","getUniqueId","then","uniqueId","getWebViewLink","res","_res$data","data","errorMessage","_res$data2","_res$data3","errorUrl","EventRegister","emitEvent","message","includes","_res$data4","magicCode","finalBaseUrl","toUpperCase","constants","PROD_BASE_URL","STAGE_BASE_URL","finalUrl","catch","err","console","log","finally","VisitRnSdkViewManager","useMemo","NativeModules","Proxy","Error","webviewRef","useRef","apiBaseUrl","setApiBaseUrl","authToken","setAuthToken","hasLoadedOnce","setHasLoadedOnce","callSyncApi","useCallback","httpClient","post","headers","Authorization","callEmbellishApi","apiManagerEmitter","NativeEventEmitter","subscription","addListener","reminder","_reminder$callSyncDat","_reminder$callEmbelli","callSyncData","remove","handleMessage","event","_webviewRef$current","_webviewRef$current6","JSON","parse","nativeEvent","method","type","frequency","timestamp","authtoken","googleFitLastSync","gfHourlyLastSync","url","current","injectJavaScript","getModel","_webviewRef$current2","connectToAppleHealth","sleepTime","numberOfSteps","_webviewRef$current3","_webviewRef$current4","renderGraph","results","_webviewRef$current5","updateApiUrl","Linking","openURL","height","width","Dimensions","createElement","SafeAreaView","style","flex","backgroundColor","LoadingIndicator","WebView","ref","uri","styles","webView","javascriptEnabled","onMessage","onError","warn","StyleSheet","create","webViewContainer","defaultProps","id","_default","exports","ActivityIndicator","color","size","zIndex","position","opacity","justifyContent","alignItems"],"sourceRoot":"../../src","sources":["index.ios.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,0BAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAF,sBAAA,CAAAL,OAAA;AAAoC,SAAAK,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAb,wBAAAS,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAAW,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,c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EAAC,MAAM;IACZC,IAAI,EAAC,OAAO;IACZtB,KAAK,EAAE;MACLC,IAAI,EAAE,CAAC;MACPsB,MAAM,EAAE,GAAG;MACXC,QAAQ,EAAE,UAAU;MACpBtB,eAAe,EAAE,MAAM;MACvBuB,OAAO,EAAE,GAAG;MACZ7B,KAAK,EAAE,MAAM;MACbD,MAAM,EAAE,MAAM;MACd+B,cAAc,EAAE,QAAQ;MACxBC,UAAU,EAAE;IACd;EAAE,CACH,CAAC;AAEN,CAAC"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeEventListeners","_reactNativeWebview","_reactNativeDeviceInfo","_interopRequireDefault","_Services","_constants","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","LINKING_ERROR","Platform","select","ios","escapeChars","lt","gt","quot","apos","amp","unescapeHTML","str","replace","entity","entityCode","match","String","fromCharCode","parseInt","visitEvent","VisitRnSdkView","_ref","cpsid","baseUrl","errorBaseUrl","token","moduleName","environment","magicLink","isLoggingEnabled","source","setSource","useState","loading","setLoading","useEffect","_magicLink$trim","trim","length","systemVersion","DeviceInfo","getSystemVersion","version","getVersion","getUniqueId","then","uniqueId","getWebViewLink","res","_res$data","data","errorMessage","_res$data2","_res$data3","errorUrl","EventRegister","emitEvent","message","includes","_res$data4","_res$data5","magicCode","responseReferenceId","finalBaseUrl","toUpperCase","constants","PROD_BASE_URL","STAGE_BASE_URL","finalUrl","catch","err","console","log","finally","VisitRnSdkViewManager","useMemo","NativeModules","Proxy","Error","webviewRef","useRef","apiBaseUrl","setApiBaseUrl","authToken","setAuthToken","hasLoadedOnce","setHasLoadedOnce","callSyncApi","useCallback","httpClient","post","headers","Authorization","callEmbellishApi","apiManagerEmitter","NativeEventEmitter","subscription","addListener","reminder","_reminder$callSyncDat","_reminder$callEmbelli","callSyncData","remove","handleMessage","event","_webviewRef$current","_webviewRef$current6","JSON","parse","nativeEvent","method","type","frequency","timestamp","authtoken","googleFitLastSync","gfHourlyLastSync","url","current","injectJavaScript","getModel","_webviewRef$current2","connectToAppleHealth","sleepTime","numberOfSteps","_webviewRef$current3","_webviewRef$current4","renderGraph","results","_webviewRef$current5","updateApiUrl","Linking","openURL","height","width","Dimensions","createElement","SafeAreaView","style","flex","backgroundColor","LoadingIndicator","WebView","ref","uri","styles","webView","javascriptEnabled","onMessage","onError","warn","StyleSheet","create","webViewContainer","defaultProps","id","_default","exports","ActivityIndicator","color","size","zIndex","position","opacity","justifyContent","alignItems"],"sourceRoot":"../../src","sources":["index.ios.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,0BAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAF,sBAAA,CAAAL,OAAA;AAAoC,SAAAK,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAb,wBAAAS,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WA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C;EACDM,OAAO,EAAE;IACPP,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAEFvH,cAAc,CAACsI,YAAY,GAAG;EAC5BC,EAAE,EAAE,EAAE;EACNlI,KAAK,EAAE,EAAE;EACTF,OAAO,EAAE,EAAE;EACXC,YAAY,EAAE,EAAE;EAChBE,UAAU,EAAE;AACd,CAAC;AAAC,IAAAkI,QAAA,GAEaxI,cAAc;AAAAyI,OAAA,CAAAjL,OAAA,GAAAgL,QAAA;AAE7B,MAAMf,gBAAgB,GAAGA,CAAA,KAAM;EAC7B,oBACE7K,MAAA,CAAAY,OAAA,CAAA4J,aAAA,CAACrK,YAAA,CAAA2L,iBAAiB;IAChBC,KAAK,EAAC,MAAM;IACZC,IAAI,EAAC;IACL;IAAA;IACAtB,KAAK,EAAE;MACLC,IAAI,EAAE,CAAC;MACPsB,MAAM,EAAE,GAAG;MACXC,QAAQ,EAAE,UAAU;MACpBtB,eAAe,EAAE,MAAM;MACvBuB,OAAO,EAAE,GAAG;MACZ7B,KAAK,EAAE,MAAM;MACbD,MAAM,EAAE,MAAM;MACd+B,cAAc,EAAE,QAAQ;MACxBC,UAAU,EAAE;IACd;EAAE,CACH,CAAC;AAEN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["axios","httpClient","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,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,MAAMC,UAAU,GAAGD,KAAK,CAACE,MAAM,CAAC;EACrCC,OAAO,EAAG;AACZ,CAAC,CAAC;AAEF,OAAO,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,OAAOX,UAAU,CACda,IAAI,CAAE,GAAET,OAAQ,8CAA6C,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"}
1
+ {"version":3,"names":["axios","httpClient","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,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,MAAMC,UAAU,GAAGD,KAAK,CAACE,MAAM,CAAC;EACrCC,OAAO,EAAE;AACX,CAAC,CAAC;AAEF,OAAO,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,OAAOX,UAAU,CACda,IAAI,CAAE,GAAET,OAAQ,8CAA6C,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"}
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, useEffect, useState, useCallback } from 'react';
2
2
  import { EventRegister } from 'react-native-event-listeners';
3
- import { SafeAreaView, NativeModules, PermissionsAndroid, BackHandler, Linking, Alert } from 'react-native';
3
+ import { SafeAreaView, NativeModules, PermissionsAndroid, BackHandler, Linking, Alert, AppState } from 'react-native';
4
4
  import WebView from 'react-native-webview';
5
5
  import LocationEnabler from 'react-native-location-enabler';
6
6
  import DeviceInfo from 'react-native-device-info';
@@ -28,9 +28,14 @@ const VisitRnSdkView = _ref => {
28
28
  isLoggingEnabled
29
29
  } = _ref;
30
30
  const [source, setSource] = useState('');
31
+ const [appState, setAppState] = useState(AppState.currentState);
31
32
  const [showPermissionAlreadyDeniedDialog, setShowPermissionAlreadyDeniedDialog] = useState(false);
32
33
  useEffect(() => {
33
34
  var _magicLink$trim;
35
+ if (isLoggingEnabled) {
36
+ console.log('useEffect ran');
37
+ }
38
+ NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
34
39
  if (((magicLink === null || magicLink === void 0 || (_magicLink$trim = magicLink.trim()) === null || _magicLink$trim === void 0 ? void 0 : _magicLink$trim.length) || 0) > 0) {
35
40
  setSource(magicLink);
36
41
  } else {
@@ -56,8 +61,9 @@ const VisitRnSdkView = _ref => {
56
61
  }).then(response => {
57
62
  let data = response.data;
58
63
  // let visitMagicLink = data.result; //@Deprecated. Superseded by magic code usage.
59
- let errorMessage = data.errorMessage;
60
- let magicCode = data.magicCode;
64
+ const errorMessage = data.errorMessage;
65
+ const magicCode = data.magicCode;
66
+ const responseReferenceId = data.responseReferenceId;
61
67
  let finalBaseUrl = '';
62
68
  if (environment.toUpperCase() === 'PROD') {
63
69
  finalBaseUrl = constants.PROD_BASE_URL;
@@ -70,6 +76,9 @@ const VisitRnSdkView = _ref => {
70
76
  if (((moduleName === null || moduleName === void 0 || (_moduleName$trim = moduleName.trim()) === null || _moduleName$trim === void 0 ? void 0 : _moduleName$trim.length) || 0) > 0) {
71
77
  finalUrl += `&tab=${moduleName}`;
72
78
  }
79
+ if (typeof responseReferenceId === 'string' && responseReferenceId.trim().length > 0) {
80
+ finalUrl += `&responseReferenceId=${responseReferenceId}`;
81
+ }
73
82
  if (isLoggingEnabled) {
74
83
  console.log('magicLink: ' + finalUrl);
75
84
  }
@@ -118,6 +127,29 @@ const VisitRnSdkView = _ref => {
118
127
  });
119
128
  }
120
129
  }, [cpsid, token, baseUrl, errorBaseUrl, moduleName, environment, magicLink, isLoggingEnabled]);
130
+ useEffect(() => {
131
+ const subscription = AppState.addEventListener('change', handleAppStateChange);
132
+ console.log(`AppState.addEventListener added, current state: ${appState}`);
133
+ return () => {
134
+ subscription.remove();
135
+ };
136
+ }, [appState]); // Include appState in the dependency array to ensure it's up to date.
137
+
138
+ const handleAppStateChange = nextAppState => {
139
+ // console.log(
140
+ // "nextAppState: " + nextAppState + ", previousState: " + appState
141
+ // );
142
+
143
+ // Instead of relying on the old appState, use the nextAppState directly
144
+ if (appState.match(/inactive|background/) && nextAppState === 'active') {
145
+ if (isLoggingEnabled) {
146
+ console.log('App has come to the foreground!');
147
+ }
148
+ getHealthConnectStatus();
149
+ }
150
+ setAppState(nextAppState); // Update the state with the new app state
151
+ };
152
+
121
153
  const [enabled, requestResolution] = useLocationSettings({
122
154
  priority: HIGH_ACCURACY,
123
155
  // default BALANCED_POWER_ACCURACY
@@ -127,26 +159,6 @@ const VisitRnSdkView = _ref => {
127
159
  }, false /* optional: default undefined */);
128
160
 
129
161
  const webviewRef = useRef(null);
130
- const requestActivityRecognitionPermission = async () => {
131
- console.log('inside requestActivityRecognitionPermission()');
132
- try {
133
- const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACTIVITY_RECOGNITION, {
134
- title: 'Need Activity Recognition Permission',
135
- message: 'This needs access to your Fitness Permission',
136
- buttonNeutral: 'Ask Me Later',
137
- buttonNegative: 'Cancel',
138
- buttonPositive: 'OK'
139
- });
140
- if (granted === PermissionsAndroid.RESULTS.GRANTED) {
141
- console.log('ACTIVITY_RECOGNITION granted');
142
- askForGoogleFitPermission();
143
- } else {
144
- console.log('Fitness permission denied');
145
- }
146
- } catch (err) {
147
- console.warn(err);
148
- }
149
- };
150
162
  const showLocationPermissionAlert = () => {
151
163
  Alert.alert('Permission Required', 'Allow location permission from app settings', [{
152
164
  text: 'Cancel',
@@ -162,14 +174,14 @@ const VisitRnSdkView = _ref => {
162
174
  };
163
175
  const requestLocationPermission = async () => {
164
176
  try {
165
- console.log("requestLocationPermission called");
177
+ console.log('requestLocationPermission called');
166
178
  const isLocationPermissionPresent = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
167
- console.log("isLocationPermissionPresent: " + isLocationPermissionPresent + " showPermissionAlreadyDeniedDialog: " + showPermissionAlreadyDeniedDialog);
179
+ console.log('isLocationPermissionPresent: ' + isLocationPermissionPresent + ' showPermissionAlreadyDeniedDialog: ' + showPermissionAlreadyDeniedDialog);
168
180
  if (!isLocationPermissionPresent && showPermissionAlreadyDeniedDialog) {
169
- console.log("showLocationPermissionAlert() called");
181
+ console.log('showLocationPermissionAlert() called');
170
182
  showLocationPermissionAlert();
171
183
  } else {
172
- console.log("requesting location permission");
184
+ console.log('requesting location permission');
173
185
  const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
174
186
  title: 'Need Location Permission',
175
187
  message: 'Need access to location permission',
@@ -178,7 +190,9 @@ const VisitRnSdkView = _ref => {
178
190
  buttonPositive: 'OK'
179
191
  });
180
192
  if (granted === PermissionsAndroid.RESULTS.GRANTED) {
181
- console.log('Location permission granted');
193
+ if (isLoggingEnabled) {
194
+ console.log('Location permission granted');
195
+ }
182
196
  setShowPermissionAlreadyDeniedDialog(false);
183
197
  if (!enabled) {
184
198
  requestResolution();
@@ -197,37 +211,82 @@ const VisitRnSdkView = _ref => {
197
211
  console.error(e);
198
212
  }
199
213
  };
200
- const askForGoogleFitPermission = async () => {
214
+ const askForHealthConnectPermission = async () => {
201
215
  try {
202
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
203
216
  const isPermissionGranted = await NativeModules.VisitFitnessModule.askForFitnessPermission();
204
- if (isPermissionGranted == 'GRANTED') {
217
+ if (isLoggingEnabled) {
218
+ console.log('isPermissionGranted: ' + isPermissionGranted);
219
+ }
220
+ if (isPermissionGranted === 'GRANTED') {
205
221
  getDailyFitnessData();
206
222
  }
207
- console.log(`Google Fit Permissionl: ${isPermissionGranted}`);
208
223
  } catch (e) {
209
- console.error(e);
224
+ if (isLoggingEnabled) {
225
+ console.error(e);
226
+ }
210
227
  }
211
228
  };
212
- const getDailyFitnessData = () => {
213
- console.log('getDailyFitnessData() called');
214
- NativeModules.VisitFitnessModule.requestDailyFitnessData(data => {
215
- var _webviewRef$current2;
216
- // console.log(`getDailyFitnessData() data: ` + data);
217
- (_webviewRef$current2 = webviewRef.current) === null || _webviewRef$current2 === void 0 || _webviewRef$current2.injectJavaScript(data);
218
- });
229
+ const getHealthConnectStatus = async () => {
230
+ try {
231
+ const healthConnectStatus = await NativeModules.VisitFitnessModule.getHealthConnectStatus();
232
+ if (isLoggingEnabled) {
233
+ console.log('getHealthConnectStatus: ' + healthConnectStatus);
234
+ }
235
+ if (healthConnectStatus === 'NOT_SUPPORTED') {
236
+ var _webviewRef$current2;
237
+ (_webviewRef$current2 = webviewRef.current) === null || _webviewRef$current2 === void 0 || _webviewRef$current2.injectJavaScript('window.healthConnectNotSupported()');
238
+ } else if (healthConnectStatus === 'NOT_INSTALLED') {
239
+ var _webviewRef$current3, _webviewRef$current4;
240
+ (_webviewRef$current3 = webviewRef.current) === null || _webviewRef$current3 === void 0 || _webviewRef$current3.injectJavaScript('window.healthConnectNotInstall()');
241
+ (_webviewRef$current4 = webviewRef.current) === null || _webviewRef$current4 === void 0 || _webviewRef$current4.injectJavaScript('window.updateFitnessPermissions(false,0,0)');
242
+ } else if (healthConnectStatus === 'INSTALLED') {
243
+ var _webviewRef$current5, _webviewRef$current6;
244
+ (_webviewRef$current5 = webviewRef.current) === null || _webviewRef$current5 === void 0 || _webviewRef$current5.injectJavaScript('window.healthConnectAvailable()');
245
+ (_webviewRef$current6 = webviewRef.current) === null || _webviewRef$current6 === void 0 || _webviewRef$current6.injectJavaScript('window.updateFitnessPermissions(false,0,0)');
246
+ } else if (healthConnectStatus === 'CONNECTED') {
247
+ //don't do anything here because it is responsibility of askForHealthConnectPermission
248
+ }
249
+ } catch (e) {
250
+ if (isLoggingEnabled) {
251
+ console.error(e);
252
+ }
253
+ }
219
254
  };
220
- const requestActivityData = (type, frequency, timeStamp) => {
221
- console.log('requestActivityData() called');
222
- NativeModules.VisitFitnessModule.requestActivityDataFromGoogleFit(type, frequency, timeStamp, data => {
223
- var _webviewRef$current3;
224
- // console.log(`requestActivityData() data: ` + data);
225
- (_webviewRef$current3 = webviewRef.current) === null || _webviewRef$current3 === void 0 || _webviewRef$current3.injectJavaScript('window.' + data);
226
- });
255
+ const getDailyFitnessData = async () => {
256
+ if (isLoggingEnabled) {
257
+ console.log('getDailyFitnessData() called');
258
+ }
259
+ try {
260
+ var _webviewRef$current7;
261
+ const dailyFitnessData = await NativeModules.VisitFitnessModule.requestDailyFitnessData();
262
+ (_webviewRef$current7 = webviewRef.current) === null || _webviewRef$current7 === void 0 || _webviewRef$current7.injectJavaScript(dailyFitnessData);
263
+ } catch (error) {
264
+ if (isLoggingEnabled) {
265
+ console.log(error);
266
+ }
267
+ }
268
+ };
269
+ const requestActivityData = async (type, frequency, timeStamp) => {
270
+ if (isLoggingEnabled) {
271
+ console.log('requestActivityData() called');
272
+ }
273
+ try {
274
+ var _webviewRef$current8;
275
+ const graphData = await NativeModules.VisitFitnessModule.requestActivityDataFromHealthConnect(type, frequency, timeStamp);
276
+ if (isLoggingEnabled) {
277
+ console.log(`requestActivityData() data: ` + graphData);
278
+ }
279
+ (_webviewRef$current8 = webviewRef.current) === null || _webviewRef$current8 === void 0 || _webviewRef$current8.injectJavaScript('window.' + graphData);
280
+ } catch (error) {
281
+ if (isLoggingEnabled) {
282
+ console.log(error);
283
+ }
284
+ }
227
285
  };
228
286
  const updateApiBaseUrl = (apiBaseUrl, authtoken, googleFitLastSync, gfHourlyLastSync) => {
229
- console.log('updateApiBaseUrl() called.');
230
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
287
+ if (isLoggingEnabled) {
288
+ console.log('updateApiBaseUrl() called.');
289
+ }
231
290
  NativeModules.VisitFitnessModule.updateApiBaseUrl(apiBaseUrl, authtoken, googleFitLastSync, gfHourlyLastSync);
232
291
  };
233
292
  const runBeforeFirst = `
@@ -237,22 +296,23 @@ const VisitRnSdkView = _ref => {
237
296
  true; // note: this is required, or you'll sometimes get silent failures
238
297
  `;
239
298
  const handleMessage = event => {
240
- var _webviewRef$current4;
299
+ var _webviewRef$current9;
241
300
  if (event.nativeEvent.data != null) {
242
301
  try {
243
- // console.log("Event :"+event.nativeEvent.data);
302
+ if (isLoggingEnabled) {
303
+ // console.log('Event :' + event.nativeEvent.data);
304
+ }
244
305
  const parsedObject = JSON.parse(event.nativeEvent.data);
245
306
  if (parsedObject.method != null) {
246
307
  switch (parsedObject.method) {
308
+ case 'GET_HEALTH_CONNECT_STATUS':
309
+ getHealthConnectStatus();
310
+ break;
247
311
  case 'CONNECT_TO_GOOGLE_FIT':
248
- if (parseInt(DeviceInfo.getSystemVersion(), 10) >= 10) {
249
- requestActivityRecognitionPermission();
250
- } else {
251
- askForGoogleFitPermission();
252
- }
312
+ askForHealthConnectPermission();
253
313
  break;
254
314
  case 'UPDATE_PLATFORM':
255
- (_webviewRef$current4 = webviewRef.current) === null || _webviewRef$current4 === void 0 || _webviewRef$current4.injectJavaScript('window.setSdkPlatform("ANDROID")');
315
+ (_webviewRef$current9 = webviewRef.current) === null || _webviewRef$current9 === void 0 || _webviewRef$current9.injectJavaScript('window.setSdkPlatform("ANDROID")');
256
316
  break;
257
317
  case 'UPDATE_API_BASE_URL':
258
318
  {
@@ -260,7 +320,9 @@ const VisitRnSdkView = _ref => {
260
320
  let authtoken = parsedObject.authtoken;
261
321
  let googleFitLastSync = parsedObject.googleFitLastSync;
262
322
  let gfHourlyLastSync = parsedObject.gfHourlyLastSync;
263
- console.log('apiBaseUrl: ' + 'NOT SHOWN' + ' authtoken: ' + 'NOT SHOWN' + ' googleFitLastSync: ' + googleFitLastSync + ' gfHourlyLastSync: ' + gfHourlyLastSync);
323
+ if (isLoggingEnabled) {
324
+ console.log('apiBaseUrl: ' + 'NOT SHOWN' + ' authtoken: ' + 'NOT SHOWN' + ' googleFitLastSync: ' + googleFitLastSync + ' gfHourlyLastSync: ' + gfHourlyLastSync);
325
+ }
264
326
  updateApiBaseUrl(apiBaseUrl, authtoken, googleFitLastSync, gfHourlyLastSync);
265
327
  }
266
328
  break;
@@ -269,15 +331,15 @@ const VisitRnSdkView = _ref => {
269
331
  let type = parsedObject.type;
270
332
  let frequency = parsedObject.frequency;
271
333
  let timeStamp = parsedObject.timestamp;
272
- console.log('type: ' + type + ' frequency:' + frequency + ' timeStamp: ' + timeStamp);
334
+ if (isLoggingEnabled) {
335
+ console.log('type: ' + type + ' frequency:' + frequency + ' timeStamp: ' + timeStamp);
336
+ }
273
337
  requestActivityData(type, frequency, timeStamp);
274
338
  }
275
339
  break;
276
340
  case 'GET_LOCATION_PERMISSIONS':
277
- {
278
- console.log("GET_LOCATION_PERMISSIONS");
279
- requestLocationPermission();
280
- }
341
+ console.log('GET_LOCATION_PERMISSIONS');
342
+ requestLocationPermission();
281
343
  break;
282
344
  case 'OPEN_PDF':
283
345
  {
@@ -288,7 +350,6 @@ const VisitRnSdkView = _ref => {
288
350
  }
289
351
  break;
290
352
  case 'CLOSE_VIEW':
291
- {}
292
353
  break;
293
354
  default:
294
355
  break;
@@ -302,8 +363,8 @@ const VisitRnSdkView = _ref => {
302
363
  const [canGoBack, setCanGoBack] = useState(false);
303
364
  const handleBack = useCallback(() => {
304
365
  if (canGoBack && webviewRef.current) {
305
- var _webviewRef$current5;
306
- (_webviewRef$current5 = webviewRef.current) === null || _webviewRef$current5 === void 0 || _webviewRef$current5.goBack();
366
+ var _webviewRef$current10;
367
+ (_webviewRef$current10 = webviewRef.current) === null || _webviewRef$current10 === void 0 || _webviewRef$current10.goBack();
307
368
  return true;
308
369
  }
309
370
  return false;
@@ -325,45 +386,50 @@ const VisitRnSdkView = _ref => {
325
386
  }, [handleBack]);
326
387
  const checkLocationPermissionAndSendCallback = async () => {
327
388
  const isLocationPermissionAvailable = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
328
- console.log("checkLocationPermissionAndSendCallback() isLocationPermissionAvailable: " + isLocationPermissionAvailable + "isGPSPermissionAvailabe: true");
389
+ if (isLoggingEnabled) {
390
+ console.log('checkLocationPermissionAndSendCallback() isLocationPermissionAvailable: ' + isLocationPermissionAvailable + 'isGPSPermissionAvailabe: true');
391
+ }
329
392
  if (isLocationPermissionAvailable) {
330
- var _webviewRef$current6;
393
+ var _webviewRef$current11;
331
394
  var finalString = `window.checkTheGpsPermission(true)`;
332
395
  console.log('listener: ' + finalString);
333
- (_webviewRef$current6 = webviewRef.current) === null || _webviewRef$current6 === void 0 || _webviewRef$current6.injectJavaScript(finalString);
396
+ (_webviewRef$current11 = webviewRef.current) === null || _webviewRef$current11 === void 0 || _webviewRef$current11.injectJavaScript(finalString);
334
397
  }
335
398
  };
336
- return /*#__PURE__*/React.createElement(SafeAreaView, {
337
- style: {
338
- flex: 1
339
- }
340
- }, source ? /*#__PURE__*/React.createElement(WebView, {
341
- ref: webviewRef,
342
- source: {
343
- uri: source,
344
- headers: {
345
- platform: 'ANDROID'
399
+ return (
400
+ /*#__PURE__*/
401
+ // eslint-disable-next-line react-native/no-inline-styles
402
+ React.createElement(SafeAreaView, {
403
+ style: {
404
+ flex: 1
346
405
  }
347
- },
348
- onMessage: handleMessage,
349
- injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
350
- javaScriptEnabled: true,
351
- onLoadProgress: event => setCanGoBack(event.nativeEvent.canGoBack),
352
- onError: errorMessage => {
353
- EventRegister.emitEvent('visit-event', {
354
- message: 'web-view-error',
355
- errorMessage: errorMessage
356
- });
357
- if (isLoggingEnabled) {
358
- console.warn('Webview error: ', errorMessage);
406
+ }, source ? /*#__PURE__*/React.createElement(WebView, {
407
+ ref: webviewRef,
408
+ source: {
409
+ uri: source,
410
+ headers: {
411
+ platform: 'ANDROID'
412
+ }
413
+ },
414
+ onMessage: handleMessage,
415
+ injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
416
+ javaScriptEnabled: true,
417
+ onLoadProgress: event => setCanGoBack(event.nativeEvent.canGoBack),
418
+ onError: errorMessage => {
419
+ EventRegister.emitEvent('visit-event', {
420
+ message: 'web-view-error',
421
+ errorMessage: errorMessage
422
+ });
423
+ if (isLoggingEnabled) {
424
+ console.warn('Webview error: ', errorMessage);
425
+ }
359
426
  }
360
- }
361
- }) : null);
427
+ }) : null)
428
+ );
362
429
  };
363
430
  export const fetchDailyFitnessData = (startTimeStamp, isLoggingEnabled) => {
364
431
  return new Promise((resolve, reject) => {
365
432
  console.log('fetchDailyFitnessData called: ' + startTimeStamp);
366
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
367
433
  NativeModules.VisitFitnessModule.fetchDailyFitnessData(startTimeStamp).then(result => {
368
434
  resolve(result);
369
435
  }).catch(err => reject(err));
@@ -371,13 +437,39 @@ export const fetchDailyFitnessData = (startTimeStamp, isLoggingEnabled) => {
371
437
  };
372
438
  export const fetchHourlyFitnessData = (startTimeStamp, isLoggingEnabled) => {
373
439
  return new Promise((resolve, reject) => {
374
- console.log('fetchHourlyFitnessData called: ' + startTimeStamp);
375
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
440
+ if (isLoggingEnabled) {
441
+ console.log('fetchHourlyFitnessData called: ' + startTimeStamp);
442
+ }
376
443
  NativeModules.VisitFitnessModule.fetchHourlyFitnessData(startTimeStamp).then(result => {
377
444
  resolve(result);
378
445
  }).catch(err => reject(err));
379
446
  });
380
447
  };
448
+
449
+ // debounce, deferred
450
+ // function debounce(task, ms) {
451
+ // let t = { promise: null, cancel: (_) => void 0 };
452
+ // return async (...args) => {
453
+ // try {
454
+ // t.cancel();
455
+ // t = deferred(ms);
456
+ // await t.promise;
457
+ // await task(...args);
458
+ // } catch (_) {
459
+ // console.log('cleaning up cancelled promise');
460
+ // }
461
+ // };
462
+ // }
463
+
464
+ // function deferred(ms) {
465
+ // let cancel,
466
+ // promise = new Promise((resolve, reject) => {
467
+ // cancel = reject;
468
+ // setTimeout(resolve, ms);
469
+ // });
470
+ // return { promise, cancel };
471
+ // }
472
+
381
473
  export default VisitRnSdkView;
382
474
  VisitRnSdkView.defaultProps = {
383
475
  cpsid: '',