WebToAppMaker

JavaScript Bridge

Using the QR Scanner

Open the native QR scanner and receive a scanned string in website JavaScript.

Before you start

  • QR Scanner and camera permission enabled
  • Result validation logic

Configure and verify

  1. Start from a user gesture

    Call webtoapp.openQrScanner() after the user chooses Scan.

  2. Choose confirmation behavior

    Pass enable_confirmation_popup when the configured result dialog should appear before returning.

  3. Receive the value

    Handle webtoapp.onQRResult, webtoapp:qr-result, or the generic onmessage response.

  4. Validate and route

    Accept only expected schemes, hosts, identifiers, or formats before navigating or submitting data.

Example

webtoapp.openQrScanner({ enable_confirmation_popup: true });
webtoapp.onQRResult = function (value) {
  if (/^https:\/\/example\.com\//.test(value)) location.href = value;
};

Test before release

  • Camera permission works
  • Cancel is handled
  • Result is validated
  • Unexpected schemes are rejected