viewing javascript console.log or opening camera on ios simulator

269 Views Asked by At

I implemented blinkid-react-native in react native ios app. blinkid-react-native will give me the ability to scan id's and veirfy the data on them. When i run my code i get json with only the address showing.

Since I can't open the camera to scan an id from the ios simulator. i deployed the app to test flight. i need to debug and see the javascript console.logs. I'm unable to do that from test flight?

I'm not sure about how to debug the issue? Since i can't open the camera on the ios simulator to run BlinkId and go thrugh console.logs.

here is the json the i get

enter image description here

here is BlinkId code

export const scanId = async () => {
  console.log('BlinkId*****************');
  const licenseKey = Platform.select({
    ios:
      '**********',
    android:
      '**********',
  });

  BlinkIDReactNative.SuccessFrameGrabberRecognizer(mrtdRecognizer);

  var blinkIdCombinedRecognizer = new BlinkIDReactNative.BlinkIdCombinedRecognizer();
  blinkIdCombinedRecognizer.returnFullDocumentImage = true;
  blinkIdCombinedRecognizer.returnFaceImage = true;

  const scanningResults = await BlinkIDReactNative.BlinkID.scanWithCamera(
    new BlinkIDReactNative.BlinkIdOverlaySettings(),
    new BlinkIDReactNative.RecognizerCollection([
      blinkIdCombinedRecognizer /*, mrtdSuccessFrameGrabber*/,
    ]),
    licenseKey,
  )
    .then((result) => handleResult(result))
    .catch((e) => e);
  return scanningResults;
};
console.log('BlinkId+scanningResults*****************');
console.log(this.scanningResults);
console.log('BlinkId+result1*****************');
console.log(this.result);
const handleResult = (result) => {
  function buildResult(result, key) {
    if (result && result != -1) {
      return key + ': ' + result + '\n';
    }
    return '';
  }
  console.log('BlinkId+result2*****************');
  console.log(result);
  function buildDateResult(result, key) {
    if (result) {
      return (
        key +
        ': ' +
        result.day +
        '.' +
        result.month +
        '.' +
        result.year +
        '.' +
        '\n'
      );
    }
    return '';
  }

  var localState = {
    showFrontImageDocument: false,
    resultFrontImageDocument: '',
    showBackImageDocument: false,
    resultBackImageDocument: '',
    resultImageFace: '',
    results: '',
    showSuccessFrame: false,
    successFrame: '',
  };
  console.log('BlinkId+result3*****************');
  console.log(result);
  if (result instanceof BlinkIDReactNative.BlinkIdCombinedRecognizerResult) {
    let blinkIdResult = result;
    console.log('BlinkId+blinkIdResult*****************');
    console.log(blinkIdResult);
    let resultString =
      buildResult(blinkIdResult.firstName, 'First name') +
      buildResult(blinkIdResult.lastName, 'Last name') +
      buildResult(blinkIdResult.fullName, 'Full name') +
      buildResult(blinkIdResult.localizedName, 'Localized name') +
      buildResult(
        blinkIdResult.additionalNameInformation,
        'Additional name info',
      ) +
      buildResult(blinkIdResult.address, 'Address') +
      buildResult(
        blinkIdResult.additionalAddressInformation,
        'Additional address info',
      ) +
      buildResult(blinkIdResult.documentNumber, 'Document number') +
      buildResult(
        blinkIdResult.documentAdditionalNumber,
        'Additional document number',
      ) +
      buildResult(blinkIdResult.sex, 'Sex') +
      buildResult(blinkIdResult.issuingAuthority, 'Issuing authority') +
      buildResult(blinkIdResult.nationality, 'Nationality') +
      buildDateResult(blinkIdResult.dateOfBirth, 'Date of birth') +
      buildResult(blinkIdResult.age, 'Age') +
      buildDateResult(blinkIdResult.dateOfIssue, 'Date of issue') +
      buildDateResult(blinkIdResult.dateOfExpiry, 'Date of expiry') +
      buildResult(
        blinkIdResult.dateOfExpiryPermanent,
        'Date of expiry permanent',
      ) +
      buildResult(blinkIdResult.expired, 'Expired') +
      buildResult(blinkIdResult.maritalStatus, 'Martial status') +
      buildResult(blinkIdResult.personalIdNumber, 'Personal id number') +
      buildResult(blinkIdResult.profession, 'Profession') +
      buildResult(blinkIdResult.race, 'Race') +
      buildResult(blinkIdResult.religion, 'Religion') +
      buildResult(blinkIdResult.residentialStatus, 'Residential status') +
      buildResult(blinkIdResult.processingStatus, 'Processing status') +
      buildResult(blinkIdResult.recognitionMode, 'Recognition mode');
    let licenceInfo = blinkIdResult.driverLicenseDetailedInfo;
    if (licenceInfo) {
      resultString +=
        buildResult(licenceInfo.restrictions, 'Restrictions') +
        buildResult(licenceInfo.endorsements, 'Endorsements') +
        buildResult(licenceInfo.vehicleClass, 'Vehicle class') +
        buildResult(licenceInfo.conditions, 'Conditions');
    }

    // there are other fields to extract
    localState.results += resultString;

    // Document image is returned as Base64 encoded JPEG
    if (blinkIdResult.fullDocumentFrontImage) {
      localState.showFrontImageDocument = true;
      localState.resultFrontImageDocument =
        'data:image/jpg;base64,' + blinkIdResult.fullDocumentFrontImage;
    }
    if (blinkIdResult.fullDocumentBackImage) {
      localState.showBackImageDocument = true;
      localState.resultBackImageDocument =
        'data:image/jpg;base64,' + blinkIdResult.fullDocumentBackImage;
    }
    // Face image is returned as Base64 encoded JPEG
    if (blinkIdResult.faceImage) {
      localState.showImageFace = true;
      localState.resultImageFace =
        'data:image/jpg;base64,' + blinkIdResult.faceImage;
    }
  } else {
    throw JSON.stringify(result);
  }
  console.log('BlinkId+localState*****************');
  console.log(localState);
  return localState;
};

0

There are 0 best solutions below