npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-smart-touch-id

v1.1.1

Published

Smart authentication with the native Touch ID popup for React Native app

Downloads

47

Readme

react-native-smart-touch-id

npm npm npm npm

Smart authentication with the native Touch ID popup for React Native app.

This component is compatible with React Native 0.25 and newer, only supports iOS.

Preview

react-native-smart-touch-id-preview

Installation

npm install react-native-smart-touch-id --save

Notice

It can only be used greater-than-equal react-native 0.4.0 for ios, if you want to use the package less-than react-native 0.4.0, use npm install [email protected] --save

Installation (iOS)

  • Drag RCTTouchId.xcodeproj to your project on Xcode.

  • Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag libRCTTouchId.a from the Products folder inside the RCTTouchId.xcodeproj.

  • Look for Header Search Paths and make sure it contains $(SRCROOT)/../../../react-native/React as recursive.

Full Demo

see ReactNativeComponentDemos

Usage


import React, {
  Component
} from 'react'
import {
  View,
  Text,
  Alert,
} from 'react-native'

import TouchId from 'react-native-smart-touch-id'
import Button from 'react-native-smart-button'

export default class TouchIdTest extends Component {

  render() {
    return (
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center', }}>
          <Button
            touchableType={'blur'}
            style={{marginVertical: 10, width: 300, justifyContent: 'center', height: 40, backgroundColor: 'red', borderRadius: 3, borderWidth: StyleSheet.hairlineWidth, borderColor: 'red', justifyContent: 'center',}}
            textStyle={{fontSize: 17,  color: 'white'}}
            onPress={this._isSupported}>
            verify if touchId is supported
          </Button>
          <Button
            touchableType={'blur'}
            style={{marginVertical: 10, width: 300, justifyContent: 'center', height: 40, backgroundColor: 'red', borderRadius: 3, borderWidth: StyleSheet.hairlineWidth, borderColor: 'red', justifyContent: 'center',}}
            textStyle={{fontSize: 17,  color: 'white'}}
            onPress={this._trggerTouchId}>
            trigger touch id
          </Button>
        </View>
    )
  }

  //_isSupported = () => {
  //  TouchId.isSupported( (error) => {
  //    if (error) {
  //      Alert.alert('TouchId is not supported!')
  //    } else {
  //      Alert.alert('TouchId is supported!')
  //    }
  //  })
  //}

  _isSupported = async () => {
      try {
          await TouchId.isSupported()
          Alert.alert('TouchId is supported!')
      } catch(e) {
          Alert.alert('TouchId is not supported!')
      }
  }

  //_trggerTouchId = () => {
  //    let description = 'Verify the existing mobile phone fingerprint using the home key'
  //    //let title       //fallback button title will be default as 'Enter Password'(localized)
  //    //let title = ""  //fallback button will be hidden
  //    let title = "Verify Password"   //fallback button title will be 'Verify Password'(unlocalized)
  //    TouchId.verify(description, title, (error) => {
  //        if (error) {
  //            if (error.message == '-3') {
  //                //fallback button is pressed
  //                Alert.alert('errorCode: ' + error.message + ' verify failed, user wants to ' + title)
  //            }
  //            else {
  //                Alert.alert('errorCode: ' + error.message + ' verify failed')
  //            }
  //        } else {
  //            Alert.alert('verify succeeded')
  //        }
  //    })
  //}

  _trggerTouchId = async () => {
      let description = 'Verify the existing mobile phone fingerprint using the home key'
      //let title       //fallback button title will be default as 'Enter Password'(localized)
      //let title = ""  //fallback button will be hidden
      let title = "Verify Password"   //fallback button title will be 'Verify Password'(unlocalized)
      try {
          await TouchId.verify({
              description,
              title,
          });
          //await TouchId.verify("123123123123");
          Alert.alert('verify succeeded')
      } catch(e) {
          if (e.code == '-3') {
              //fallback button is pressed
              Alert.alert('errorCode: ' + e.code + ' verify failed, user wants to ' + title)
          }
          else {
              Alert.alert('errorCode: ' + e.code + ' verify failed')
          }
      }
  }

}

Errors

There are various reasons why authenticating with Touch ID may fail. Whenever calling Touch ID authentication fails, TouchId.verify will return an error code.

More information on errors can be found in Apple's Documentation.