-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InAppWebViewController.clearAllCache() doesnt works fine #2143
Comments
NOTE: This comment is auto-generated. Are you sure you have already searched for the same problem? Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem! If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue. In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding Following these steps can save you, me, and other people a lot of time, thanks! |
I use this code when my user logout. On Android session cookies are maybe your issue. /// Delete all cookies except the ones that are required for the webview to works
/// Then clear cache.
Future<void> clearSessionCookies() async {
final CookieManager cookieManager = CookieManager.instance();
final List<Cookie> cookies = await cookieManager.getCookies(
url: WebUri(config.webviewUrl),
);
for (final Cookie cookie in cookies) {
if (!<String>[
WEB_VIEW_COOKIE_CONSENTS,
WEB_VIEW_COOKIE_REGION_SUFFIX,
].contains(cookie.name)) {
await cookieManager.deleteCookie(
url: WebUri(config.webviewUrl),
domain: cookie.domain,
name: cookie.name,
path: cookie.path ?? WEB_VIEW_COOKIES_DEFAULT_PATH,
);
}
}
if (Platform.isAndroid) await cookieManager.removeSessionCookies();
await InAppWebViewController.clearAllCache();
}
} |
Hi, |
no :( they didnt give a shit to me :( |
(did my response helped you ?) |
Didn't work, I just change to webview_flutter |
Same for me ! First time it's clear cache, but second time CTA clear cache doesn't work and cache is not refreshed. CookieManager cookieManager = CookieManager.instance();
await cookieManager.removeSessionCookies();
await cookieManager.deleteAllCookies();
await InAppWebViewController.clearAllCache(); with same webview URL called. |
version 5 and version 6 have different implementations. On native side, the old implementation was: Lines 576 to 581 in 9447770
and now it's only For cookies and web storage data, use the corresponding service: Cookie Manager and Web Storage Manager |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue. |
Environment
Device information: Google Pixel 8 PRO
Description
I have a login page thats I capture toekn by webview, currently I'm using
controller.clearCache();
and works great, but this was deprecated and ask to use InAppWebViewController.clearAllCache instead, but when I changed to use the new way the cache dont be cleared anymoreExpected behavior:
Current behavior:
Steps to reproduce
Stacktrace/Logcat
D/InAppWebView(32290): Using InAppWebViewClientCompat implementation
[AndroidInAppWebViewWidget] (android) AndroidInAppWebViewWidget ID 3 calling "onWebViewCreated" using []
W/cr_WebSettings(32290): setForceDark() is a no-op in an app with targetSdkVersion>=T
W/cr_SupportWebSettings(32290): setForceDarkBehavior() is a no-op in an app with targetSdkVersion>=T
I/PlatformViewsController(32290): Using hybrid composition for platform view: 3
W/WindowOnBackDispatcher(32290): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher(32290): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onProgressChanged" using {progress: 10}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onReceivedHttpError" using {request: {headers: {User-Agent: Mozilla/5.0 (Linux; Android 14; Pixel 8 Pro Build/AP1A.240405.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.123 Mobile Safari/537.36, sec-ch-ua: "Chromium";v="124", "Android WebView";v="124", "Not-A.Brand";v="99", sec-ch-ua-mobile: ?1, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7, Upgrade-Insecure-Requests: 1, sec-ch-ua-platform: "Android"}, isRedirect: false, method: GET, hasGesture: false, isForMainFrame: true, url: url_login, errorResponse: {headers: {date: Tue, 1...
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onLoadStart" using {url: url_login}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onProgressChanged" using {progress: 24}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onTitleChanged" using {title: FarmáciasApp}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onUpdateVisitedHistory" using {isReload: false, url: url_login}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onProgressChanged" using {progress: 70}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onReceivedTouchIconUrl" using {precomposed: false, url: url_login}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onUpdateVisitedHistory" using {isReload: false, url: url_login}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onProgressChanged" using {progress: 100}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onLoadStop" using {url: url_login}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onProgressChanged" using {progress: 100}
[AndroidInAppWebViewController] (android) WebView ID 3 calling "onLoadStop" using {url: url_login}
[AndroidInAppWebViewWidget] (android) AndroidInAppWebViewWidget calling "dispose" using []
W/WindowOnBackDispatcher(32290): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher(32290): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
I/chromium(32290): [INFO:CONSOLE(1)] "[next-auth][error][CLIENT_FETCH_ERROR]
The text was updated successfully, but these errors were encountered: