Skip to content

Commit cceddee

Browse files
committed
added updated checker
1 parent de71abf commit cceddee

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

App.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,26 @@ const MyWebView = () => {
7171
webViewRef.current?.injectJavaScript(webViewScript);
7272
};
7373

74+
const handleWebViewError = (error: any) => {
75+
// Check if error is a 419 error
76+
if (error.statusCode == 419) {
77+
// clear the cookies
78+
webViewRef.current?.injectJavaScript(`
79+
document.cookie.split(';').forEach(function(c) {
80+
document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/');
81+
});
82+
`);
83+
}
84+
85+
// Check if error is a 4xx error
86+
if (error.statusCode >= 400 && error.statusCode < 500) {
87+
// Redirect to another page
88+
webViewRef.current?.injectJavaScript(`
89+
window.location.href = 'https://dtsanalpos.com/payment';
90+
`);
91+
}
92+
};
93+
7494
return (
7595
<>
7696
<StatusBar
@@ -82,14 +102,15 @@ const MyWebView = () => {
82102
<SafeAreaView style={styles.container}>
83103
{cookieString && (
84104
<WebView
105+
ref={webViewRef}
85106
sharedCookiesEnabled={true}
86107
mixedContentMode="always"
87-
ref={webViewRef}
88108
source={{ uri: "https://dtsanalpos.com/payment" }}
89109
onMessage={handleWebViewLoad}
90110
onNavigationStateChange={handleNavigationStateChange}
91111
onShouldStartLoadWithRequest={() => true}
92112
injectedJavaScriptBeforeContentLoaded={setWebViewCookieString}
113+
onError={handleWebViewError}
93114
/>
94115
)}
95116
</SafeAreaView>

app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"expo": {
33
"name": "dtsanalpos",
44
"slug": "dtsanalpos",
5-
"version": "1.0.7",
5+
"version": "1.0.9",
66
"orientation": "portrait",
77
"icon": "./assets/app-icon.png",
88
"userInterfaceStyle": "light",
@@ -17,15 +17,15 @@
1717
"ios": {
1818
"supportsTablet": true,
1919
"bundleIdentifier": "com.distedavim.dtsanalpos",
20-
"buildNumber": "13"
20+
"buildNumber": "15"
2121
},
2222
"android": {
2323
"adaptiveIcon": {
2424
"foregroundImage": "./assets/app-icon.png",
2525
"backgroundColor": "#ffffff"
2626
},
2727
"package": "com.distedavim.dtsanalpos",
28-
"versionCode": 13
28+
"versionCode": 16
2929
},
3030
"web": {
3131
"favicon": "./assets/app-icon.png"

eas.json

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
{
2-
"build": {
3-
"preview": {
4-
"android": {
5-
"buildType": "apk"
6-
}
7-
},
8-
"preview2": {
9-
"android": {
10-
"gradleCommand": ":app:assembleRelease"
11-
}
12-
},
13-
"preview3": {
14-
"developmentClient": true
15-
},
16-
"production": {
17-
"autoIncrement": true
18-
}
19-
}
2+
"build": {
3+
"preview": {
4+
"android": {
5+
"buildType": "apk"
6+
}
7+
},
8+
"preview2": {
9+
"android": {
10+
"gradleCommand": ":app:assembleRelease"
11+
}
12+
},
13+
"preview3": {
14+
"developmentClient": true
15+
},
16+
"production": {
17+
"autoIncrement": true
18+
}
19+
},
20+
"cli": {
21+
"promptToConfigurePushNotifications": false
22+
}
2023
}

0 commit comments

Comments
 (0)