Firebase logs user out when building for production

Hello,
I have an app that signs users using phone auth (using Firebase). For now, it knows how to redirect them to login page or main activity accordingly .
Whenever I build again (same setting: ‘ionic cordova run android’) , it knows how to keep the user still (that’s good), however, when building again using different settings (build + --prod) it forgets the user.

I know this is cache related, and I’m afraid of saving credentials on the users’ phone because it can be easily deleted by system and such.

How can I prevent this? When the app gets updated in the store it deletes the local cache also?

UPDATE:

this is the redirection -

 constructor(platform: Platform, statusBar: StatusBar,   public splashScreen: SplashScreen, private geoloc: Geolocation) {
    var that = this
    platform.ready().then(() => {
     
      platform.setDir("rtl",true)
      statusBar.styleLightContent() 


      auth().onAuthStateChanged((user) => {

     
        if (user) {

          var options = {
            enableHighAccuracy: true,
            timeout: 9200,
            maximumAge: 0
          };
      
          geoloc.getCurrentPosition(options).then((position) =>{

            that.navCtrl.setRoot('TabsPage', {lat: position.coords.latitude, long: position.coords.longitude})
            .then(()=>{

            that.splashScreen.hide();  

          })
        }).catch(()=>{
          that.navCtrl.setRoot('TabsPage', {lat: 30.9878,long: 34.9297}).then(()=>{
            that.splashScreen.hide();  
          })

        })

        }else {

          that.navCtrl.setRoot('LoginPage').then(()=>{
            that.splashScreen.hide();  
          })  
        
        }

      });
    }).catch((err)=>{
      console.log(err)
    })
  }
this.fAuth.authState
        .subscribe(
          user => {
            if (user) {
              this.rootPage = HomePage;
            } else {
              this.rootPage = WelcomePage;
            }
          },
          () => {
            this.rootPage = WelcomePage;
          }
        );

i added like this in my project…

I already have a redirection, that’s not answering my question nor solving my problem … I updated the topic to include the redirection.