Browse Source

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

tekmin 5 years ago
parent
commit
47e9a0b97d

+ 5
- 1
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java View File

367
   @ReactProp(name = "incognito")
367
   @ReactProp(name = "incognito")
368
   public void setIncognito(WebView view, boolean enabled) {
368
   public void setIncognito(WebView view, boolean enabled) {
369
     // Remove all previous cookies
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
     // Disable caching
376
     // Disable caching
373
     view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
377
     view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);