React Native iCloud Keychain popup not appearing after 2FA

I have a React Native app built with Expo and Expo Router. I’ve correctly configured autofill, and it works perfectly. On my Login screen, when I enter the username and password correctly, I get a successful response from my API and navigate to the next screen, and the iCloud Keychain popup to save my credentials appears as expected.

However, sometimes my API returns an error code when logging in, which means the user needs to enter a 2FA code. After entering the 2FA code, I press the login button again and navigate to the next screen successfully, but now the iCloud Keychain popup never appears.

Does anyone have any idea why this might be happening?

It seems like if the response from the API is not successful the iCloud popup does not appear anymore.

This issue occurs on both iOS and Android.

Here is my code:

import theme from '@config/theme';
import { router } from 'expo-router';
import React, { useState } from 'react';
import { Button, StyleSheet, Text, TextInput, View } from 'react-native';
import Toast from 'react-native-toast-message';

import { useSignIn } from '../hooks';
import { ErrorApiResponse, SignInForm } from '../types';

const SignInScreen = () => {
  const { login } = useSignIn();
  const [isOtpCodeRequired, setIsOtpCodeRequired] = useState(false);

  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');
  const [otpCode, setOtpCode] = useState('');

  const handleOnSignIn = async ({ email, password, otpCode }: SignInForm) => {
    try {
      await login({
        email,
        password,
        otpAttempt: otpCode,
      });
      router.navigate('/home');
    } catch (error) {
      const typedError = error as ErrorApiResponse;
      if (
        typedError?.response?.status === 401 &&
        typedError?.response?.data?.errorCode === 12345
      ) {
        setIsOtpCodeRequired(true);
      } else {
        Toast.show({
          type: 'error',
          text1: 'Login Error',
          text2: typedError?.response?.data?.error,
        });
      }
    }
  };

  return (
    <View style={styles.mainContainer}>
      <View style={styles.formContainer}>
        <View style={{}}>
          <Text>Email</Text>
          <TextInput
            value={email}
            onChangeText={setEmail}
            placeholder="Email"
            keyboardType="email-address"
            textContentType="emailAddress"
            style={styles.input}
          />
        </View>

        <View style={{}}>
          <Text>Password</Text>
          <TextInput
            value={password}
            onChangeText={setPassword}
            placeholder="Password"
            secureTextEntry
            textContentType="password"
            style={styles.input}
          />
        </View>

        {isOtpCodeRequired && (
          <View style={{}}>
            <Text>Otp Code</Text>
            <TextInput
              placeholder="OTP CODE"
              value={otpCode}
              onChangeText={setOtpCode}
              textContentType="oneTimeCode"
              style={styles.input}
            />
          </View>
        )}
      </View>

      <View style={styles.buttonContainer}>
        <Button
          title="Log in"
          onPress={() => handleOnSignIn({ email, password, otpCode })}
        />
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  mainContainer: {
    flex: 1,
    justifyContent: 'space-between',
    paddingHorizontal: theme.sizes.dimensions.padding * 2,
  },
  formContainer: { marginTop: 46 },
  input: {
    borderWidth: 1,
    borderColor: theme.colors.gray500,
    padding: 8,
    borderRadius: 8,
  },
  buttonContainer: {
    marginBottom: theme.sizes.dimensions.padding * 2,
  },
});

export default SignInScreen;

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật