iosflutterwebviewwebview-flutter

webview_flutter not working on iPhone after iOS 16.1.1 update


I am using webview_flutter 3.0.4 to load a login web page in iOS I have tried both on simulator and on device the app loading it shows the webpage login page for a few milisecounds and then crashs and I get this error WKErrorDomain WebResourceErrorType.webContentProcessTerminated

I am using Webpage url that use OAuth 2.0 to generate a unique login challenge everytime.

Flutter doctor -v output : `

[✓] Flutter (Channel stable, 3.3.9, on macOS 13.0.1 22A400 darwin-x64, locale en-US)
    • Flutter version 3.3.9 on channel stable at /Users/test/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (6 days ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[✓] VS Code (version 1.63.2)
    • VS Code at /Users/test/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0
[✓] Connected device (1 available)
    • macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64
[✓] HTTP Host Availability

Code Of WebView :

WebView(
                   onWebResourceError: (error){
                     print(error.domain);
                     print(error.errorType);
                     print(error.failingUrl);
                   },
                    zoomEnabled: false,
                    initialUrl: url,
                    javascriptMode: JavascriptMode.unrestricted,
                    navigationDelegate: (NavigationRequest request) async {
                      if (request.url.contains(“authenticated?redirect”)) {
                        await unsubFromOldFCMtopics(“From LOgin”);
                        //You can do anything
                        Navigator.push(
                            context,
                            MaterialPageRoute(
                                builder: (c) => MainScreen(),
                                settings: RouteSettings(name: “main-screen”)));
                        //Prevent that url works
                        return NavigationDecision.prevent;
                      }
                      //Any other url works
                      return NavigationDecision.navigate;
                    },
                    onPageStarted: (urli) {
                     print(urli);
                    },
                    onPageFinished: (_) async {
                       print(_);
                      final gotCookies = await cookieManager.getCookies(url);
                      if (gotCookies.isNotEmpty) {
                        Provider.of<AppData>(context, listen: false)
                            .updateCookies(gotCookies[0].value.toString());
                      }
                    },
                    onWebViewCreated: (WebViewController webViewController) {
                      _Webcontroller = webViewController;
                      if (_controller.isCompleted == false) {
                        _controller.complete(webViewController);
                      }
                    },
                  )

`

Also the webpage loads fine when i disable the JavascriptMode but then no buttons on the webpage work.


Solution

  • if you are facing the same issue you can use the package that I have edited. Link You can add it in your pubspec.yaml like this : enter image description here