Notice for App Developers

To use these methods, the codeScanner module must be installed in the native app:

Hierarchy

  • CodeScanner

Methods

Methods

  • Opens the camera and scans selected codes: (qr, aztec, dataMatrix, pdf417, code128 and ean13) A custom skin can also be provided to change the look of the scanner to one more appropriate to the code to be scanned.

    try {
    const modules = await Eitri.modules()

    // retrocompatibility with older scanner implementations using camera namespace
    const codeScannerModule = modules.codeScanner ?? modules.camera
    const startScannerMethod = codeScannerModule?.startScanner

    if (!startScannerMethod) {
    return // codeScanner module is unavailable, disable UI elements related to code scanning
    }

    const deeplink = await startScannerMethod({
    formats: ["qr_code"], // qr_code, aztec, data_matrix, pdf417, code_128, ean_13, ...
    layout: {
    skin: {
    code: "qr_code", // qr_code, barcode_portrait, barcode_landscape, ...
    laserAnimation: {
    enabled: true,
    color: "#FF0000",
    }
    },
    i18n:{
    title: "Escanear QR Code",
    description: "Centralize o QR Code para escanear",
    manualInput: "Digite seu código",
    torch: "Lanterna",
    },
    buttons: ["manualInput", "torch"]
    }
    })
    if (!deeplink) {
    setAlertMessage('code not detected')
    setShowErrorAlert(true)
    return
    }
    handleCode(deeplink)
    } catch (error) {
    console.log("startScanner.error: ", error);
    }

    Compatibility Control

    Parameters

    Returns Promise<string>

Generated using TypeDoc