Host Card Emulation Through React Native

Host Card Emulation Through React Native

react-native-card-emulation Host card emulation through react native


Host card emulation through react native


npm install react-native-card-emulation


import CardEmulation from "react-native-card-emulation";

// ...

1. Initialize the module

componentDidMount() {
  // ...

2. Add event listeners

componentDidMount() {
    // ...


    const eventEmitter = new NativeEventEmitter(CardEmulation);
    eventEmitter.addListener('ReadRecord', () => {
      // Call api to get record info
      // Api should return: PAN, expity, serviceCode, User name

      console.log('Read record event received on js')

      const pan = "1212121212121212";
      const expiry = "2104";
      const serviceCode = "101";
      const name = "BASTOLA/SANT";

      CardEmulation.setReadRecordData(pan, expiry, serviceCode, name);

    eventEmitter.addListener('ComputeCryptoChecksum', () => {
      // Call api to compute cryptograhic checksum
      // Api should return cvv for Track1, cvv for Track2 and ATC

      console.log('Compute cryptographic checksum event received on js')

      const cvvT1 = "FBC7";
      const cvvT2 = "B892";
      const atc = "0001";

      CardEmulation.setCryptographicData(cvvT1, cvvT2, atc);

    eventEmitter.addListener('PaymentStarted', () => {
      console.log('Payment Started');

    eventEmitter.addListener('PaymentSuccessful', () => {
      console.log('Payment Successful');

    eventEmitter.addListener('PaymentFailed', () => {
      console.log('Payment Failed');

    eventEmitter.addListener('IncrementATC', () => {
      // Call an Api to increment atc

      console.log('Increment ATC');


Android setup

1. Add this on AndroidManifest.xml

<uses-permission android:name="android.permission.NFC" />

  android:required="true" />


// ...
      <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />

      <category android:name="android.intent.category.DEFAULT" />

      android:resource="@xml/apdu_config" />


2. Create a new file apdu_config.xml on android/app/src/main/res/xml and paste this code.

<?xml version="1.0" encoding="utf-8"?>
<host-apdu-service xmlns:android=""

            android:description="@string/aid_ppse_description" />
            android:description="@string/aid_mastercard_description" />


3. Add this on android/app/src/main/res/values/strings.xml

<!-- HCE Configuration -->
<string name="apdu_description">Contactless Pay</string>
<string name="aid_group_description">Contactless Pay is the best.</string>
<string name="aid_ppse_description">Proximity Payment System Environment (PPSE)</string>
<string name="aid_mastercard_description">MasterCard</string>


See the contributing guide to learn how to contribute to the repository and the development workflow.

Download Details:

Author: bastolaxantos

Source Code:

react-native react mobile-apps

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

React Native Mobile App Development

Skenix is providing React Native Development Services with qualified React Native App Developers. Get the best React Native App Development Services.

How React Native Is Shaping Mobile App Development

Are you a mobile app developer looking for more efficient tools for your projects? Mobile app development is getting tougher and tougher as the market continues to grow. As a developer, you need to develop Apps which meet the demands of your users. To achieve this, adopt the right tools, like the React Native development framework.

Top React Native Mobile App Development Companies in USA

Looking for top React Native mobile app development company in USA for Startups & Enterprise? Find out the top list of React Native mobile app development company in USA.

Which is the best React Native app development company in New York?

Hire top react native app development company in New York to build and develop custom react native mobile apps for Android & iOS with the latest features.