Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Display Touch ID dialog on Android (if supported) #1312

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/action/auth-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,20 @@ class AuthAction {
// TouchID & KeyStore Authentication
//

async checkFingerprintHardwareAndEnrollment() {
const hasHardware = await this._Fingerprint.hasHardwareAsync();
const isEnrolled = await this._Fingerprint.isEnrolledAsync();
return hasHardware && isEnrolled ? true : false;
}

/**
* Try authenticating the user using either via TouchID/FaceID on iOS
* or a fingerprint reader on Android.
* @return {Promise<undefined>}
*/
async tryFingerprint() {
const hasHardware = await this._Fingerprint.hasHardwareAsync();
const isEnrolled = await this._Fingerprint.isEnrolledAsync();
if (!hasHardware || !isEnrolled) {
const hasFingerprint = await this.checkFingerprintHardwareAndEnrollment();
if (!hasFingerprint) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor 👍

return;
}
const msg = 'Unlock your Wallet';
Expand Down
5 changes: 4 additions & 1 deletion src/view/pin-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class PinView extends React.Component {

render() {
const { store, auth } = this.props;
const unlockText = this.props.auth.checkFingerprintHardwareAndEnrollment()
? 'Unlock with your pin or fingerprint'
: 'Unlock with your pin';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest using the Android's native FingerprintDialog api:

https://medium.com/exploring-android/exploring-android-p-fingerprint-dialog-fa672ae62c6f

There are react-native modules that seem to offer some type of dialog UI for Android as well:

https://github.com/jariz/react-native-fingerprint-android
https://github.com/hieuvp/react-native-fingerprint-scanner

But those seems to be full fledged replacements for the expo-local-authentication module that we're using. But if we can offer a native look and feel for auth on each platform it might be worth replacing that one:

https://docs.expo.io/versions/latest/sdk/local-authentication/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like FingerprintDialog has moved over to BiometricPrompt https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt.Builder

return (
<Background image="purple-gradient-bg">
<MainContent style={styles.content}>
Expand All @@ -47,7 +50,7 @@ class PinView extends React.Component {
<LightningWord height={31.2} width={245.7} />
</View>
<FormStretcher>
<Text>Unlock with your pin</Text>
<Text>{unlockText}</Text>
<PinBubbles pin={store.auth.pin} style={styles.bubbles} />
</FormStretcher>
<PinKeyboard
Expand Down