react-native-mytatva-rn-sdk 1.2.1 → 1.2.3
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 +1 -1
- package/src/MainWebView.tsx +5 -2
- package/src/ProgressWebView.tsx +5 -2
- package/src/index.android.js +2 -0
- package/src/index.ios.js +23 -2
package/package.json
CHANGED
package/src/MainWebView.tsx
CHANGED
|
@@ -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:
|
|
28
|
+
platform: platform,
|
|
28
29
|
},
|
|
29
30
|
}}
|
|
30
31
|
onMessage={handleMessage}
|
|
31
|
-
|
|
32
|
+
{...(runBeforeFirst && {
|
|
33
|
+
injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
|
|
34
|
+
})}
|
|
32
35
|
javaScriptEnabled={true}
|
|
33
36
|
onLoadProgress={(event) => setCanGoBack(event.nativeEvent.canGoBack)}
|
|
34
37
|
onError={(errorMessage) => {
|
package/src/ProgressWebView.tsx
CHANGED
|
@@ -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:
|
|
341
|
+
platform: platform,
|
|
341
342
|
},
|
|
342
343
|
}}
|
|
343
344
|
onMessage={handleMessage}
|
|
344
|
-
|
|
345
|
+
{...(runBeforeFirst && {
|
|
346
|
+
injectedJavaScriptBeforeContentLoaded: runBeforeFirst,
|
|
347
|
+
})}
|
|
345
348
|
javaScriptEnabled={true}
|
|
346
349
|
// onLoadProgress={(event) => setCanGoBack(event.nativeEvent.canGoBack)}
|
|
347
350
|
onError={(errorMessage) => {
|
package/src/index.android.js
CHANGED
|
@@ -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
|
@@ -11,8 +11,10 @@ import {
|
|
|
11
11
|
NativeModules,
|
|
12
12
|
NativeEventEmitter,
|
|
13
13
|
Linking,
|
|
14
|
+
BackHandler,
|
|
14
15
|
Platform,
|
|
15
16
|
ActivityIndicator,
|
|
17
|
+
BackHandler,
|
|
16
18
|
Dimensions,
|
|
17
19
|
} from 'react-native';
|
|
18
20
|
import { EventRegister } from 'react-native-event-listeners';
|
|
@@ -219,6 +221,23 @@ const MyTatvaRnSdkView = ({
|
|
|
219
221
|
break;
|
|
220
222
|
}
|
|
221
223
|
};
|
|
224
|
+
const [canGoBack, setCanGoBack] = useState(false);
|
|
225
|
+
|
|
226
|
+
const handleBack = useCallback(() => {
|
|
227
|
+
if (canGoBack && webviewRef.current) {
|
|
228
|
+
webviewRef.current?.goBack();
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
}, [canGoBack]);
|
|
233
|
+
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
236
|
+
return () => {
|
|
237
|
+
BackHandler.removeEventListener('hardwareBackPress', handleBack);
|
|
238
|
+
// gpsListener.remove();
|
|
239
|
+
};
|
|
240
|
+
}, [handleBack]);
|
|
222
241
|
|
|
223
242
|
const { height, width } = Dimensions.get('screen');
|
|
224
243
|
return (
|
|
@@ -234,10 +253,11 @@ const MyTatvaRnSdkView = ({
|
|
|
234
253
|
loading={loading}
|
|
235
254
|
isError={isError}
|
|
236
255
|
webviewRef={webviewRef}
|
|
237
|
-
runBeforeFirst={runBeforeFirst}
|
|
256
|
+
// runBeforeFirst={runBeforeFirst}
|
|
238
257
|
setCanGoBack={setCanGoBack}
|
|
239
258
|
mobileNumber={mobileNumber}
|
|
240
259
|
moduleName={moduleName}
|
|
260
|
+
platform={'IOS'}
|
|
241
261
|
uuid={uuid}
|
|
242
262
|
clientSource={clientSource}
|
|
243
263
|
/>
|
|
@@ -247,10 +267,11 @@ const MyTatvaRnSdkView = ({
|
|
|
247
267
|
environment={environment}
|
|
248
268
|
source={source}
|
|
249
269
|
loading={loading}
|
|
270
|
+
platform={'IOS'}
|
|
250
271
|
isError={isError}
|
|
251
272
|
webviewRef={webviewRef}
|
|
252
273
|
handleMessage={handleMessage}
|
|
253
|
-
runBeforeFirst={runBeforeFirst}
|
|
274
|
+
// runBeforeFirst={runBeforeFirst}
|
|
254
275
|
setCanGoBack={setCanGoBack}
|
|
255
276
|
clientSource={clientSource}
|
|
256
277
|
moduleName={moduleName}
|