Ionic 2 - Remember logged-in user when closing and opening app

Hello guys,

I have an ionic 2 app that handles logging of users with facebook and using the login method with firebase email. It works perfectly, but when I close the app and re-open it on my device, I must log in again.

How could you do to remember that the user is logged in?
I can think of keeping the app in the background.
Another way could be to save the email when logging in and then trying to log in automatically with that email when you open the app.
Any ideas? Did someone do something like that? If someone can give me a hand I would be more than grateful !!

Regards,
Ivan

if you are doing the firebase authentication correctly, it should be persisting the user for you and on relaunch of the app you can just check of there already is a user session

“Get the currently signed-in user” - https://firebase.google.com/docs/auth/web/manage-users

1 Like

I used native storage to persist user information: https://ionicframework.com/docs/v2/storage/
but thanks, that should work and even better than I implemented so i’ll try it

please tell me in ionic 3 where i initlize this function ?

get current user funtion
’

Would advise against using local storage, unless you are hashing the passwords. If you are using something like firebase, it caches user auth info for you.