Skip to content

Instantly share code, notes, and snippets.

@ohmyjersh
Forked from adhithiravi/FingerPrint.js
Created September 26, 2018 16:26
Show Gist options
  • Save ohmyjersh/8bc70445c53c89d3c20fdc92ad97b567 to your computer and use it in GitHub Desktop.
Save ohmyjersh/8bc70445c53c89d3c20fdc92ad97b567 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import {
AlertIOS,
StyleSheet,
Text,
TouchableHighlight,
View,
NativeModules
}
import TouchID from 'react-native-touch-id'
class FingerPrint extends React.Component {
//config is optional to be passed in on Android
const optionalConfigObject = {
title: "Authentication Required", // Android
color: "#e00606", // Android,
fallbackLabel: "Show Passcode" // iOS (if empty, then label is hidden)
}
pressHandler() {
TouchID.authenticate('to demo this react-native component', optionalConfigObject)
.then(success => {
AlertIOS.alert('Authenticated Successfully');
})
.catch(error => {
AlertIOS.alert('Authentication Failed');
});
}
render() {
return (
<View>
<TouchableHighlight onPress={this.pressHandler}>
<Text>
Authenticate with Touch ID
</Text>
</TouchableHighlight>
</View>
);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment