Skip to content

Commit

Permalink
fix: Make compatible with Android 13 (SDK 33)
Browse files Browse the repository at this point in the history
Make react-native-webview compatible with Android SDK 33 by removing
deprecated calls to `setAppCacheEnabled`

Related PR: react-native-webview#2583
Related PR: react-native-webview#2697
  • Loading branch information
Ldoppea committed Aug 22, 2023
1 parent d95f2b0 commit 7cb96ce
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,7 @@ public void setHasOnOpenWindowEvent(WebView view, boolean hasEvent) {

@ReactProp(name = "cacheEnabled")
public void setCacheEnabled(WebView view, boolean enabled) {
if (enabled) {
Context ctx = view.getContext();
if (ctx != null) {
view.getSettings().setAppCachePath(ctx.getCacheDir().getAbsolutePath());
view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
view.getSettings().setAppCacheEnabled(true);
}
} else {
view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
view.getSettings().setAppCacheEnabled(false);
}
view.getSettings().setCacheMode(enabled ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_NO_CACHE);
}

@ReactProp(name = "cacheMode")
Expand Down Expand Up @@ -505,7 +495,6 @@ public void setIncognito(WebView view, boolean enabled) {

// Disable caching
view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
view.getSettings().setAppCacheEnabled(false);
view.clearHistory();
view.clearCache(true);

Expand Down

0 comments on commit 7cb96ce

Please sign in to comment.