mozmorris / react-webcam

Webcam component
https://codepen.io/mozmorris/pen/JLZdoP
MIT License
1.65k stars 281 forks source link

doesnt ask permission on mobile (safari, ios 15) #324

Closed rjworks closed 2 years ago

rjworks commented 2 years ago

doesnt ask permission on mobile (safari, ios 15)

mozmorris commented 2 years ago

@cupof2 can you provide some code? or perhaps a link to your application?

rjworks commented 2 years ago
import React from 'react';
import Webcam from 'react-webcam';

const videoConstraints = {
  facingMode: 'environment',
  width: 1080,
  height: 720,
};

const Camera = () => {
  const webcamRef = React.useRef(null);

  const capture = async () => {
    const image = webcamRef.current.getScreenshot();
    console.log(image);
  };

  return (
    <div>
      <Webcam
        audio={false}
        ref={webcamRef}
        screenshotFormat="image/jpeg"
        screenshotQuality={1}
        videoConstraints={videoConstraints}
      />
      <button onClick={capture}>Capture</button>
    </div>
  );
};

export default Camera;

When this component is rendered, it asks for camera permission on desktop but not on mobile

mozmorris commented 2 years ago

Does the demo work for you? codepen.io/mozmorris/pen/jlzdop

timothymiller commented 2 years ago

Does the demo work for you? codepen.io/mozmorris/pen/jlzdop

Demo works for me on iPad iOS 15

mozmorris commented 2 years ago

@cupof2 have you got a link to your application? Did you read the issue guide before posting? For example, is you application being served over https?

The code supplied looks like one of the demo's created on Codepen, which leads me to think you're hosting this locally and probably not using https.

rjworks commented 2 years ago

Yes, I am hosting locally. Could that be the reason why?

rjworks commented 2 years ago

I do not have a production link at the moment.

mozmorris commented 2 years ago

@cupof2 yes - this is stated when you open a new issue and at the top of the README. I don't know if this is exactly your problem but it usually is for most people.


Screenshot 2021-11-22 at 09 56 36
Screenshot 2021-11-22 at 09 57 27

Taking time to read the guide and the contributing instructions takes a couple of minutes. Unfortunately in my experience a lot of developers are far too quick to open an issue. I can usually spot these types as their issues only contain a single sentence with no other information.

Please don't take this personally, you're not alone.