HMS-Core/hms-cordova-plugin

Data Matrix and Aztec codes scan not working

MaratEldarov opened this issue · 6 comments

Description
I have a problem with Data Matrix and Aztec code scan, but simple QR code works fine.

Expected behavior
I expect that Aztec and Data Matrix scanning will work fine and give me the result when I pass HMSScan.ScanTypes.ALL_SCAN_TYPE in scanTypes array:

const defaultViewModeInput = {
  scanTypes: [window.HMSScan.ScanTypes.ALL_SCAN_TYPE],
};

await window.HMSScan.defaultViewMode(defaultViewModeInput);

Current behavior
But when I scan Aztec or Data Matrix codes - scanner not react on it and staying opened. When I try scan that codes from Gallery - I got error:

image

In English it means something like "code not defined"

Environment

  • Platform: Cordova 8.1.2, Cordova Android 8.0.0
  • Kit: Scan Kit
  • Kit Version 1.2.3-300
  • OS Version Android 11

Other
These are codes I try to scan:

image

image

I also using forked version of plugin form here https://github.com/cempay/hms-cordova-plugin
because of there was some little fixes from our team. Without them we have problems with getting permissions.

And here is my full JS code

async function requestPermissionsScan() {
  try {
    await window.HMSScan.requestPermissions({
      permissionList: ['CAMERA', 'WRITE_EXTERNAL_STORAGE'],
    });
  } catch (ex) {
    throw new Error(ex);
  }
}

async function checkPermissions() {
  try {
    const result = await window.HMSScan.checkPermissions({
      permissionList: ['CAMERA', 'WRITE_EXTERNAL_STORAGE'],
    });
    return result;
  } catch (ex) {
    console.error('checkPermissions error:', { ex });
  }
}

async function defaultViewMode() {
  try {
    const defaultViewModeInput = {
      scanTypes: [window.HMSScan.ScanTypes.ALL_SCAN_TYPE],
    };
    const { originalValue: text } = await window.HMSScan.defaultViewMode(defaultViewModeInput);
    return { text };
  } catch (ex) {
    throw new Error(ex);
  }
}

async function scanHuawei() {
  if (!window.HMSScan) {
    throw new Error('HMS BarcodeScanner plugin not exists!');
  }
  const { CAMERA, WRITE_EXTERNAL_STORAGE } = await checkPermissions();
  if (!CAMERA.hasPermission || !WRITE_EXTERNAL_STORAGE.hasPermission) {
    await requestPermissionsScan();
  }
  try {
    const scanResult = await defaultViewMode();
    return scanResult;
  } catch (scannerException) {
    throw new Error(scannerException.message);
  }
}

Hello MaratEldarov, we are investigating the error you encountered, we will return as soon as possible.

If you update your Scan SDK version to 1.3.1.300, the problem you encounter will be solved.

  1. In the plugin.xml file in the plugin you need to change this line this way.
  2. In Plugin, you need to change the implementation information in this directory. src-> android-> build.gradle implementation 'com.huawei.hms: scan: 1.3.1.300'

I try to do it and got plenty of errors about android.support packages in other plugins, for example:

image

image

image

image

image

I am developing the new version of Scankit. It will be released at the end of next month.