9

WKWebView is not asking permission for camera and microphone in the app. When I load the same url in safari browser it asks the permission for camera and microphone, and video call works perfectly. But when I embed this in WKWebView permission is not asked even I have given both camera and microphone permission in plist file. The same thing is not working even in UIWebView and safari view controller. I have referred below links but still its not working. Enable Camera and Mic access in wkwebview , How do I prevent a WKWebView from presenting the Camera modal if a user has denied access to the camera? Can anybody provide any solution?

Pooja Gupta
  • 785
  • 10
  • 22
Sona
  • 394
  • 3
  • 15

1 Answers1

0

Why not do the asking permission for camera and microphone in the app yourself?

You have the full control over your app.

    //Camera
    AVCaptureDevice.requestAccess(for: AVMediaType.video) { response in
        if response {
            //access granted
        } else {

        }
    }

    //Photos
    let photos = PHPhotoLibrary.authorizationStatus()
    if photos == .notDetermined {
        PHPhotoLibrary.requestAuthorization({status in
            if status == .authorized{
                ...
            } else {}
        })
    }

If all granted, then do the js video call.

If not, show tips for the use to grant it.

  • And, it's easy to do that js call native, native call js
dengST30
  • 3,643
  • 24
  • 25