How to make the React Native app to ask if I want to save username and password? (iOS 11+)

Viewed 354

Based on this excellent question and answer, I tried to implement autofill function in my app. While the username and password sections can be auto-filled (i.e, Above the keyboard, there is a password button, and once I press the button, Face ID is activated, and I can select an option), but it does not ask when I typed a username and password and pressed the sign in button.

Any suggestion is very appreciated!

import { useForm } from 'react-hook-form';
// Just in case
// "@react-navigation/bottom-tabs": "^5.4.2",
// "@react-navigation/native": "^5.2.6",
// "@react-navigation/stack": "^5.3.1",
...

export default function screen({navigation, route}) {

 useEffect(()=> {

    register("email");
    register("password")


    return () => {
      console.log("Unmounted");
    }
  }, [register]);

...

return (

 ...
       <View
        style={[
          styles.container,
          styles.emailSection,
          styles.paddingHorizontal,
        ]}>
        <View style={styles.textInputContainer}>
          <TextInput
            onChangeText={text => {
              setValue('email', text);
            }}
            placeholder={'Email'}
            placeholderTextColor="grey"
            keyboardType="email-address"
            autoCapitalize={'none'}
            autoCorrect={false}
            textContentType={'username'}
            style={styles.textInputFont}
          />
        </View>
        <View style={styles.textInputContainer}>
          <TextInput
            onChangeText={text => {
              setValue('password', text);
            }}
            placeholder={'Password'}
            placeholderTextColor="grey"
            keyboardType="default"
            autoCapitalize={'none'}
            autoCorrect={false}
            secureTextEntry={true}
            textContentType={'password'}
            style={styles.textInputFont}
          />
        </View>

        <View>
          <TouchableOpacity
            onPress={
              isEmailLoading ? null : handleSubmit(_onPressEmailSignIn)
            }>
            <View style={[styles.wideButtonContainer]}>
              <Text style={styles.secondaryFont}>Sign In</Text>
            </View>
          </TouchableOpacity>
        </View>

        <View style={styles.textContainer}>
          <TouchableOpacity
            onPress={() => navigation.navigate('ForgotPassword')}>
            <View>
              <Text style={styles.secondaryFont}>Forgot Password</Text>
            </View>
          </TouchableOpacity>
          <TouchableOpacity
            onPress={() => navigation.navigate('EmailSignUp')}>
            <View>
              <Text style={styles.secondaryFont}>Sign Up</Text>
            </View>
          </TouchableOpacity>
        </View>
      </View>
...

)

- Tried on simulator (iPhone Xs (12.0) and my device (iPhone Xr (13.0))

0 Answers
Related