hello,
i just did log in with facebook in my ionic 2 app,it works fine but
when i log in in first time it goes to the home page but when i exit from the app and run again
ionic run android
it not go to home page but it shows like the user is connected.
i connected my phone and i saw in chrome://inspect that it’s print the user details but it shows me blank page
in my app.component.ts
i did this
import { Component } from ‘@angular/core’;
import { Platform } from ‘ionic-angular’;
import { StatusBar, Splashscreen } from ‘ionic-native’;
//import pages
import { HomePage } from ‘…/pages/home/home’;
import { LoginPage } from ‘…/pages/loginPage/login-page’;
//import plugins
import firebase from ‘firebase’;
@Component({
template:<ion-nav [root]="rootPage"></ion-nav>
})
export class MyApp {
rootPage:any;
constructor(platform: Platform) {
firebase.initializeApp({
apiKey: “AIzaSyDOpRshkjuy_tGXSzw34RFHXmAFelyAUt0”,
authDomain: “haversami.firebaseapp.com”,
databaseURL: “https://haversami.firebaseio.com”,
storageBucket: “haversami.appspot.com”,
messagingSenderId: “704224601349”
});
firebase.auth().onAuthStateChanged((user) => { if (user) { console.log(user); this.rootPage = HomePage; console.log("I'm here! HomePage"); } else { this.rootPage = LoginPage; console.log("I'm here! LoginPage"); } }); platform.ready().then(() => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. StatusBar.styleDefault(); Splashscreen.hide(); });
}
}
in login-page.ts
i did this function
facebookLogin(){
Facebook.login([‘email’]).then( (response) => {
let facebookCredential = firebase.auth.FacebookAuthProvider.credential(response.authResponse.accessToken);
var that = this;
firebase.auth().signInWithCredential(facebookCredential)
.then((success) => {
console.log("Firebase success: " + JSON.stringify(success));
that.userProfile = success;
console.log(that.userProfile);
that.nav.setRoot(HomePage); // after login in it goes to homepage
}) .catch((error) => { console.log("Firebase failure: " + JSON.stringify(error)); });
}).catch((error) => { console.log(error) }); let loader = this.loadingCtrl.create({ dismissOnPageChange: true, });
in my first time when i login it shows all the details fine
but when i exit from emulator\chrome://inspect and run the app again it shows me blank page