简体   繁体   中英

Native PWA getUserMedia permission prompt on iOS 1.16.2

In a PWA i require the users camera access for scanning QR codes. i use getUserMedia() to get the users permission, however, when you leave the device for a while and want to scan more QR codes, the devices prompts for permission again.

I can accept these permissions globally for the safari app so it doesn't show up when using the app in PWA mode. However, using it as native PWA installed from the app-store , i get the prompt many times.

the app has a global setting for camera access, and it's set to true. html object <input type="file" accept="image/*" capture="environment"> then will NOT prompt the message again. however getUserMedia() WILL always keep prompting.

i find tons of peoples posts on the inte.net going back a couple of years.

I want the prompt to only show once.

solved:

@available(iOS 15.0, *)
    func webView(_ webView: WKWebView,
        requestMediaCapturePermissionFor
        origin: WKSecurityOrigin,initiatedByFrame
        frame: WKFrameInfo,type: WKMediaCaptureType,
        decisionHandler: @escaping (WKPermissionDecision) -> Void){
        decisionHandler(.grant)
     }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM