react-native-mytatva-rn-sdk 1.2.1 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -12,6 +12,7 @@ const MainWebView = (props) => {
12
12
  webviewRef,
13
13
  handleMessage,
14
14
  runBeforeFirst,
15
+ platform,
15
16
  setCanGoBack,
16
17
  } = props; // Get the URL and other parameters from the route
17
18
 
@@ -24,11 +25,13 @@ const MainWebView = (props) => {
24
25
  source={{
25
26
  uri: source,
26
27
  headers: {
27
- platform: 'ANDROID',
28
+ platform: platform,
28
29
  },
29
30
  }}
30
31
  onMessage={handleMessage}
31
- injectedJavaScriptBeforeContentLoaded={runBeforeFirst}
32
+ {...(runBeforeFirst && {
33
+ injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
34
+ })}
32
35
  javaScriptEnabled={true}
33
36
  onLoadProgress={(event) => setCanGoBack(event.nativeEvent.canGoBack)}
34
37
  onError={(errorMessage) => {
@@ -40,6 +40,7 @@ const ProgressWebView = (props) => {
40
40
  mobileNumber,
41
41
  uuid,
42
42
  clientSource,
43
+ platform,
43
44
  moduleName,
44
45
  } = props;
45
46
  const [activeGoodflipTab, setActiveGoodflipTab] = useState(
@@ -337,11 +338,13 @@ const ProgressWebView = (props) => {
337
338
  source={{
338
339
  uri: url,
339
340
  headers: {
340
- platform: 'ANDROID',
341
+ platform: platform,
341
342
  },
342
343
  }}
343
344
  onMessage={handleMessage}
344
- injectedJavaScriptBeforeContentLoaded={runBeforeFirst}
345
+ {...(runBeforeFirst && {
346
+ injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
347
+ })}
345
348
  javaScriptEnabled={true}
346
349
  // onLoadProgress={(event) => setCanGoBack(event.nativeEvent.canGoBack)}
347
350
  onError={(errorMessage) => {
@@ -256,6 +256,7 @@ const MyTatvaRnSdkView = ({
256
256
  runBeforeFirst={runBeforeFirst}
257
257
  setCanGoBack={setCanGoBack}
258
258
  mobileNumber={mobileNumber}
259
+ platform={'ANDROID'}
259
260
  moduleName={moduleName}
260
261
  uuid={uuid}
261
262
  clientSource={clientSource}
@@ -266,6 +267,7 @@ const MyTatvaRnSdkView = ({
266
267
  environment={environment}
267
268
  source={source}
268
269
  loading={loading}
270
+ platform={'ANDROID'}
269
271
  isError={isError}
270
272
  webviewRef={webviewRef}
271
273
  handleMessage={handleMessage}
package/src/index.ios.js CHANGED
@@ -219,6 +219,23 @@ const MyTatvaRnSdkView = ({
219
219
  break;
220
220
  }
221
221
  };
222
+ const [canGoBack, setCanGoBack] = useState(false);
223
+
224
+ const handleBack = useCallback(() => {
225
+ if (canGoBack && webviewRef.current) {
226
+ webviewRef.current?.goBack();
227
+ return true;
228
+ }
229
+ return false;
230
+ }, [canGoBack]);
231
+
232
+ useEffect(() => {
233
+ BackHandler.addEventListener('hardwareBackPress', handleBack);
234
+ return () => {
235
+ BackHandler.removeEventListener('hardwareBackPress', handleBack);
236
+ // gpsListener.remove();
237
+ };
238
+ }, [handleBack]);
222
239
 
223
240
  const { height, width } = Dimensions.get('screen');
224
241
  return (
@@ -234,10 +251,11 @@ const MyTatvaRnSdkView = ({
234
251
  loading={loading}
235
252
  isError={isError}
236
253
  webviewRef={webviewRef}
237
- runBeforeFirst={runBeforeFirst}
254
+ // runBeforeFirst={runBeforeFirst}
238
255
  setCanGoBack={setCanGoBack}
239
256
  mobileNumber={mobileNumber}
240
257
  moduleName={moduleName}
258
+ platform={'IOS'}
241
259
  uuid={uuid}
242
260
  clientSource={clientSource}
243
261
  />
@@ -247,10 +265,11 @@ const MyTatvaRnSdkView = ({
247
265
  environment={environment}
248
266
  source={source}
249
267
  loading={loading}
268
+ platform={'IOS'}
250
269
  isError={isError}
251
270
  webviewRef={webviewRef}
252
271
  handleMessage={handleMessage}
253
- runBeforeFirst={runBeforeFirst}
272
+ // runBeforeFirst={runBeforeFirst}
254
273
  setCanGoBack={setCanGoBack}
255
274
  clientSource={clientSource}
256
275
  moduleName={moduleName}