问题
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