HomeiOS Developmentjavascript - Need to open digital camera immediately in html5-qrcode (reactjs)

javascript – Need to open digital camera immediately in html5-qrcode (reactjs)


I’m dealing with challenge on cellular I’m not in a position to open digital camera immediately there’s a textual content identify “begin scanning” consumer must click on that button to open digital camera and begin ,is there any solution to open digital camera immediately with out click on on begin scanning button on cellular , I forcefully did it on internet utilizing Dom that is working high-quality

Need to open digital camera ditectly with out click on on textual content “begin scanning”..

That is our present code

import { Html5QrcodeScanner } from "html5-qrcode";
import { useEffect, useState } from "react";

const qrcodeRegionId = "html5qr-code-full-region";

// Creates the configuration object for Html5QrcodeScanner.
const createConfig = (props) => {
  let config = {};
  if (props.fps) {
    config.fps = props.fps;
  }
  if (props.qrbox) {
    config.qrbox = props.qrbox;
  }
  if (props.aspectRatio) {
    config.aspectRatio = props.aspectRatio;
  }
  if (props.disableFlip !== undefined) {
    config.disableFlip = props.disableFlip;
  }
  return config;
};

const Html5QrcodePlugin = (props) => {
  const [text, setText] = useState(false);

  // useEffect(() => {
  //   let internal = doc.getElementById("html5-qrcode-anchor-scan-type-change");
  //   if (internal?.innerHTML == "Scan utilizing digital camera immediately") {
  //     internal.innerHTML = "";
  //   }
  // });
  useEffect(() => {
    // when element mounts
    const config = createConfig(props);
    const verbose = props.verbose === true;
    // Suceess callback is required.
    if (!props.qrCodeSuccessCallback) {
      throw "qrCodeSuccessCallback is required callback.";
    }
    const html5QrcodeScanner = new Html5QrcodeScanner(
      qrcodeRegionId,
      config,
      verbose
    );
    html5QrcodeScanner.render(
      props.qrCodeSuccessCallback,
      props.qrCodeErrorCallback
    );

    // cleanup perform when element will unmount
    return () => {
      html5QrcodeScanner.clear().catch((error) => {
        console.error("Didn't clear html5QrcodeScanner. ", error);
      });
    };
  }, []);

  return <div id={qrcodeRegionId} onClick={() => setText(!textual content)} />;
};

export default Html5QrcodePlugin;

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments