【问题标题】:React Native Fingerprint Scanner taking too much time to authenticateReact Native Fingerprint Scanner 花费太多时间进行身份验证
【发布时间】:2021-02-02 17:16:05
【问题描述】:

我正在使用 "react-native-fingerprint-scanner": "^6.0.0" 它在模拟器上运行良好。但是当我构建 apk 时,在真实设备上进行身份验证需要花费太多时间(3 或 4 秒)。我能做什么?

这是我的代码:

const SplashBeforeFingerprint = ({ navigation }) => {

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>
) }

【问题讨论】:

  • 三个问题 - 1. APK 是否有可能是为调试而不是发布而构建的?调试会慢很多。 2. 设备普遍慢吗? 3. 如果指纹方式是连接外部API,会不会是设备网络问题?
  • 您的问题的答案是 - 1. 它是一个签名的 APK。 2. 设备有 4GB 内存。 3.没有外部API。只有给定的代码用于指纹。 @安倍

标签: react-native


【解决方案1】:

我无法发表评论。我有类似的问题。 行为:屏幕的第一次运行 - 没有任何反应,大约 10 秒后,它显示了对身份验证的对话框。 如果身份验证正常或取消,稍后它会立即打开。

我安装了这些包:react-native-pincode、@react-native-async-storage/async-storage 和 react-native-keychain。

因此,解决方案是卸载它们。 关注这篇文章的答案:How to unlink library from react-native project

  • 取消链接
  • 卸载
  • setting.gradle 和 MainActivity.java 中的注释导入(如果不这样做,您将无法编译您的项目)
  • gradlew 清洁 并重新编译,例如npx react-native run-android

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-13
    • 1970-01-01
    • 1970-01-01
    • 2020-08-23
    • 2021-12-28
    • 1970-01-01
    • 2020-07-31
    • 1970-01-01
    相关资源
    最近更新 更多