Listening to Events

You can listen to various events in the PrintCard using the onEvent prop.

import { PrintCard } from '@card91/react-native-issue-card';

export function PrintCardPage() {
	const onEvent = (event) => {
  	switch (event) {
      case "C91_PRINT_CARD_SCREEN_INITIALISED":
        // Do something to indicate that Parameter is missing
        break;
      case "C91_PRINT_CARD_AUTHENTICATION_FAILURE":
        // Do something to indicate that the API calls have Unauthorized
        break;
      case "C91_PRINT_CARD_SERVER_FAILURE":
        // Do something to indicate that the API calls have Server Error
        break;
      case "C91_PRINT_CARD_API_SUCCESS":
        // Do something to indicate that the API calls have succeeded
        break;
      case "C91_PRINT_CARD_MISSING_PARAMETER":
        // Do something to indicate that the API calls have succeeded
        break;
      case 'C91_PRINT_CARD_API_FAILURE':
        // Do something to indicate that the API calls have failed
        break;
       case "C91_PRINT_CARD_EXTERNAL_AUTHENTICATION_FAILURE":
        // Do something to indicate that the API calls have Unauthorized
        break;
      case "C91_PRINT_CARD_EXTERNAL_SERVER_FAILURE":
        // Do something to indicate that the API calls have Server Error
        break;
      case "C91_PRINT_CARD_TOKEN_API_SUCCESS":
        // Do something to indicate that the API calls have succeeded
        break;
      case 'C91_PRINT_CARD_TOKEN_API_FAILURE':
        // Do something to indicate that the API calls have failed
        break;
      case 'C91_PRINT_CARD_EXTERNAL_MISSING_PARAMETER':
        // Do something to indicate that the API calls have failed
        break;
      case 'C91_FETCH_ADDRESS_API_FAILURE':
         // Do something to indicate that the API calls have failed
        break;
    }
  };
  
  return (
    <View>
	  	<PrintCard ... onEvent={onEvent} />
		</View>
  );
}

The events are as follows:

Event NameDescription
C91_PRINT_CARD_SCREEN_INITIALISEDThe Print card screen has been initialised.
C91_PRINT_CARD_API_SUCCESSThe API request related to the print card screen was successful.
C91_PRINT_CARD_API_FAILUREThe API request related to the print card screen has failed.
C91_PRINT_CARD_AUTHENTICATION_FAILUREAuthentication for the print card screen has failed.
C91_PRINT_CARD_SERVER_FAILUREThe server encountered an error while processing the print card request.
C91_PRINT_CARD_MISSING_PARAMETERA required parameter is missing in the print card request.
C91_PRINT_CARD_TOKEN_API_SUCCESSThe API request for retrieving a token related to the print card was successful.
C91_PRINT_CARD_TOKEN_API_FAILUREThe API request for retrieving a token related to the print card has failed.
C91_PRINT_CARD_EXTERNAL_SERVER_FAILUREAn external server encountered an error while processing the print card request.
C91_PRINT_CARD_EXTERNAL_MISSING_PARAMETERA required parameter is missing in the external print card request.
C91_PRINT_CARD_EXTERNAL_AUTHENTICATION_FAILUREAuthentication for the external print card request has failed.
C91_FETCH_ADDRESS_API_FAILUREThe API request related to the fetch address has failed.