React Native - Firebase auth persistence not working

主宰稳场 提交于 2019-11-30 04:13:21

You don't need to set persistence. Firebase handles it for you by default. You just need to call this function to check whether user is logged or not:

firebase.auth().onAuthStateChanged((user) => {
      if (user) {
        console.log('user is logged');
      }
}

This will not be triggered only if user has sign out or cleaned app data.

You can find more details in the official docs: https://firebase.google.com/docs/auth/web/manage-users

Hope it helps.

Make sure you do not restrict the 'Token Service API' in the console, with the API key you are using. I did not add the service to my key, and it logged me out every 3-4 hours, even with the right code suggested above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!