瀏覽代碼

fix(android): webview crash with incognito in Android Lollipop (#799)

tekmin 5 年之前
父節點
當前提交
47e9a0b97d
共有 1 個檔案被更改,包括 5 行新增1 行删除
  1. 5
    1
      android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java

+ 5
- 1
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java 查看文件

@@ -367,7 +367,11 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
367 367
   @ReactProp(name = "incognito")
368 368
   public void setIncognito(WebView view, boolean enabled) {
369 369
     // Remove all previous cookies
370
-    CookieManager.getInstance().removeAllCookies(null);
370
+    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
371
+      CookieManager.getInstance().removeAllCookies(null);
372
+    } else {
373
+      CookieManager.getInstance().removeAllCookie();
374
+    }
371 375
 
372 376
     // Disable caching
373 377
     view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);