BlinkID / blinkid-react-native

ID scanning for cross-platform apps built with ReactNative.
176 stars 59 forks source link

IdBarcodeRecognizer TimeOut. #212

Open aarango opened 1 year ago

aarango commented 1 year ago

I need activate one time out or know the lecture numbers for know if the camera don't recognize the barCode, I search in the options but I dont see results , this is possible? - I need help.

This property exist ?

This is my implementation.


import React, { useEffect } from 'react'
import * as BlinkIDReactNative from 'blinkid-react-native'
import { useIsFocused } from '@react-navigation/native'
import { View, Platform } from 'react-native'
import Constants from 'expo-constants'
import { styles } from './styles'

const licenseKey = Platform.select({
  ios: Constants.manifest.extra.iosApiKeyBlinkId,
  android: Constants.manifest.extra.androidBlinkIdApiKey,
})

function CameraPDF417({ onScanedQr, title = '' }) {
  const isFocused = useIsFocused()

  async function scan() {
    try {
      const uiSettings = new BlinkIDReactNative.BlinkIdOverlaySettings()
      uiSettings.firstSideInstructionsText = title

      const idBarcodeRecognizer = new BlinkIDReactNative.IdBarcodeRecognizer()

      const scanningResults = await BlinkIDReactNative.BlinkID.scanWithCamera(
        uiSettings,
        new BlinkIDReactNative.RecognizerCollection([idBarcodeRecognizer]),
        licenseKey,
      )
      if (scanningResults) {
        console.log('scanningResults', scanningResults)
        // onScanedQr(scanningResults)
      } else {
        console.log('scanningResults', scanningResults)
      }
    } catch (error) {
      console.log('ERROR CAMERA', error)
    }
  }

  useEffect(() => {
    ;(async () => {
      await scan()
    })()
  }, [isFocused])

  return <View style={styles.container} />
}

export { CameraPDF417 }
MBrizic01 commented 1 year ago

Hello @aarango , thank you for reaching out. If you are referring to the partial recognition timeout feature, you can implement it and set it to the number of seconds that fits your needs. Just to give more context, with the partial recognition timeout feature, the SDK will return the partial results to the user that it managed to scan after the number of seconds you've previously put in cases where it was not successful in extracting the 100% of the fields we support reading. Please check here how to set it up.

aarango commented 1 year ago

No I wanna close the camera in determinate time, for example wen the camera is open await 10 secons and close de camera. This is posible I cant see eny method to close camera. They only close with the user press the button close or the reader is succesfull. I need help to controllet this method