pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.21k stars 1.57k forks source link

Offline behaviour for Android differs from iOS on version 6.1.0+1 (i.e. error-page shows on Android unfortunately) #2295

Open iKK001 opened 2 days ago

iKK001 commented 2 days ago

[ok] I have read the Getting Started section [ok] I have already searched for the same problem

Environment

Technology Version
Flutter version 3.24.3
Plugin version 6.1.0+1
Android version 14
iOS version 18.0
macOS version 15.0 Sequioa
Xcode version 16.0
Google Chrome version 129.0.6668.70

Device information: Google Pixel 6

Description

I am working with the brand new version 6.1.0+1 of the flutter_inappwebview library.

And I want to use cache if the mobile phone is offline.

On iOS v18.0 everything works now with this newest inappwebview-version. (Thanks for the quick effort !!)

However on Android, the cache does not work the same way as iOS does it.

Current behavior:

On Android, if my physical device is offline, then pressing any link in my inappwebView gives me an error-page (saying that the error `ERR_INTERNET_DISCONNECTED" has happened).

What I would expect is the same as on iOS: Any link should simply not do anything. But instead, Android shows this error-page if links are pressed.

Steps to reproduce

I turn on flight-mode to make the physical device go offline. Then I open my flutter-app showing the inappwebview. I press any link and the error page is here.

This is my InAppWebView SETTINGS:

InAppWebViewSettings settings = InAppWebViewSettings(
    sharedCookiesEnabled:
        true, // needed to make login-persistency possible on iOS
    allowsLinkPreview: false,
    preferredContentMode: UserPreferredContentMode.MOBILE,
    javaScriptEnabled: true, // needed to make javascript-communication possible
    underPageBackgroundColor: constants.KARMA_LAMA_PRIMARY_COLOR,
    isInspectable: false,
    cacheEnabled:
        true, // needed to make app-running caching possible (and also to make login-persistency possible on Android)
    cacheMode: CacheMode
        .LOAD_DEFAULT, // use cached resources when they are available and not expired, otherwise load resources from the network
    mediaPlaybackRequiresUserGesture: false,
    allowsInlineMediaPlayback: true,
    iframeAllow: "camera; microphone",
    iframeAllowFullscreen: true,
    mixedContentMode: MixedContentMode
        .MIXED_CONTENT_ALWAYS_ALLOW, // allows mixed content (https and http), well ...kind of...
  );

Any help on this appreciated.

Why is Android behaving differently than iOS ?

github-actions[bot] commented 2 days ago

👋 @iKK001

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 android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!