Skip to content

Commit 4f7e07c

Browse files
committed
feat(android): update androidx.biometric to 1.1.0 (latest stable)
1 parent 87f6000 commit 4f7e07c

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ buildscript {
2121
jcenter()
2222
}
2323
dependencies {
24-
classpath 'com.android.tools.build:gradle:3.4.1'
24+
classpath 'com.android.tools.build:gradle:3.4.3'
2525
}
2626
}
2727
}
@@ -61,7 +61,7 @@ repositories {
6161
dependencies {
6262
//noinspection GradleDynamicVersion
6363
implementation 'com.facebook.react:react-native:+' // From node_modules
64-
implementation 'androidx.biometric:biometric:1.0.1'
64+
implementation 'androidx.biometric:biometric:1.1.0'
6565
}
6666

6767
def configureReactNativePom(def pom) {

android/src/main/java/com/smallcase/rnbiometrics/RNBiometricsModule.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import java.util.concurrent.Executor;
1818

1919
public class RNBiometricsModule extends ReactContextBaseJavaModule {
20-
20+
static final int authenticators = BiometricManager.Authenticators.BIOMETRIC_STRONG
21+
| BiometricManager.Authenticators.BIOMETRIC_WEAK
22+
| BiometricManager.Authenticators.DEVICE_CREDENTIAL;
2123

2224
public RNBiometricsModule(ReactApplicationContext reactContext) {
2325
super(reactContext);
@@ -33,7 +35,10 @@ public void canAuthenticate(Promise promise) {
3335
try {
3436
ReactApplicationContext context = getReactApplicationContext();
3537
BiometricManager biometricManager = BiometricManager.from(context);
36-
boolean can = biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS;
38+
39+
int res = biometricManager.canAuthenticate(authenticators);
40+
boolean can = res == BiometricManager.BIOMETRIC_SUCCESS;
41+
3742
promise.resolve(can);
3843
} catch (Exception e) {
3944
promise.reject(e);
@@ -68,9 +73,9 @@ public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationRes
6873
BiometricPrompt prompt = new BiometricPrompt((FragmentActivity) activity, mainExecutor, authenticationCallback);
6974

7075
BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder()
76+
.setAllowedAuthenticators(authenticators)
7177
.setTitle(title)
7278
.setSubtitle(subtitle)
73-
.setDeviceCredentialAllowed(true)
7479
.build();
7580

7681
prompt.authenticate(promptInfo);

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ android.useAndroidX=true
2525
android.enableJetifier=true
2626

2727
# Version of flipper SDK to use with React Native
28-
FLIPPER_VERSION=0.37.0
28+
FLIPPER_VERSION=0.74.0

0 commit comments

Comments
 (0)