regulaforensics / react-native-document-reader

React-Native Framework for reading and validation of identification documents
19 stars 10 forks source link

Error reading license [Error: ENOENT: no such file or directory] #12

Open Aleksej3333 opened 2 years ago

Aleksej3333 commented 2 years ago
image
const licPath =
  Platform.OS === 'ios'
    ? RNFS.MainBundlePath + '/regula.license'
    : 'regula.license';
const readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileAssets;
const readLicense = async () => {
    try {
      const license = await readFile(licPath);
      console.log('license', license);
    } catch (err) {
      console.log('Error reading license');
    }
  };

[Error: ENOENT: no such file or directory, open '/Users/ag/Library/Developer/CoreSimulator/Devices/51847DA5-88F9-4336-AE1A-16C16499686F/data/Containers/Bundle/Application/3F0BA254-38E9-48B1-834C-DA174431DA57/SimpleFormApplication.app/regula.license']

Aleksej3333 commented 2 years ago

How I can fix it?

DzmitrySmaliakou commented 2 years ago

Hello, you should add regula.license file to your target in xCode project as it was done in our example

gamble2020 commented 2 years ago

Why don't you guys just provide a base64 string? It would make life so much easier for everyone.

If you have a Mac you can use your terminal like...

base64 regula.license

Copy the string and use as...

    DocumentReader.initializeReader(
      ??Base_64_String??,
      respond => {
        console.log(respond);
        DocumentReader.setConfig(
          {
            processParams: {
              scenario: 'Mrz',
            },
          },
          str => {
            console.log(str);
          },
          error => {
            console.log(error);
          },
        );
      },
      error => console.log(error),
    );