{"_id":"@ammarahmed/react-native-fingerprint-scanner","_rev":"2-18421553581eb0517963c92dd939db10","name":"@ammarahmed/react-native-fingerprint-scanner","dist-tags":{"latest":"5.0.1"},"versions":{"5.0.0":{"name":"@ammarahmed/react-native-fingerprint-scanner","version":"5.0.0","keywords":["react-native","react-native-component","react-component","react","native","touch","touchid","touch-id","fingerprint","fingerprint-scanner","authentication","authenticate","auth","face-id","faceid","biometrics"],"author":{"url":"https://github.com/hieuvp","name":"Hieu Van"},"license":"MIT","_id":"@ammarahmed/react-native-fingerprint-scanner@5.0.0","maintainers":[{"name":"ammarahm-ed","email":"ammarahmed6506@gmail.com"}],"homepage":"https://github.com/hieuvp/react-native-fingerprint-scanner#readme","bugs":{"url":"https://github.com/hieuvp/react-native-fingerprint-scanner/issues"},"dist":{"shasum":"8f2cd6be085d0eb7107efa08099f764feb18408d","tarball":"https://registry.npmjs.org/@ammarahmed/react-native-fingerprint-scanner/-/react-native-fingerprint-scanner-5.0.0.tgz","fileCount":23,"integrity":"sha512-X0O6swQkDz1TEjqO+tIZLVt+Olr7j1lq4BwtA8OKn9nJp5kdO+I1JurN7c7zYSrYMJiJcPcuiP8FShjXj8fcsQ==","signatures":[{"sig":"MEUCIQCnY3EksaCajIlrrJL85ENTh4oEmNZEIW3YNK7v8kOBywIgWQPITfjvYlc79DJNmn5mg4i+tT5ca0w7vCIxh+C9+Ag=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":64075},"main":"index.js","types":"index.d.ts","gitHead":"7beac32968684b13948f141d84b48e700c838591","scripts":{"ios":"cd examples && react-native run-ios","android":"cd examples && react-native run-android","cleanup":"rm -rf android/build ios/build yarn.lock node_modules && cd examples && rm -rf android/build android/app/build ios/build yarn.lock node_modules","cleanup:android":"cd examples/android && ./gradlew clean","cleanup:install":"yarn cleanup && yarn && cd examples && yarn && cd .. && yarn symlink && yarn cleanup:android"},"_npmUser":{"name":"ammarahm-ed","email":"ammarahmed6506@gmail.com"},"repository":{"url":"git+https://github.com/hieuvp/react-native-fingerprint-scanner.git","type":"git"},"_npmVersion":"10.5.2","description":"React Native Biometrics Scanner for Android and iOS","directories":{},"_nodeVersion":"20.12.2","_hasShrinkwrap":false,"peerDependencies":{"react-native":">=0.60 <1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-native-fingerprint-scanner_5.0.0_1732085419765_0.35078282386951765","host":"s3://npm-registry-packages"}},"5.0.1":{"name":"@ammarahmed/react-native-fingerprint-scanner","version":"5.0.1","description":"React Native Biometrics Scanner for Android and iOS","main":"index.js","keywords":["react-native","react-native-component","react-component","react","native","touch","touchid","touch-id","fingerprint","fingerprint-scanner","authentication","authenticate","auth","face-id","faceid","biometrics"],"peerDependencies":{"react-native":">=0.60 <1.0.0"},"repository":{"type":"git","url":"git+https://github.com/hieuvp/react-native-fingerprint-scanner.git"},"homepage":"https://github.com/hieuvp/react-native-fingerprint-scanner#readme","author":{"name":"Hieu Van","url":"https://github.com/hieuvp"},"license":"MIT","types":"index.d.ts","scripts":{"android":"cd examples && react-native run-android","ios":"cd examples && react-native run-ios","cleanup":"rm -rf android/build ios/build yarn.lock node_modules && cd examples && rm -rf android/build android/app/build ios/build yarn.lock node_modules","cleanup:android":"cd examples/android && ./gradlew clean","cleanup:install":"yarn cleanup && yarn && cd examples && yarn && cd .. && yarn symlink && yarn cleanup:android"},"_id":"@ammarahmed/react-native-fingerprint-scanner@5.0.1","gitHead":"d9962022b2a3f622defdc929b4ceefa30cf2bce5","bugs":{"url":"https://github.com/hieuvp/react-native-fingerprint-scanner/issues"},"_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-7n40K/zsA21pAQH5l5n0XJQZMmJcbniTj/MOPvyowXb0xGAc+NZX6DdGiQvw47iipIIgUJNKdew+WqQqvh2/kQ==","shasum":"587475f98d43f0ee65ddca8aaef05243dbff7879","tarball":"https://registry.npmjs.org/@ammarahmed/react-native-fingerprint-scanner/-/react-native-fingerprint-scanner-5.0.1.tgz","fileCount":23,"unpackedSize":64039,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF3puggRKaZ6B66pdmQb8WUbcK1gXJQyF08y5vHIQH2MAiBkcSsm1BwK7j3k1meeBW7RYf3Ylfm19rVsaQLvDbtbTw=="}]},"_npmUser":{"name":"ammarahm-ed","email":"ammarahmed6506@gmail.com"},"directories":{},"maintainers":[{"name":"ammarahm-ed","email":"ammarahmed6506@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-native-fingerprint-scanner_5.0.1_1760938008942_0.3413677894017524"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-20T06:50:19.655Z","modified":"2025-10-20T05:26:49.845Z","5.0.0":"2024-11-20T06:50:19.926Z","5.0.1":"2025-10-20T05:26:49.112Z"},"bugs":{"url":"https://github.com/hieuvp/react-native-fingerprint-scanner/issues"},"author":{"name":"Hieu Van","url":"https://github.com/hieuvp"},"license":"MIT","homepage":"https://github.com/hieuvp/react-native-fingerprint-scanner#readme","keywords":["react-native","react-native-component","react-component","react","native","touch","touchid","touch-id","fingerprint","fingerprint-scanner","authentication","authenticate","auth","face-id","faceid","biometrics"],"repository":{"type":"git","url":"git+https://github.com/hieuvp/react-native-fingerprint-scanner.git"},"description":"React Native Biometrics Scanner for Android and iOS","maintainers":[{"name":"ammarahm-ed","email":"ammarahmed6506@gmail.com"}],"readme":"# React Native Fingerprint Scanner\n\n[![React Native Version](https://img.shields.io/badge/react--native-latest-blue.svg?style=flat-square)](http://facebook.github.io/react-native/releases)\n[![Version](https://img.shields.io/npm/v/react-native-fingerprint-scanner.svg)](https://www.npmjs.com/package/react-native-fingerprint-scanner)\n[![NPM](https://img.shields.io/npm/dm/react-native-fingerprint-scanner.svg)](https://www.npmjs.com/package/react-native-fingerprint-scanner)\n\nReact Native Fingerprint Scanner is a [React Native](http://facebook.github.io/react-native/) library for authenticating users with Fingerprint (TouchID).\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Compatibility](#compatibility)\n- [Example](#example)\n- [API](#api)\n- [License](#license)\n\n### iOS Version\nThe usage of the TouchID is based on a framework, named **Local Authentication**.\n\nIt provides a **Default View** that prompts the user to place a finger to the iPhone’s button for scanning.\n\n<div>\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/ios-availability.png\" height=\"600\">\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/ios-authentication.gif\" height=\"600\">\n</div>\n\n### Android Version\n4.0.0 Prefers the new native Android BiometricPrompt lib on any Android >= v23 (M)\n4.0.0 also DEPRECATES support for the legacy library that provides support for Samsung & MeiZu phones\n\n3.0.2 and below: \nUsing an expandable Android Fingerprint API library, which combines [Samsung](http://developer.samsung.com/galaxy/pass#) and [MeiZu](http://open-wiki.flyme.cn/index.php?title=%E6%8C%87%E7%BA%B9%E8%AF%86%E5%88%ABAPI)'s official Fingerprint API.\n\nSamsung and MeiZu's Fingerprint SDK supports most devices which system versions less than Android 6.0.\n\n<div>\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/android-availability.png\" height=\"600\">\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/android-authentication.gif\" height=\"600\">\n</div>\n\n## Installation\n\n```sh\n$ npm install react-native-fingerprint-scanner --save\n```\nor\n```sh\n$ yarn add react-native-fingerprint-scanner\n```\n\n### Automatic Configuration\nFor RN >= 0.60\n```sh\n$ cd ios && pod install\n```\n\nFor RN < 0.60, use react-native link to add the library to your project:\n```sh\n$ react-native link react-native-fingerprint-scanner\n```\n\n### Manual Configuration\n\n#### iOS\n\n1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n2. Go to `node_modules` ➜ `react-native-fingerprint-scanner` and add `ReactNativeFingerprintScanner.xcodeproj`\n3. In XCode, in the project navigator, select your project. Add `libReactNativeFingerprintScanner.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`\n4. Run your project (`Cmd+R`)\n\n#### Android\n\n1. Open up `android/app/src/main/java/[...]/MainApplication.java`\n  - Add `import com.hieuvp.fingerprint.ReactNativeFingerprintScannerPackage;` to the imports at the top of the file\n  - Add `new ReactNativeFingerprintScannerPackage()` to the list returned by the `getPackages()` method\n2. Append the following lines to `android/settings.gradle`:\n  \t```\n  \tinclude ':react-native-fingerprint-scanner'\n  \tproject(':react-native-fingerprint-scanner').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fingerprint-scanner/android')\n  \t```\n3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n  \t```\n    implementation project(':react-native-fingerprint-scanner')\n  \t```\n\n### App Permissions\n\nAdd the following permissions to their respective files:\n\n#### Android\nIn your `AndroidManifest.xml`:\n\nAPI level 28+ (Uses Android native BiometricPrompt) ([Reference](https://developer.android.com/reference/android/Manifest.permission#USE_BIOMETRIC))\n```xml\n<uses-permission android:name=\"android.permission.USE_BIOMETRIC\" />\n```\n\nAPI level 23-28 (Uses Android native FingerprintCompat) [Reference](https://developer.android.com/reference/android/Manifest.permission#USE_FINGERPRINT)) \n```xml\n<uses-permission android:name=\"android.permission.USE_FINGERPRINT\" />\n```\n\n// DEPRECATED in 4.0.0\nAPI level <23 (Uses device-specific native fingerprinting, if available - Samsung & MeiZu only) [Reference](https://developer.android.com/reference/android/Manifest.permission#USE_FINGERPRINT)) \n```xml\n<uses-permission android:name=\"android.permission.USE_FINGERPRINT\" />\n```\n#### iOS\nIn your `Info.plist`:\n\n```xml\n<key>NSFaceIDUsageDescription</key>\n<string>$(PRODUCT_NAME) requires FaceID access to allows you quick and secure access.</string>\n```\n\n### Extra Configuration\n\n1. Make sure the following versions are all correct in `android/app/build.gradle`\n    ```\n    // API v29 enables FaceId\n    android {\n        compileSdkVersion 29\n        buildToolsVersion \"29.0.2\"\n    ...\n        defaultConfig {\n          targetSdkVersion 29\n    ```\n\n2. Add necessary rules to `android/app/proguard-rules.pro` if you are using proguard:\n    ```\n    # MeiZu Fingerprint\n\n    // DEPRECATED in 4.0.0\n    -keep class com.fingerprints.service.** { *; }\n    -dontwarn com.fingerprints.service.**\n\n    # Samsung Fingerprint\n\n    // DEPRECATED in 4.0.0\n    -keep class com.samsung.android.sdk.** { *; }\n    -dontwarn com.samsung.android.sdk.**\n    ```\n\n## Compatibility\n\n* For Gradle < 3 you MUST install react-native-fingerprint-scanner at version <= 2.5.0\n* For RN >= 0.57 and/or Gradle >= 3 you MUST install react-native-fingerprint-scanner at version >= 2.6.0\n* For RN >= 0.60 you MUST install react-native-fingerprint-scanner at version >= 3.0.0\n* For Android native Face Unlock, MUST use >= 4.0.0\n\n## Example\n\n[Example Source Code](https://github.com/hieuvp/react-native-fingerprint-scanner/tree/master/examples)\n\n**iOS Implementation**\n```javascript\nimport React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport { AlertIOS } from 'react-native';\nimport FingerprintScanner from 'react-native-fingerprint-scanner';\n\nclass FingerprintPopup extends Component {\n\n  componentDidMount() {\n    FingerprintScanner\n      .authenticate({ description: 'Scan your fingerprint on the device scanner to continue' })\n      .then(() => {\n        this.props.handlePopupDismissed();\n        AlertIOS.alert('Authenticated successfully');\n      })\n      .catch((error) => {\n        this.props.handlePopupDismissed();\n        AlertIOS.alert(error.message);\n      });\n  }\n\n  render() {\n    return false;\n  }\n}\n\nFingerprintPopup.propTypes = {\n  handlePopupDismissed: PropTypes.func.isRequired,\n};\n\nexport default FingerprintPopup;\n```\n\n**Android Implementation**\n```javascript\n\nimport React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n  Alert,\n  Image,\n  Text,\n  TouchableOpacity,\n  View,\n  ViewPropTypes,\n  Platform,\n} from 'react-native';\n\nimport FingerprintScanner from 'react-native-fingerprint-scanner';\nimport styles from './FingerprintPopup.component.styles';\nimport ShakingText from './ShakingText.component';\n\n\n// - this example component supports both the\n//   legacy device-specific (Android < v23) and\n//   current (Android >= 23) biometric APIs\n// - your lib and implementation may not need both\nclass BiometricPopup extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      errorMessageLegacy: undefined,\n      biometricLegacy: undefined\n    };\n\n    this.description = null;\n  }\n\n  componentDidMount() {\n    if (this.requiresLegacyAuthentication()) {\n      this.authLegacy();\n    } else {\n      this.authCurrent();\n    }\n  }\n\n  componentWillUnmount = () => {\n    FingerprintScanner.release();\n  }\n\n  requiresLegacyAuthentication() {\n    return Platform.Version < 23;\n  }\n\n  authCurrent() {\n    FingerprintScanner\n      .authenticate({ title: 'Log in with Biometrics' })\n      .then(() => {\n        this.props.onAuthenticate();\n      });\n  }\n\n  authLegacy() {\n    FingerprintScanner\n      .authenticate({ onAttempt: this.handleAuthenticationAttemptedLegacy })\n      .then(() => {\n        this.props.handlePopupDismissedLegacy();\n        Alert.alert('Fingerprint Authentication', 'Authenticated successfully');\n      })\n      .catch((error) => {\n        this.setState({ errorMessageLegacy: error.message, biometricLegacy: error.biometric });\n        this.description.shake();\n      });\n  }\n\n  handleAuthenticationAttemptedLegacy = (error) => {\n    this.setState({ errorMessageLegacy: error.message });\n    this.description.shake();\n  };\n\n  renderLegacy() {\n    const { errorMessageLegacy, biometricLegacy } = this.state;\n    const { style, handlePopupDismissedLegacy } = this.props;\n\n    return (\n      <View style={styles.container}>\n        <View style={[styles.contentContainer, style]}>\n\n          <Image\n            style={styles.logo}\n            source={require('./assets/finger_print.png')}\n          />\n\n          <Text style={styles.heading}>\n            Biometric{'\\n'}Authentication\n          </Text>\n          <ShakingText\n            ref={(instance) => { this.description = instance; }}\n            style={styles.description(!!errorMessageLegacy)}>\n            {errorMessageLegacy || `Scan your ${biometricLegacy} on the\\ndevice scanner to continue`}\n          </ShakingText>\n\n          <TouchableOpacity\n            style={styles.buttonContainer}\n            onPress={handlePopupDismissedLegacy}\n          >\n            <Text style={styles.buttonText}>\n              BACK TO MAIN\n            </Text>\n          </TouchableOpacity>\n\n        </View>\n      </View>\n    );\n  }\n\n\n  render = () => {\n    if (this.requiresLegacyAuthentication()) {\n      return this.renderLegacy();\n    }\n\n    // current API UI provided by native BiometricPrompt\n    return null;\n  }\n}\n\nBiometricPopup.propTypes = {\n  onAuthenticate: PropTypes.func.isRequired,\n  handlePopupDismissedLegacy: PropTypes.func,\n  style: ViewPropTypes.style,\n};\n\nexport default BiometricPopup;\n```\n\n## API\n\n### `isSensorAvailable()`: (Android, iOS)\nChecks if Fingerprint Scanner is able to be used by now.\n\n- Returns a `Promise<string>`\n- `biometryType: String` - The type of biometric authentication supported by the device.\n  - iOS: biometryType = 'Touch ID', 'Face ID'\n  - Android: biometryType = 'Biometrics'\n- `error: FingerprintScannerError { name, message, biometric }` - The name and message of failure and the biometric type in use.\n\n```javascript\ncomponentDidMount() {\n  FingerprintScanner\n    .isSensorAvailable()\n    .then(biometryType => this.setState({ biometryType }))\n    .catch(error => this.setState({ errorMessage: error.message }));\n}\n```\n\n### `authenticate({ description, fallbackEnabled })`: (iOS)\nStarts Fingerprint authentication on iOS.\n\n- Returns a `Promise`\n- `description: String` - the string to explain the request for user authentication.\n- `fallbackEnabled: Boolean` - default to `true`, whether to display fallback button (e.g. Enter Password).\n\n```javascript\ncomponentDidMount() {\n  FingerprintScanner\n    .authenticate({ description: 'Scan your fingerprint on the device scanner to continue' })\n    .then(() => {\n      this.props.handlePopupDismissed();\n      AlertIOS.alert('Authenticated successfully');\n    })\n    .catch((error) => {\n      this.props.handlePopupDismissed();\n      AlertIOS.alert(error.message);\n    });\n}\n```\n\n### `authenticate({ title=\"Log In\", subTitle, description, cancelButton=\"Cancel\", onAttempt=() => (null) })`: (Android)\nStarts Fingerprint authentication on Android.\n\n- Returns a `Promise`\n- `title: String` the title text to display in the native Android popup\n- `subTitle: String` the sub title text to display in the native Android popup\n- `description: String` the description text to display in the native Android popup\n- `cancelButton: String` the cancel button text to display in the native Android popup\n- `onAttempt: Function` - a callback function when users are trying to scan their fingerprint but failed.\n\n```javascript\ncomponentDidMount() {\n  if (requiresLegacyAuthentication()) {\n    authLegacy();\n  } else {\n    authCurrent();\n  }\n}\n\ncomponentWillUnmount = () => {\n  FingerprintScanner.release();\n}\n\nrequiresLegacyAuthentication() {\n  return Platform.Version < 23;\n}\n\nauthCurrent() {\n  FingerprintScanner\n    .authenticate({ title: 'Log in with Biometrics' })\n    .then(() => {\n      this.props.onAuthenticate();\n    });\n}\n\nauthLegacy() {\n  FingerprintScanner\n    .authenticate({ onAttempt: this.handleAuthenticationAttemptedLegacy })\n    .then(() => {\n      this.props.handlePopupDismissedLegacy();\n      Alert.alert('Fingerprint Authentication', 'Authenticated successfully');\n    })\n    .catch((error) => {\n      this.setState({ errorMessageLegacy: error.message, biometricLegacy: error.biometric });\n      this.description.shake();\n    });\n}\n\nhandleAuthenticationAttemptedLegacy = (error) => {\n  this.setState({ errorMessageLegacy: error.message });\n  this.description.shake();\n};\n```\n\n### `release()`: (Android)\nStops fingerprint scanner listener, releases cache of internal state in native code, and cancels native prompt if visible.\n\n- Returns a `Void`\n\n```javascript\ncomponentWillUnmount() {\n  FingerprintScanner.release();\n}\n```\n\n### `Types of Biometrics`\n\n| Value | OS | Description|\n|---|---|---|\n| Touch ID | iOS | |\n| Face ID | iOS | |\n| Biometrics | Android | Refers to the biometric set as preferred on the device |\n\n### `Errors`\n\n| Name | Message |\n|---|---|\n| AuthenticationNotMatch | No match |\n| AuthenticationFailed | Authentication was not successful because the user failed to provide valid credentials |\n| AuthenticationTimeout | Authentication was not successful because the operation timed out |\n| AuthenticationProcessFailed | 'Sensor was unable to process the image. Please try again |\n| UserCancel | Authentication was canceled by the user - e.g. the user tapped Cancel in the dialog |\n| UserFallback | Authentication was canceled because the user tapped the fallback button (Enter Password) |\n| SystemCancel | Authentication was canceled by system - e.g. if another application came to foreground while the authentication dialog was up |\n| PasscodeNotSet | Authentication could not start because the passcode is not set on the device |\n| DeviceLocked | Authentication was not successful, the device currently in a lockout of 30 seconds |\n| DeviceLockedPermanent | Authentication was not successful, device must be unlocked via password |\n| DeviceOutOfMemory | Authentication could not proceed because there is not enough free memory on the device |\n| HardwareError | A hardware error occurred |\n| FingerprintScannerUnknownError | Could not authenticate for an unknown reason |\n| FingerprintScannerNotSupported | Device does not support Fingerprint Scanner |\n| FingerprintScannerNotEnrolled  | Authentication could not start because Fingerprint Scanner has no enrolled fingers |\n| FingerprintScannerNotAvailable | Authentication could not start because Fingerprint Scanner is not available on the device |\n\n## License\n\nMIT\n","readmeFilename":"README.md"}