简体   繁体   English

iOS 1.16.2 上原生 PWA getUserMedia 权限提示

[英]Native PWA getUserMedia permission prompt on iOS 1.16.2

In a PWA i require the users camera access for scanning QR codes.在 PWA 中,我要求用户访问摄像头以扫描二维码。 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.我使用getUserMedia()来获得用户许可,但是,当您离开设备一段时间并想扫描更多二维码时,设备会再次提示您获得许可。

I can accept these permissions globally for the safari app so it doesn't show up when using the app in PWA mode.我可以全局接受 safari 应用程序的这些权限,因此在 PWA 模式下使用该应用程序时它不会显示。 However, using it as native PWA installed from the app-store , i get the prompt many times.但是,将其用作从应用商店安装的本机 PWA ,我多次收到提示。

the app has a global setting for camera access, and it's set to true.该应用程序具有相机访问的全局设置,并且设置为 true。 html object <input type="file" accept="image/*" capture="environment"> then will NOT prompt the message again. html object <input type="file" accept="image/*" capture="environment">然后不会再次提示消息。 however getUserMedia() WILL always keep prompting.但是getUserMedia()将始终保持提示。

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)
     }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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