react-native-visit-rn-sdk 0.4.8 → 0.4.10

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 } from 'react-native';
3
+ import { SafeAreaView, NativeModules, PermissionsAndroid, BackHandler, Linking, Alert } 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,8 +28,13 @@ const VisitRnSdkView = _ref => {
28
28
  isLoggingEnabled
29
29
  } = _ref;
30
30
  const [source, setSource] = useState('');
31
+ const [showPermissionAlreadyDeniedDialog, setShowPermissionAlreadyDeniedDialog] = useState(false);
31
32
  useEffect(() => {
32
33
  var _magicLink$trim;
34
+ if (isLoggingEnabled) {
35
+ console.log('useEffect ran');
36
+ }
37
+ NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
33
38
  if (((magicLink === null || magicLink === void 0 || (_magicLink$trim = magicLink.trim()) === null || _magicLink$trim === void 0 ? void 0 : _magicLink$trim.length) || 0) > 0) {
34
39
  setSource(magicLink);
35
40
  } else {
@@ -55,8 +60,9 @@ const VisitRnSdkView = _ref => {
55
60
  }).then(response => {
56
61
  let data = response.data;
57
62
  // let visitMagicLink = data.result; //@Deprecated. Superseded by magic code usage.
58
- let errorMessage = data.errorMessage;
59
- let magicCode = data.magicCode;
63
+ const errorMessage = data.errorMessage;
64
+ const magicCode = data.magicCode;
65
+ const responseReferenceId = data.responseReferenceId;
60
66
  let finalBaseUrl = '';
61
67
  if (environment.toUpperCase() === 'PROD') {
62
68
  finalBaseUrl = constants.PROD_BASE_URL;
@@ -69,6 +75,9 @@ const VisitRnSdkView = _ref => {
69
75
  if (((moduleName === null || moduleName === void 0 || (_moduleName$trim = moduleName.trim()) === null || _moduleName$trim === void 0 ? void 0 : _moduleName$trim.length) || 0) > 0) {
70
76
  finalUrl += `&tab=${moduleName}`;
71
77
  }
78
+ if (typeof responseReferenceId === 'string' && responseReferenceId.trim().length > 0) {
79
+ finalUrl += `&responseReferenceId=${responseReferenceId}`;
80
+ }
72
81
  if (isLoggingEnabled) {
73
82
  console.log('magicLink: ' + finalUrl);
74
83
  }
@@ -126,83 +135,130 @@ const VisitRnSdkView = _ref => {
126
135
  }, false /* optional: default undefined */);
127
136
 
128
137
  const webviewRef = useRef(null);
129
- const requestActivityRecognitionPermission = async () => {
130
- console.log('inside requestActivityRecognitionPermission()');
131
- try {
132
- const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACTIVITY_RECOGNITION, {
133
- title: 'Need Activity Recognition Permission',
134
- message: 'This needs access to your Fitness Permission',
135
- buttonNeutral: 'Ask Me Later',
136
- buttonNegative: 'Cancel',
137
- buttonPositive: 'OK'
138
- });
139
- if (granted === PermissionsAndroid.RESULTS.GRANTED) {
140
- console.log('ACTIVITY_RECOGNITION granted');
141
- askForGoogleFitPermission();
142
- } else {
143
- console.log('Fitness permission denied');
138
+ const showLocationPermissionAlert = () => {
139
+ Alert.alert('Permission Required', 'Allow location permission from app settings', [{
140
+ text: 'Cancel',
141
+ onPress: () => {
142
+ console.log('Cancel clicked');
144
143
  }
145
- } catch (err) {
146
- console.warn(err);
147
- }
144
+ }, {
145
+ text: 'Go to Settings',
146
+ onPress: () => {
147
+ Linking.openSettings();
148
+ }
149
+ }]);
148
150
  };
149
151
  const requestLocationPermission = async () => {
150
152
  try {
151
- const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
152
- title: 'Need Location Permission',
153
- message: 'Need access to location permission',
154
- buttonNeutral: 'Ask Me Later',
155
- buttonNegative: 'Cancel',
156
- buttonPositive: 'OK'
157
- });
158
- if (granted === PermissionsAndroid.RESULTS.GRANTED) {
159
- console.log('Location permission granted');
160
- if (!enabled) {
161
- requestResolution();
153
+ console.log('requestLocationPermission called');
154
+ const isLocationPermissionPresent = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
155
+ console.log('isLocationPermissionPresent: ' + isLocationPermissionPresent + ' showPermissionAlreadyDeniedDialog: ' + showPermissionAlreadyDeniedDialog);
156
+ if (!isLocationPermissionPresent && showPermissionAlreadyDeniedDialog) {
157
+ console.log('showLocationPermissionAlert() called');
158
+ showLocationPermissionAlert();
159
+ } else {
160
+ console.log('requesting location permission');
161
+ const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
162
+ title: 'Need Location Permission',
163
+ message: 'Need access to location permission',
164
+ buttonNeutral: 'Ask Me Later',
165
+ buttonNegative: 'Cancel',
166
+ buttonPositive: 'OK'
167
+ });
168
+ if (granted === PermissionsAndroid.RESULTS.GRANTED) {
169
+ if (isLoggingEnabled) {
170
+ console.log('Location permission granted');
171
+ }
172
+ setShowPermissionAlreadyDeniedDialog(false);
173
+ if (!enabled) {
174
+ requestResolution();
175
+ } else {
176
+ var _webviewRef$current;
177
+ var finalString = `window.checkTheGpsPermission(true)`;
178
+ console.log('requestLocationPermission: ' + finalString);
179
+ (_webviewRef$current = webviewRef.current) === null || _webviewRef$current === void 0 || _webviewRef$current.injectJavaScript(finalString);
180
+ }
162
181
  } else {
163
- var _webviewRef$current;
164
- var finalString = `window.checkTheGpsPermission(true)`;
165
- console.log('requestLocationPermission: ' + finalString);
166
- (_webviewRef$current = webviewRef.current) === null || _webviewRef$current === void 0 || _webviewRef$current.injectJavaScript(finalString);
182
+ setShowPermissionAlreadyDeniedDialog(true);
183
+ console.log('Location permission denied');
167
184
  }
168
- } else {
169
- console.log('Location permission denied');
170
185
  }
171
186
  } catch (e) {
172
187
  console.error(e);
173
188
  }
174
189
  };
175
- const askForGoogleFitPermission = async () => {
190
+ const askForHealthConnectPermission = async () => {
176
191
  try {
177
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
178
192
  const isPermissionGranted = await NativeModules.VisitFitnessModule.askForFitnessPermission();
179
- if (isPermissionGranted == 'GRANTED') {
193
+ if (isLoggingEnabled) {
194
+ console.log('isPermissionGranted: ' + isPermissionGranted);
195
+ }
196
+ if (isPermissionGranted === 'GRANTED') {
180
197
  getDailyFitnessData();
181
198
  }
182
- console.log(`Google Fit Permissionl: ${isPermissionGranted}`);
183
199
  } catch (e) {
184
- console.error(e);
200
+ if (isLoggingEnabled) {
201
+ console.error(e);
202
+ }
185
203
  }
186
204
  };
187
- const getDailyFitnessData = () => {
188
- console.log('getDailyFitnessData() called');
189
- NativeModules.VisitFitnessModule.requestDailyFitnessData(data => {
190
- var _webviewRef$current2;
191
- // console.log(`getDailyFitnessData() data: ` + data);
192
- (_webviewRef$current2 = webviewRef.current) === null || _webviewRef$current2 === void 0 || _webviewRef$current2.injectJavaScript(data);
193
- });
205
+ const getHealthConnectStatus = async () => {
206
+ try {
207
+ const healthConnectStatus = await NativeModules.VisitFitnessModule.getHealthConnectStatus();
208
+ if (isLoggingEnabled) {
209
+ console.log('getHealthConnectStatus: ' + healthConnectStatus);
210
+ }
211
+ if (healthConnectStatus === 'NOT_SUPPORTED') {
212
+ var _webviewRef$current2;
213
+ (_webviewRef$current2 = webviewRef.current) === null || _webviewRef$current2 === void 0 || _webviewRef$current2.injectJavaScript('window.healthConnectNotSupported()');
214
+ } else if (healthConnectStatus === 'NOT_INSTALLED') {
215
+ var _webviewRef$current3;
216
+ (_webviewRef$current3 = webviewRef.current) === null || _webviewRef$current3 === void 0 || _webviewRef$current3.injectJavaScript('window.healthConnectNotInstall()');
217
+ } else if (healthConnectStatus === 'INSTALLED') {
218
+ var _webviewRef$current4;
219
+ (_webviewRef$current4 = webviewRef.current) === null || _webviewRef$current4 === void 0 || _webviewRef$current4.injectJavaScript('window.healthConnectAvailable()');
220
+ }
221
+ } catch (e) {
222
+ if (isLoggingEnabled) {
223
+ console.error(e);
224
+ }
225
+ }
194
226
  };
195
- const requestActivityData = (type, frequency, timeStamp) => {
196
- console.log('requestActivityData() called');
197
- NativeModules.VisitFitnessModule.requestActivityDataFromGoogleFit(type, frequency, timeStamp, data => {
198
- var _webviewRef$current3;
199
- // console.log(`requestActivityData() data: ` + data);
200
- (_webviewRef$current3 = webviewRef.current) === null || _webviewRef$current3 === void 0 || _webviewRef$current3.injectJavaScript('window.' + data);
201
- });
227
+ const getDailyFitnessData = async () => {
228
+ if (isLoggingEnabled) {
229
+ console.log('getDailyFitnessData() called');
230
+ }
231
+ try {
232
+ var _webviewRef$current5;
233
+ const dailyFitnessData = await NativeModules.VisitFitnessModule.requestDailyFitnessData();
234
+ (_webviewRef$current5 = webviewRef.current) === null || _webviewRef$current5 === void 0 || _webviewRef$current5.injectJavaScript(dailyFitnessData);
235
+ } catch (error) {
236
+ if (isLoggingEnabled) {
237
+ console.log(error);
238
+ }
239
+ }
240
+ };
241
+ const requestActivityData = async (type, frequency, timeStamp) => {
242
+ if (isLoggingEnabled) {
243
+ console.log('requestActivityData() called');
244
+ }
245
+ try {
246
+ var _webviewRef$current6;
247
+ const graphData = await NativeModules.VisitFitnessModule.requestActivityDataFromHealthConnect(type, frequency, timeStamp);
248
+ if (isLoggingEnabled) {
249
+ console.log(`requestActivityData() data: ` + graphData);
250
+ }
251
+ (_webviewRef$current6 = webviewRef.current) === null || _webviewRef$current6 === void 0 || _webviewRef$current6.injectJavaScript('window.' + graphData);
252
+ } catch (error) {
253
+ if (isLoggingEnabled) {
254
+ console.log(error);
255
+ }
256
+ }
202
257
  };
203
258
  const updateApiBaseUrl = (apiBaseUrl, authtoken, googleFitLastSync, gfHourlyLastSync) => {
204
- console.log('updateApiBaseUrl() called.');
205
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
259
+ if (isLoggingEnabled) {
260
+ console.log('updateApiBaseUrl() called.');
261
+ }
206
262
  NativeModules.VisitFitnessModule.updateApiBaseUrl(apiBaseUrl, authtoken, googleFitLastSync, gfHourlyLastSync);
207
263
  };
208
264
  const runBeforeFirst = `
@@ -212,22 +268,23 @@ const VisitRnSdkView = _ref => {
212
268
  true; // note: this is required, or you'll sometimes get silent failures
213
269
  `;
214
270
  const handleMessage = event => {
215
- var _webviewRef$current4;
271
+ var _webviewRef$current7;
216
272
  if (event.nativeEvent.data != null) {
217
273
  try {
218
- // console.log("Event :"+event.nativeEvent.data);
274
+ if (isLoggingEnabled) {
275
+ console.log('Event :' + event.nativeEvent.data);
276
+ }
219
277
  const parsedObject = JSON.parse(event.nativeEvent.data);
220
278
  if (parsedObject.method != null) {
221
279
  switch (parsedObject.method) {
280
+ case 'GET_HEALTH_CONNECT_STATUS':
281
+ getHealthConnectStatus();
282
+ break;
222
283
  case 'CONNECT_TO_GOOGLE_FIT':
223
- if (parseInt(DeviceInfo.getSystemVersion(), 10) >= 10) {
224
- requestActivityRecognitionPermission();
225
- } else {
226
- askForGoogleFitPermission();
227
- }
284
+ askForHealthConnectPermission();
228
285
  break;
229
286
  case 'UPDATE_PLATFORM':
230
- (_webviewRef$current4 = webviewRef.current) === null || _webviewRef$current4 === void 0 || _webviewRef$current4.injectJavaScript('window.setSdkPlatform("ANDROID")');
287
+ (_webviewRef$current7 = webviewRef.current) === null || _webviewRef$current7 === void 0 || _webviewRef$current7.injectJavaScript('window.setSdkPlatform("ANDROID")');
231
288
  break;
232
289
  case 'UPDATE_API_BASE_URL':
233
290
  {
@@ -235,7 +292,9 @@ const VisitRnSdkView = _ref => {
235
292
  let authtoken = parsedObject.authtoken;
236
293
  let googleFitLastSync = parsedObject.googleFitLastSync;
237
294
  let gfHourlyLastSync = parsedObject.gfHourlyLastSync;
238
- console.log('apiBaseUrl: ' + 'NOT SHOWN' + ' authtoken: ' + 'NOT SHOWN' + ' googleFitLastSync: ' + googleFitLastSync + ' gfHourlyLastSync: ' + gfHourlyLastSync);
295
+ if (isLoggingEnabled) {
296
+ console.log('apiBaseUrl: ' + 'NOT SHOWN' + ' authtoken: ' + 'NOT SHOWN' + ' googleFitLastSync: ' + googleFitLastSync + ' gfHourlyLastSync: ' + gfHourlyLastSync);
297
+ }
239
298
  updateApiBaseUrl(apiBaseUrl, authtoken, googleFitLastSync, gfHourlyLastSync);
240
299
  }
241
300
  break;
@@ -244,14 +303,15 @@ const VisitRnSdkView = _ref => {
244
303
  let type = parsedObject.type;
245
304
  let frequency = parsedObject.frequency;
246
305
  let timeStamp = parsedObject.timestamp;
247
- console.log('type: ' + type + ' frequency:' + frequency + ' timeStamp: ' + timeStamp);
306
+ if (isLoggingEnabled) {
307
+ console.log('type: ' + type + ' frequency:' + frequency + ' timeStamp: ' + timeStamp);
308
+ }
248
309
  requestActivityData(type, frequency, timeStamp);
249
310
  }
250
311
  break;
251
312
  case 'GET_LOCATION_PERMISSIONS':
252
- {
253
- requestLocationPermission();
254
- }
313
+ console.log('GET_LOCATION_PERMISSIONS');
314
+ requestLocationPermission();
255
315
  break;
256
316
  case 'OPEN_PDF':
257
317
  {
@@ -262,7 +322,6 @@ const VisitRnSdkView = _ref => {
262
322
  }
263
323
  break;
264
324
  case 'CLOSE_VIEW':
265
- {}
266
325
  break;
267
326
  default:
268
327
  break;
@@ -276,8 +335,8 @@ const VisitRnSdkView = _ref => {
276
335
  const [canGoBack, setCanGoBack] = useState(false);
277
336
  const handleBack = useCallback(() => {
278
337
  if (canGoBack && webviewRef.current) {
279
- var _webviewRef$current5;
280
- (_webviewRef$current5 = webviewRef.current) === null || _webviewRef$current5 === void 0 || _webviewRef$current5.goBack();
338
+ var _webviewRef$current8;
339
+ (_webviewRef$current8 = webviewRef.current) === null || _webviewRef$current8 === void 0 || _webviewRef$current8.goBack();
281
340
  return true;
282
341
  }
283
342
  return false;
@@ -288,10 +347,7 @@ const VisitRnSdkView = _ref => {
288
347
  locationEnabled
289
348
  } = _ref2;
290
349
  if (locationEnabled) {
291
- var _webviewRef$current6;
292
- var finalString = `window.checkTheGpsPermission(true)`;
293
- console.log('listener: ' + finalString);
294
- (_webviewRef$current6 = webviewRef.current) === null || _webviewRef$current6 === void 0 || _webviewRef$current6.injectJavaScript(finalString);
350
+ checkLocationPermissionAndSendCallback();
295
351
  }
296
352
  });
297
353
  BackHandler.addEventListener('hardwareBackPress', handleBack);
@@ -300,37 +356,50 @@ const VisitRnSdkView = _ref => {
300
356
  gpsListener.remove();
301
357
  };
302
358
  }, [handleBack]);
303
- return /*#__PURE__*/React.createElement(SafeAreaView, {
304
- style: {
305
- flex: 1
359
+ const checkLocationPermissionAndSendCallback = async () => {
360
+ const isLocationPermissionAvailable = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
361
+ console.log('checkLocationPermissionAndSendCallback() isLocationPermissionAvailable: ' + isLocationPermissionAvailable + 'isGPSPermissionAvailabe: true');
362
+ if (isLocationPermissionAvailable) {
363
+ var _webviewRef$current9;
364
+ var finalString = `window.checkTheGpsPermission(true)`;
365
+ console.log('listener: ' + finalString);
366
+ (_webviewRef$current9 = webviewRef.current) === null || _webviewRef$current9 === void 0 || _webviewRef$current9.injectJavaScript(finalString);
306
367
  }
307
- }, source ? /*#__PURE__*/React.createElement(WebView, {
308
- ref: webviewRef,
309
- source: {
310
- uri: source,
311
- headers: {
312
- platform: 'ANDROID'
368
+ };
369
+ return (
370
+ /*#__PURE__*/
371
+ // eslint-disable-next-line react-native/no-inline-styles
372
+ React.createElement(SafeAreaView, {
373
+ style: {
374
+ flex: 1
313
375
  }
314
- },
315
- onMessage: handleMessage,
316
- injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
317
- javaScriptEnabled: true,
318
- onLoadProgress: event => setCanGoBack(event.nativeEvent.canGoBack),
319
- onError: errorMessage => {
320
- EventRegister.emitEvent('visit-event', {
321
- message: 'web-view-error',
322
- errorMessage: errorMessage
323
- });
324
- if (isLoggingEnabled) {
325
- console.warn('Webview error: ', errorMessage);
376
+ }, source ? /*#__PURE__*/React.createElement(WebView, {
377
+ ref: webviewRef,
378
+ source: {
379
+ uri: source,
380
+ headers: {
381
+ platform: 'ANDROID'
382
+ }
383
+ },
384
+ onMessage: handleMessage,
385
+ injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
386
+ javaScriptEnabled: true,
387
+ onLoadProgress: event => setCanGoBack(event.nativeEvent.canGoBack),
388
+ onError: errorMessage => {
389
+ EventRegister.emitEvent('visit-event', {
390
+ message: 'web-view-error',
391
+ errorMessage: errorMessage
392
+ });
393
+ if (isLoggingEnabled) {
394
+ console.warn('Webview error: ', errorMessage);
395
+ }
326
396
  }
327
- }
328
- }) : null);
397
+ }) : null)
398
+ );
329
399
  };
330
400
  export const fetchDailyFitnessData = (startTimeStamp, isLoggingEnabled) => {
331
401
  return new Promise((resolve, reject) => {
332
402
  console.log('fetchDailyFitnessData called: ' + startTimeStamp);
333
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
334
403
  NativeModules.VisitFitnessModule.fetchDailyFitnessData(startTimeStamp).then(result => {
335
404
  resolve(result);
336
405
  }).catch(err => reject(err));
@@ -338,13 +407,39 @@ export const fetchDailyFitnessData = (startTimeStamp, isLoggingEnabled) => {
338
407
  };
339
408
  export const fetchHourlyFitnessData = (startTimeStamp, isLoggingEnabled) => {
340
409
  return new Promise((resolve, reject) => {
341
- console.log('fetchHourlyFitnessData called: ' + startTimeStamp);
342
- NativeModules.VisitFitnessModule.initiateSDK(isLoggingEnabled);
410
+ if (isLoggingEnabled) {
411
+ console.log('fetchHourlyFitnessData called: ' + startTimeStamp);
412
+ }
343
413
  NativeModules.VisitFitnessModule.fetchHourlyFitnessData(startTimeStamp).then(result => {
344
414
  resolve(result);
345
415
  }).catch(err => reject(err));
346
416
  });
347
417
  };
418
+
419
+ // debounce, deferred
420
+ // function debounce(task, ms) {
421
+ // let t = { promise: null, cancel: (_) => void 0 };
422
+ // return async (...args) => {
423
+ // try {
424
+ // t.cancel();
425
+ // t = deferred(ms);
426
+ // await t.promise;
427
+ // await task(...args);
428
+ // } catch (_) {
429
+ // console.log('cleaning up cancelled promise');
430
+ // }
431
+ // };
432
+ // }
433
+
434
+ // function deferred(ms) {
435
+ // let cancel,
436
+ // promise = new Promise((resolve, reject) => {
437
+ // cancel = reject;
438
+ // setTimeout(resolve, ms);
439
+ // });
440
+ // return { promise, cancel };
441
+ // }
442
+
348
443
  export default VisitRnSdkView;
349
444
  VisitRnSdkView.defaultProps = {
350
445
  cpsid: '',