简体   繁体   English

React Native Fingerprint Scanner 花费太多时间进行身份验证

[英]React Native Fingerprint Scanner taking too much time to authenticate

I'm using "react-native-fingerprint-scanner": "^6.0.0" it works fine on emulator.我正在使用 "react-native-fingerprint-scanner": "^6.0.0" 它在模拟器上运行良好。 But when I built apk it taking too much time(3 or 4 second) to authenticate on a real device.但是当我构建 apk 时,在真实设备上进行身份验证需要花费太多时间(3 或 4 秒)。 What can i do?我能做些什么?

Here is my code:这是我的代码:

const SplashBeforeFingerprint = ({ navigation }) => {常量 SplashBeforeFingerprint = ({ 导航 }) => {

useEffect(() => {
        FingerprintScanner
            .authenticate({ description: 'Scan your fingerprint on the device scanner to continue' })
            .then(() => {
                    /// nothing to do
            })
            .catch((error) => {
                Alert.alert(
                    "Authentication failed",
                    "Your fingerprint doesn't matches! Try agin later!",
                    [
                        {
                            text: "Exit",
                            onPress: () => BackHandler.exitApp(),
                            style: "cancel"
                        },

                    ],
                    { cancelable: false });
            });

}, []);

return (
    <ImageBackground source={require("../img/Splash2.png")} style={styles.imageContainer} >
        <View style={styles.buttonContainer} >
            <AppButton style={styles.button} textStyle={styles.text} name={"Go to Home"} onPress={() => navigation.reset({
                index: 2,
                routes: [{ name: 'NewWallet' }],
            })} />

        </View>
    </ImageBackground>
) }

I cannot comment.我无法评论。 I had similar problem.我有类似的问题。 Behavior: first run of the screen - nothing happens, after around 10 seconds, it showed dialog to auth.行为:第一次运行屏幕 - 大约 10 秒后,没有任何反应,它显示了对身份验证的对话框。 If auth was ok or canceled, later it opened imidiately.如果身份验证正常或取消,稍后它会立即打开。

I installed these packages: react-native-pincode, @react-native-async-storage/async-storage and react-native-keychain.我安装了这些包:react-native-pincode、@react-native-async-storage/async-storage 和 react-native-keychain。

So, solution was to uninstall them.因此,解决方案是卸载它们。 Folow answer from this post: How to unlink library from react-native project从这篇文章中得到答案: 如何从 react-native 项目中取消链接库

  • unlink取消链接
  • uninstall卸载
  • comment imports in setting.gradle and MainActivity.java (if not done, you will not be able to compile your project)在 setting.gradle 和 MainActivity.java 中评论导入(如果没有完成,您将无法编译您的项目)
  • gradlew clean and recompile eg npx react-native run-android gradlew 清理并重新编译例如 npx react-native run-android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM