Используйте Localstorage
плагин.
Звоните loginWithFB()
со страницы входа пользователя.Внутри этой функции установите для зарегистрированного пользователя значение localstorage
:
loginWithFB(userData) {
this.fb.login(['email', 'public_profile']).then((response: FacebookLoginResponse) => {
this.fb.api('me?fields=id,name,email,first_name,picture.width(720).height(720).as(picture_small)', [])
.then(profile => {
this.userData = {
email: profile['email'],
first_name: profile['first_name'],
picture: profile['picture_small']['data']['url'],
username: profile['name']
}
// Set user to storage
this.nativeStorage.setItem('user', this.userData)
})
.then(() => { // Redirect to user page })
// ....
Последний шаг - получение пользовательских данных, когда platform is ready
из localstorage
:
Пример:
platform.ready().then(() => {
// Here we will check if the user is already logged in
// because we don't want to ask users to log in each time they open the app
let env = this;
this.nativeStorage.getItem('user')
.then( function (data) {
// user is previously logged and we have his data
// we will let him access the app
env.nav.push(UserPage);
env.splashScreen.hide();
}, function (error) {
//we don't have the user data so we will ask him to log in
env.nav.push(LoginPage);
env.splashScreen.hide();
});
this.statusBar.styleDefault();
});
Это очень полезная ссылка: Facebook Войти