IOS Physical Device - History.replace after successful login is not working

Hello, so I am running into an issue and I cannot understand what seems to be the problem.

I have integrated Firebase into my application and it is working great.

const App: React.FC = () => {

  const [authValue, setAuthValue] = useState(false)

useEffect(() => {
    onAuthStateChanged(auth, (currentUser) => {
      if (currentUser) {
      else {
}, []);

  return (
            {authValue? <TabRoot /> : <LoginRoot />}


export default App

As you can see above, I have set up two different route roots, one if a user is logged in (TabRoot) and another if a user is not (LoginRoot)

Using Firebase’s Auth State, when a user is logged in they have access to the TabRoot. Everything is working great on Web and IOS Simulator.

However, on my physical IOS device when I attempt to switch roots by logging in, nothing happens. The page remains stuck on the Login Page. See code below for the login page:

const Login: React.FC = () => {

  const [loginEmail, SetLoginEmail] = useState("")
  const [loginPassword, SetLoginPassword] = useState("")
  const [error, SetError] = useState("")
  const [signingIn, setSigningIn] = useState(false)
  const history = useHistory()

  function SignIn() {
    if (error !== '') SetError('');


    signInWithEmailAndPassword(auth, loginEmail, loginPassword)
  .then((userCredential) => {
  .catch((error) => {
    SetError('Unable to sign in. Please try again.')


  return (
          <IonTitle className="notif--header--name">Login</IonTitle>
            <IonLabel position="floating">Email</IonLabel>
            <IonInput onIonChange={e => SetLoginEmail(e.detail.value!)} />
          <IonLabel position="floating">Password</IonLabel>
          <IonInput onIonChange={e => SetLoginPassword(e.detail.value!)} />

        <div className="error--text">
          <ErrorText error={error} />
        <a className="login--forgot--password" href='/forgotpasswordpage'>Forgot Password?</a>
        <div className='page--container'>
          <IonButton className="login--button page" onClick={SignIn} fill='clear'>Login</IonButton>
          <div className='small--container page'>
          <a className="login--button--small" href='/register'>Register</a>

export default Login

I am not sure why on the IOS physical device it does nothing. History.replace is working fine on web on the IOS simulator.

Please help me out if you have any ideas, thanks!

I was able to solve this issue. Firstly, I watched Aaron Saunder’s video on youtube using ReactFire and I changed the way my app is routed:

const App: React.FC = () => {

  return (
      <AuthProvider sdk={auth}>
        <FirestoreProvider sdk={db}>
              <AuthWrapper fallback={<LoginRoot />}>
                <TabRoot />

export const AuthWrapper = ({
}: React.PropsWithChildren<{ fallback: JSX.Element }>): JSX.Element => {
  const { status, data: signInCheckResult } = useSigninCheck();

  if (!children) {
    throw new Error("Children must be provided");
  if (status === "loading") {
    return <IonLoading isOpen={status === "loading"} />;
  } else if (signInCheckResult.signedIn === true) {
    return children as JSX.Element;

  return fallback;

export default App

when I did this, initially I got a stuck error on the IOS physical device, again I don’t know why.

So what I did was instead of syncing to Xcode and running the project through Xcode, I used the official Ionic Plugin and deployed onto my Iphone directing from there. For whatever reason, this seamed to sync better and clean up whatever bug that was persisting through running the app on Xcode.

I think some data just got permanently looped or something that prevented the app to ever get into a useable state from running through Xcode, but when deployed from the Ionic IOS plugin unto my physical phone it worked great!

1 Like