首页 > 解决方案 > 激活 google 密码管理器提示 @ React-Native app

问题描述

我正在使用 React-Native 0.63.4 为 android 开发一个新应用程序,我希望谷歌服务提示使用谷歌密码管理器存储用户凭据。我正在使用 Formik 来管理我的表单操作。

这是代码:

            <View style={styles.formContainer}>
              <Input
                onChangeText={handleChange('email')}
                onBlur={(e) => {
                  handleBlur('email')(e);
                }}
                placeholder={emailPlaceholder}
                autoCompleteType="email"
                autoCapitalize="none"
                keyboardType="email-address"
                textContentType="emailAddress"
                value={values.email}
                isError={Boolean(errors.email && touched.email)}
                errorMessage={errors.email}
              />

              <PasswordInput
                placeholder={passwordPlaceholder}
                notFocusedText={continueToResetPassword}
                textContentType="password"
                onChangeText={handleChange('password')}
                onBlur={(e) => {
                  handleBlur('password')(e);
                }}
                value={values.password}
                isError={Boolean(errors.password && touched.password)}
                errorMessage={errors.password}
                notFocusedTextOnPress={() =>
                  navigation.navigate('EnterEmail', {
                    email: values.email,
                  })
                }
              />

              <Button text={isSubmitting ? '' : button} onPress={handleSubmit}>
                {isSubmitting ? <ActivityIndicator color="black" /> : null}
              </Button>
            </View>

两者都<Input />继承<PasswordInput />自 React-Native 的<TextInput />元素,并将 {...props} 作为“>”之前的最后一行转发。

设置了 textContentType 和 autoCompleteType 的道具,但我仍然没有提示存储凭据,我错过了什么?

ps 其他本机应用程序在成功登录后肯定会提示,与在大多数 Web 浏览器中实现的方式相同。问题是它是如何在 react-native 中实现的?

标签: androidreact-nativegoogle-play-services

解决方案


从您的代码中,您尚未添加autoCompleteType<PasswordInput/>.
尝试添加autoCompleteType="password"到您的<PasswordInput/>.


推荐阅读