react-qr-reader icon indicating copy to clipboard operation
react-qr-reader copied to clipboard

Camera does not capture QR on iOS

Open mahtoid opened this issue 2 years ago • 7 comments

Hello,

I am running react-qr-reader on a web app. Users have been trying to scan QRs using iOS (w/ Safari and Chrome) and have been reporting that it isn't detecting the QR code to scan.

From the little I have been able to test, there doesn't seem to be any errors or feedback what so ever. I have taken a browse over existing issues regarding iOS, but the website is 'trusted' (active SSL Certification) and works perfectly fine on Windows, Linux and Android. It seems to have intermittent issues with Mac (unable to reproduce myself) but has never worked at all on iOS.

Is there an active solution for this issue?

mahtoid avatar Jun 28 '23 13:06 mahtoid

Same here

Tjerk-Haaye-Henricus avatar Jul 01 '23 12:07 Tjerk-Haaye-Henricus

Same here. Any updates?

mosqueradvd avatar Aug 13 '23 00:08 mosqueradvd

same

sebitas avatar Aug 20 '23 21:08 sebitas

same. any updates?

di3upham avatar Sep 06 '23 09:09 di3upham

@mahtoid What iOS version are you using? Do you have the version numbers of each browser, etc?

I'm currently using iOS 16.1.1 on the latest version of Chrome / Safari and have no issues. Here's my QrReader component:

const [scanResult, setScanResult] = useState(null);

<QrReader
          onResult={(result) => {
            setScanResult((oldState) => {
              if (oldState?.getText() !== result?.getText()) {
                return result;
              }
            });
          }}
          scanDelay={250}
          constraints={{
            facingMode: 'environment',
            width: { max: 2000, min: 480 },
          }}
        />

Patrick-Sherlund avatar Sep 12 '23 04:09 Patrick-Sherlund

The docs are wrong with the result.text. I also have no idea why they default the camera to the selfie camera, that makes no sense, the below fixes that too.

You can copy and paste this for a good working start:

<QrReader
  constraints={{
    aspectRatio: "1",
    facingMode: "environment"
  }}
  scanDelay={250}
  onResult={(result, error) => {
    if (!!result) {
      console.log(result.getText())
    }
  }}
  ViewFinder={() => (
    <div
      style={{
        position: "absolute",
        top: "0",
        left: "0",
        right: "0",
        bottom: "0",
        zIndex: 10
      }}
    >overlay</div>
  )}
  videoContainerStyle={{}}
  videoStyle={{}}
/>

gregg-cbs avatar Sep 24 '23 19:09 gregg-cbs