@exodus/react-native-biometrics 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,11 +40,25 @@ public final class RNBiometricsModule extends ReactContextBaseJavaModule {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@ReactMethod
|
|
43
|
-
public void authenticate(String title, String subtitle, String cancelButtonText, Promise promise) {
|
|
43
|
+
public void authenticate(String title, String subtitle, String cancelButtonText, boolean fallbackToPasscode, Promise promise) {
|
|
44
44
|
context.getCurrentActivity().runOnUiThread(new Runnable() {
|
|
45
45
|
@Override
|
|
46
46
|
public void run() {
|
|
47
47
|
try {
|
|
48
|
+
int authenticators = fallbackToPasscode
|
|
49
|
+
? BiometricManager.Authenticators.BIOMETRIC_STRONG | BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
|
50
|
+
: BiometricManager.Authenticators.BIOMETRIC_STRONG;
|
|
51
|
+
|
|
52
|
+
BiometricPrompt.PromptInfo.Builder promptInfoBuilder = new BiometricPrompt.PromptInfo.Builder()
|
|
53
|
+
.setAllowedAuthenticators(authenticators)
|
|
54
|
+
.setTitle(title)
|
|
55
|
+
.setSubtitle(subtitle);
|
|
56
|
+
|
|
57
|
+
// Negative button text cannot be set when DEVICE_CREDENTIAL is allowed.
|
|
58
|
+
if (!fallbackToPasscode) {
|
|
59
|
+
promptInfoBuilder.setNegativeButtonText(cancelButtonText);
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
new BiometricPrompt(
|
|
49
63
|
(FragmentActivity) context.getCurrentActivity(),
|
|
50
64
|
ContextCompat.getMainExecutor(context),
|
|
@@ -61,14 +75,7 @@ public final class RNBiometricsModule extends ReactContextBaseJavaModule {
|
|
|
61
75
|
promise.resolve(true);
|
|
62
76
|
}
|
|
63
77
|
}
|
|
64
|
-
).authenticate(
|
|
65
|
-
new BiometricPrompt.PromptInfo.Builder()
|
|
66
|
-
.setAllowedAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG)
|
|
67
|
-
.setTitle(title)
|
|
68
|
-
.setSubtitle(subtitle)
|
|
69
|
-
.setNegativeButtonText(cancelButtonText)
|
|
70
|
-
.build()
|
|
71
|
-
);
|
|
78
|
+
).authenticate(promptInfoBuilder.build());
|
|
72
79
|
|
|
73
80
|
} catch (Exception e) {
|
|
74
81
|
promise.reject(e);
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
isSupported: async () => {
|
|
7
7
|
return AndroidBiometrics.isSupported();
|
|
8
8
|
},
|
|
9
|
-
authenticate: async ({ title, subtitle, cancelButtonText }) => {
|
|
10
|
-
return AndroidBiometrics.authenticate(title, subtitle, cancelButtonText);
|
|
9
|
+
authenticate: async ({ title, subtitle, cancelButtonText, fallbackToPasscode = false }) => {
|
|
10
|
+
return AndroidBiometrics.authenticate(title, subtitle, cancelButtonText, fallbackToPasscode);
|
|
11
11
|
}
|
|
12
12
|
}
|