简体   繁体   English

iOS 11.3.1上的PWA中的getUserMedia()

[英]getUserMedia() in PWA on iOS 11.3.1

I'm trying to build a PWA of my webapp. 我正在尝试构建我的webapp的PWA。 My webapp makes use of getUserMedia to let the user make a picture. 我的webapp使用getUserMedia让用户拍照。 the webapp works as expected. webapp按预期工作。 the browser asks permission to access the camera and if a user accepts it, the app continues to work. 浏览器要求访问摄像头的权限,如果用户接受它,该应用程序将继续工作。 Now, I made a PWA which works except for the camera. 现在,我做了一个PWA,除了相机之外。 The user doesn't get a prompt to give access to its camera which is where I think is the problem. 用户没有得到提示访问其相机的提示,这是我认为的问题所在。 Is there any way to trigger the camera access: 有没有办法触发相机访问:

   let constraints = {
       video: {
           facingMode: "user"
       },
       audio: false
   };

navigator.mediaDevices
    .getUserMedia(constraints)
    .then(function (stream) {
        track = stream.getTracks()[0];
        cameraView.srcObject = stream;
    })
    .catch(function (error) {
        console.error("Oops. Something is broken.", error);
    });

like such inside a PWA? 像这样的PWA? or is this not possible (yet)? 或者这是不可能的(还)? If not, are there any plans for PWA's on iOS to have this functionality? 如果没有,是否有计划让iOS上的PWA具备此功能?

On your manifest.json file, you probably have "display": "standalone" . 在manifest.json文件中,您可能有"display": "standalone" If you change it to browser it should work. 如果你把它改成browser它应该工作。 I'm facing the same problem now and it seems that iOS doesn't allow access to webrtc outside Safari main view 我现在面临同样的问题,似乎iOS不允许在Safari主视图之外访问webrtc

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

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