title: Firebase Auth login state persistence is not working
body: <p>On an ionic/AngularJS/Cordova IOS app.</p>
  
  <p>I'm trying to set a persistence login using mail/password (followed <code>Firebase documentation</code> : <a href="https://firebase.google.com/docs/auth/web/auth-state-persistence" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/web/auth-state-persistence</a>). But I can't figured out what is wrong with my code. My app is starting on the login page, when a user is clicking on the "Connexion button", it's trigger the login function.</p>
  
  <p>The login is working, but when I'm closing the app (without logging out), restarting it, I'm still on the login page. The login is not persistent.</p>
  
  <p>So I guess, one problem, might be the persistency call not well placed...Is it ? According to this post : <a href="https://stackoverflow.com/questions/37568644/firebase-3-0-session-persistance">Firebase 3.0 session persistance</a> it could have someting related to <code>firebase.auth().onAuthStateChanged(function(user)</code>, but I don't know... </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// EMAIL CONNEXION TRIGGERED WHEN CONNEXION BUTTON IS HIT
  
  $scope.loginEmail = function($email, $password){
    
    firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION)
    .then(function() {
      var alertPopup;
      
      function signInSuccess(response) {
    
      $state.go("menu.VN");
      }
  
      function signInError(response) {
      
          var errorCode = null;
          errorCode = response.code;
          if ($email === ""){
               alertPopup = $ionicPopup.alert({
                      title: 'Something wrong...',
                      cssClass: 'pop',
                      template: '&lt;div class="center-form"&gt;Need an email address...&lt;/div&gt;'
                  });   
          }
  }
  
  return firebase.auth().signInWithEmailAndPassword($email, $password)
    .then(signInSuccess)
    .catch(signInError);
  
       })
       .catch(function(error) {
      // Handle persistence Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
    });
  
  };</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;label&gt;
            &lt;span&gt;Email&lt;/span&gt;
            &lt;input type="email" placeholder="" ng-model="data.email"&gt;
  &lt;/label&gt;
  
  &lt;label&gt;
            &lt;span&gt;Password&lt;/span&gt;
            &lt;input type="password" placeholder="" ng-model="data.password"&gt;
  &lt;/label&gt;
      
  &lt;button ng-click="loginEmail(data.email, data.password )"&gt;Connexion&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>