howljs / rn-card-scanner

This library provides payment card scanning functionality for your React Native app
MIT License
88 stars 10 forks source link

Camera is not opening at all #17

Closed thidasapankaja closed 6 months ago

thidasapankaja commented 6 months ago

I'm trying to use this in a project.

Created a component like this

export function CreditCardScanner() {
  const cardScannerRef = useRef(null);
  return (
    <View>
      <Button
        onPress={() => {
          console.log('cardSca:  ', cardScannerRef?.current);
          cardScannerRef?.current?.startCamera();
        }}]
        title="Click"
      />
      <CardScanner
        style={{ flex: 1 }}
        PermissionCheckingComponent={<LoadingIndicator />}
        ref={cardScannerRef}
        didCardScan={(response) => {
          console.log('Card info: ', response);
        }}
      />
    </View>
  );
}

When I tapped on the Button, it's not starting the camera at all in Android. I checked the code. In the below file I see only toggleFlash and resetResult are being mapped, not any other functions. How does it work ?

   return MapBuilder.of(
      "toggleFlash", COMMAND_TOGGLE_FLASH,
      "resetResult", COMMAND_RESET_RESULT
    );

https://github.com/howljs/rn-card-scanner/blob/main/android/src/main/java/com/rncardscanner/CardScannerViewManager.java