-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,61 @@ | ||
# react-native-touch-sensor | ||
# react-native-touch-sensor | ||
|
||
Bridging for accesing the Touch Sensor on both iOS and Android using TouchID and Android Fingerprint | ||
|
||
# Installation | ||
|
||
`npm install -s react-native-touch-sensor` | ||
`react-native link react-native-touch-sensor` | ||
|
||
# Android Setup | ||
|
||
Be sure to add the Fingerprint permission to your `AndroidManaifest.xml` file | ||
`<uses-permission android:name="android.permission.USE_FINGERPRINT" />` | ||
|
||
# Example | ||
``` | ||
import React, { Component } from 'react' | ||
import { View, Text, Button } from 'react-native' | ||
import Touch from 'react-native-touch-sensor' | ||
export default class TouchExample extends Component { | ||
_isSupported() { | ||
Touch.isSupported() | ||
.then( () => alert('Android fingerprint supported')) | ||
.catch( (error) => alert(`unsupported: ${error}`)) | ||
} | ||
_authenticatePressed() { | ||
Touch.authenticate("To test out the app") | ||
.then( () => alert('authenticated') ) | ||
.catch( (error) => alert(`Failed: ${error}`) ) | ||
} | ||
render() { | ||
return ( | ||
<View> | ||
<Text>Check to see if all conditions are met to use Fingerprint</Text> | ||
<Button | ||
title="IsSupported()" | ||
onPress={() => this._isSupported()} | ||
/> | ||
<Text>Begins Authentication process</Text> | ||
<Button | ||
title="Authenticate()" | ||
onPress={() => this._authenticatePressed()} | ||
/> | ||
</View> | ||
); | ||
} | ||
} | ||
``` | ||
|
||
# Reference: | ||
TouchID: https://github.com/naoufal/react-native-touch-id | ||
AndroidFingerprint: https://github.com/googlesamples/android-FingerprintDialog | ||
https://github.com/jariz/react-native-fingerprint-android | ||
https://material.io/guidelines/patterns/fingerprint.html#fingerprint-enrollment | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* Sample React Native App | ||
* https://github.com/facebook/react-native | ||
* @flow | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
import { | ||
AppRegistry, | ||
StyleSheet, | ||
View, | ||
Text, | ||
Button | ||
} from 'react-native'; | ||
|
||
import Touch from 'react-native-touch-sensor' | ||
|
||
export default class TouchExample extends Component { | ||
|
||
|
||
_isSupported() { | ||
Touch.isSupported() | ||
.then( () => alert('Android fingerprint supported')) | ||
.catch( (error) => alert(`unsupported: ${error}`)) | ||
} | ||
_hasPermission() { | ||
Touch.hasPermissions() | ||
.then( () => alert('Permissions accepted')) | ||
.catch( (error) => alert(`unsupported: ${error}`)) | ||
} | ||
|
||
_hardwareSupported() { | ||
Touch.hardwareSupported() | ||
.then( () => alert('Hardware supports it')) | ||
.catch( (error) => alert(`unsupported: ${error}`)) | ||
} | ||
|
||
_hasFingerprints() { | ||
Touch.hasFingerprints() | ||
.then( () => alert('User Has fingerprints')) | ||
.catch( (error) => alert(`no fingerprints: ${error}`)) | ||
} | ||
|
||
_authenticatePressed() { | ||
Touch.authenticate("To test out the app") | ||
.then( () => alert('authenticated') ) | ||
.catch( (error) => alert(`Failed: ${error}`) ) | ||
} | ||
|
||
|
||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<Text>Check to see if all conditions are met to use Fingerprint</Text> | ||
<Button | ||
title="IsSupported()" | ||
onPress={() => this._isSupported()} | ||
/> | ||
<Text>Check to see if the user has enabled system permissions</Text> | ||
<Button | ||
title="HasPermissions()" | ||
onPress={() => this._hasPermission()} | ||
/> | ||
<Text>Checks The hardware support</Text> | ||
<Button | ||
title="HardwareSupported()" | ||
onPress={() => this._hardwareSupported()} | ||
/> | ||
<Text>Checks if the user has fingerprints on their device</Text> | ||
<Button | ||
title="HasFingerprints()" | ||
onPress={() => this._hasFingerprints()} | ||
/> | ||
<Text>Begins Authentication process</Text> | ||
<Button | ||
title="Authenticate()" | ||
onPress={() => this._authenticatePressed()} | ||
/> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
}, | ||
welcome: { | ||
fontSize: 20, | ||
textAlign: 'center', | ||
margin: 10, | ||
}, | ||
instructions: { | ||
textAlign: 'center', | ||
color: '#333333', | ||
marginBottom: 5, | ||
}, | ||
}); | ||
|
||
AppRegistry.registerComponent('TouchExample', () => TouchExample); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Sample React Native App | ||
* https://github.com/facebook/react-native | ||
* @flow | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
import { | ||
AppRegistry, | ||
StyleSheet, | ||
View, | ||
Text, | ||
Button | ||
} from 'react-native'; | ||
|
||
import Touch from 'react-native-touch-sensor' | ||
|
||
export default class TouchExample extends Component { | ||
|
||
_supportedPressed() { | ||
Touch.isSupported() | ||
.then( () => alert('supported')) | ||
.catch( (error) => alert(`unsupported: ${error}`)) | ||
} | ||
|
||
_authenticatePressed() { | ||
Touch.authenticate("To test out the app") | ||
.then( () => alert('authenticated') ) | ||
.catch( (error) => alert(`Failed: ${error}`) ) | ||
} | ||
|
||
|
||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<Button | ||
title="IsSupported()" | ||
onPress={() => this._supportedPressed()} | ||
/> | ||
<Text> space </Text> | ||
<Button | ||
title="Authenticate()" | ||
onPress={() => this._authenticatePressed()} | ||
/> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
}, | ||
welcome: { | ||
fontSize: 20, | ||
textAlign: 'center', | ||
margin: 10, | ||
}, | ||
instructions: { | ||
textAlign: 'center', | ||
color: '#333333', | ||
marginBottom: 5, | ||
}, | ||
}); | ||
|
||
AppRegistry.registerComponent('TouchExample', () => TouchExample); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.