Giter Site home page Giter Site logo

rodrigosoareschaves / react-native-nfc-card-reader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jackbayliss/react-native-nfc-card-reader

0.0 0.0 0.0 155 KB

React Native NFC card reader, designed for reading debit/credit cards.

Home Page: https://github.com/jackbayliss/react-native-nfc-card-reader

License: MIT License

JavaScript 0.94% Java 99.06%

react-native-nfc-card-reader's Introduction

react-native-nfc-card-reader

Fork

This is a fork of jackbayliss/react-native-nfc-card-reader repo with the CardNfcUtils integrated to the repo to avoid issues in Android 12. The issue in case was something related to Target S+ compatibilities that was happening on class: com.pro100svitlo.creditCardNfcReader.utils.CardNfcUtils

Description

This package is specifically designed to scan credit/debit cards using an Android devices NFC reader and return the card number, expiry and card type.

This package will only work on Android and isn't available for iOS as of 2020 because Apple do not allow 3rd party iPhone apps to use the Core NFC framework.

Getting started

$ npm install react-native-nfc-card-reader --save

For Gradle 7.0 and greater you can do:

npm install "https://github.com/jackbayliss/react-native-nfc-card-reader.git#gradle7.0" --save

Mostly automatic installation

$ react-native link react-native-nfc-card-reader

Usage

import NfcCardReader from 'react-native-nfc-card-reader';

NfcCardReader.startNfc(function(cardDetails){
     // Card details contain the callback data below, see the options.
     that.setState({cardNumber : cardDetails.cardNumber})
     that.setState({expiryDate : cardDetails.expiryDate})
     that.setState({cardType : cardDetails.cardType})
 })

Ensure you add the following to your AndroidManifest.xml located in android\app\src\main

<activity android:name="com.jackbayliss.nfcreader.NfcCardReaderActivity"/>

Methods

startNfc(callback) -> Will start the NFC Activity and expects a callback function that will return the card details it's scanned.

Callback data

cardType -> Provides the type of the card scanned.

cardNumber -> Provides the full card number scanned.

expiryDate -> Providers the expiry date of the card scanned.

firstName -> Card owners first name.

lastName -> Card owners last name.

Example App

You can find the sample app here

Contributing

I am by no means an Android developer, but saw this as a huge thing no one had produced for React Native. So, if you can expand or improve on my basic implementation feel free to create a pull request.

License

MIT - expanded from here

A special thanks to pro100svitlo for their library which gave me the ability to create this module. A special thanks to decoder10 for fixing a few issues, and adding firstname / lastname - as well as allowing any NFC cards to be scanned.

react-native-nfc-card-reader's People

Contributors

jackbayliss avatar dependabot[bot] avatar rodrigosoareschaves avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.