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.28k stars 1.61k forks source link

iOS WebView Does Not Persist Camera and Mic Permission Status in In-App Webview #1751

Open 7ANV1R opened 1 year ago

7ANV1R commented 1 year ago

Expected Behavior:

The WebView should remember the previously granted camera and microphone permissions, and not prompt the user again for permission.

Actual Behavior:

On iOS, the WebView asks for camera and microphone permissions every time the app is launched, and the video meeting page is accessed within the WebView. The permission status is not persisted across app sessions.

Additional Information: This issue is specific to iOS and is not observed on Android devices. The behavior is consistent across different versions of iOS.

Code:

 Positioned.fill(
            child: InAppWebView(
              initialUrlRequest: URLRequest(
                url: Uri.parse(widget.url),
              ),
              onWebViewCreated: (controller) {
                webViewController = controller;
              },
              initialOptions: InAppWebViewGroupOptions(
                ios: IOSInAppWebViewOptions(
                  allowsInlineMediaPlayback: true,
                  allowsAirPlayForMediaPlayback: true,
                ),
                crossPlatform: InAppWebViewOptions(
                  // Assign the permissionRequestHandler function
                  mediaPlaybackRequiresUserGesture: false,
                ),
              ),
              androidOnPermissionRequest:
                  (InAppWebViewController controller, String origin, List<String> resources) async {
                return PermissionRequestResponse(
                  resources: resources,
                  action: PermissionRequestResponseAction.GRANT,
                );
              },
              onLoadStart: (controller, url) {
                isLoading.value = true;
              },
              onLoadStop: (controller, url) {
                isLoading.value = false;
              },
            ),
          ),

Environment:

Flutter Version: 3.10 iOS Version: 15.7 Device: iPhone 7 flutter_inappwebview: 5.7.2+3

Notes: This issue affects user experience, as users are prompted for camera and microphone permissions every time they access the video meeting page within the WebView on iOS devices. It is essential to ensure a smoother and more streamlined user experience by persisting the permission status across app sessions on iOS.

github-actions[bot] commented 1 year ago

👋 @7ANV1R

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!

sunny0092 commented 1 year ago

I'm also having the same problem

Adesh-Pandey commented 7 months ago

It is an IOS webkit behavior and cannot be escaped. If you are using camera and mic in your app using webkit, it will always ask for permission.