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.01k stars 1.33k forks source link

IOS Selfie camera not opening #2117

Open vijayunified opened 2 weeks ago

vijayunified commented 2 weeks ago

Environment

Technology Version
Flutter version 3.19.5
Plugin version 6.0.0
Android version 14
iOS version 17.4.1
macOS version Sonoma 14.4
Xcode version 15.2
Google Chrome version

Device information:

Description

Expected behavior: Integrate a third-party KYC library to perform user verification through a webview that can access both the front and back cameras of a device.

Current behavior: On iOS devices, the webview integrated with the KYC library only allows access to the back camera and fails to switch to or activate the front camera.

Steps to reproduce

  1. This
  2. Than that
  3. Then

Code

`Expanded(

        child: InAppWebView(
            initialUrlRequest:
            URLRequest(url: WebUri(widget.webUrl.toString())),
            initialSettings: InAppWebViewSettings(
                allowFileAccess: true,
                allowContentAccess: true,
                iframeAllow: "camera; microphone",
                iframeAllowFullscreen: true,
                mediaPlaybackRequiresUserGesture: false,
                useShouldOverrideUrlLoading: true,
                useHybridComposition:true,
                allowsInlineMediaPlayback: true,
                javaScriptEnabled: true,
                hardwareAcceleration: true),
            shouldOverrideUrlLoading: (controller, navAction) async {
              return NavigationActionPolicy.ALLOW;
            },
            onReceivedError: (controller, request, error){
              AppLog.logPrint("RECEIVED ERROR: ${error}");
            },
            onPermissionRequest: (controller, request) async {
              print(request);
              return PermissionResponse(
                  resources: request.resources,
                  action: PermissionResponseAction.GRANT);
            },
            onWebViewCreated:
                (InAppWebViewController inAppWebViewController) {
              _controller.complete(inAppWebViewController);
            },
            onLoadStart: (InAppWebViewController, url) {
              setState(() {
                this.url = url?.toString() ?? '';
              });
            },
            onReceivedServerTrustAuthRequest: (_, challenge) async {
              return ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);
            },
            onCameraCaptureStateChanged:
                (inAppWebViewController, oldState, newState) async {
              var state= await inAppWebViewController.getCameraCaptureState();
              return inAppWebViewController.setCameraCaptureState(
                  state:state!);
            },
            onConsoleMessage: (InAppWebViewController, consoleMessage) {
              AppLog.logPrint(consoleMessage);
              /*if (controller.status.isSuccess == 1) {
    Get.offAll(const BottomNav(setIndex: 0));
  }*/
              // it will print: {message: {"bar":"bar_value","baz":"baz_value"}, messageLevel: 1}
            },
            onPageCommitVisible: (InAppWebViewController, url) async {
              InAppWebViewController.canGoBack();
            },
            onProgressChanged: (InAppWebViewController, progress) {
              setState(() {
                this.progress = progress / 100;
              });
            },
            shouldInterceptAjaxRequest: (InAppWebViewController controller,
                AjaxRequest ajaxRequest) async {
              print(ajaxRequest.url);
              return ajaxRequest;
            },
            onAjaxReadyStateChange: (InAppWebViewController _controller,
                AjaxRequest ajaxRequest) async {
              AppLog.logPrint(ajaxRequest.status);
              return AjaxRequestAction.PROCEED;
            },
            onAjaxProgress: (InAppWebViewController _controller,
                AjaxRequest ajaxRequest) async {
              AppLog.logPrint(ajaxRequest.status);
              return AjaxRequestAction.PROCEED;
            },
            onLoadStop: (InAppWebViewController, url) async {
              if (url.toString() == ApiConst.kycSuccessUrlDev) {
                await PreferenceUtils.setString(
                    AppConstants.KYC_STATUS, KycStatus.kycSuccessful);
                //Get.offAll(const BottomNav(setIndex: 0));
                Get.to(const KYCSuccessScreen());
                //ApiRepo.showToast("KYC Completed Successfully", isForError: false);
              }
              //InAppWebViewController.canGoBack();
            },
            androidOnPermissionRequest: (InAppWebViewController controller,
                String origin, List<String> resources) async {
              return PermissionRequestResponse(
                  resources: resources,
                  action: PermissionRequestResponseAction.GRANT);
            }),
      )` 

Images

Stacktrace/Logcat

Here Is My Code

github-actions[bot] commented 2 weeks ago

👋 @vijayunified

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!