Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility - [iOS >17] [Safari Chrome] - Cannot start camera #951

Open
alexnguyenth opened this issue Sep 15, 2024 · 0 comments
Open

Comments

@alexnguyenth
Copy link

alexnguyenth commented Sep 15, 2024

Working fine on android and macOS but cannot on iOS 17

 const handleStartCamera = useCallback(() => {
    setMode('camera')
    setIsScanning(true)

    cameraRef.current = new Html5Qrcode('reader')
    cameraRef.current.start(
      { facingMode: cameraEnv },
      {
        fps: 10,
        qrbox: { width: 250, height: 250 },
      },
      onScanSuccess,
      onScanError,
    )
  }, [cameraEnv, onScanError, onScanSuccess])
const handleSwitchCamera = useCallback(() => {
    Html5Qrcode.getCameras().then((cameras) => {
      if (cameras.length < 2) {
        return
      }

      if (cameraRef.current) {
        setCameraEnv((prev) =>
          prev === 'environment' ? 'user' : 'environment',
        )

        cameraRef.current.stop().then(() => {
          handleStartCamera()
        })
      }
    })
  }, [handleStartCamera])

The element in Html5Qrcode instance created but canvasElement didn't create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant