Skip to content

Commit

Permalink
feat(android): update androidx.biometric to 1.1.0 (latest stable)
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelyCpp committed Feb 26, 2021
1 parent 87f6000 commit 4f7e07c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.3'
}
}
}
Expand Down Expand Up @@ -61,7 +61,7 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'androidx.biometric:biometric:1.0.1'
implementation 'androidx.biometric:biometric:1.1.0'
}

def configureReactNativePom(def pom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import java.util.concurrent.Executor;

public class RNBiometricsModule extends ReactContextBaseJavaModule {

static final int authenticators = BiometricManager.Authenticators.BIOMETRIC_STRONG
| BiometricManager.Authenticators.BIOMETRIC_WEAK
| BiometricManager.Authenticators.DEVICE_CREDENTIAL;

public RNBiometricsModule(ReactApplicationContext reactContext) {
super(reactContext);
Expand All @@ -33,7 +35,10 @@ public void canAuthenticate(Promise promise) {
try {
ReactApplicationContext context = getReactApplicationContext();
BiometricManager biometricManager = BiometricManager.from(context);
boolean can = biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS;

int res = biometricManager.canAuthenticate(authenticators);
boolean can = res == BiometricManager.BIOMETRIC_SUCCESS;

promise.resolve(can);
} catch (Exception e) {
promise.reject(e);
Expand Down Expand Up @@ -68,9 +73,9 @@ public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationRes
BiometricPrompt prompt = new BiometricPrompt((FragmentActivity) activity, mainExecutor, authenticationCallback);

BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder()
.setAllowedAuthenticators(authenticators)
.setTitle(title)
.setSubtitle(subtitle)
.setDeviceCredentialAllowed(true)
.build();

prompt.authenticate(promptInfo);
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.37.0
FLIPPER_VERSION=0.74.0

0 comments on commit 4f7e07c

Please sign in to comment.