getUserMedia() in PWA on iOS 11.3.1

此生再无相见时 提交于 2019-12-23 19:32:03

问题


I'm trying to build a PWA of my webapp. My webapp makes use of getUserMedia to let the user make a picture. the webapp works as expected. 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. 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? or is this not possible (yet)? If not, are there any plans for PWA's on iOS to have this functionality?


回答1:


On your manifest.json file, you probably have "display": "standalone". If you change it to browser it should work. I'm facing the same problem now and it seems that iOS doesn't allow access to webrtc outside Safari main view



来源:https://stackoverflow.com/questions/50535580/getusermedia-in-pwa-on-ios-11-3-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!