How to create login persistence on React Native app

Hi all,

I am attempting to incorporate ChatKitty functionalities into my mobile app. I am using Firebase together with ChatKitty.

Currently, I am facing the problem of:

NoActiveSessionError {
  "error": "NoActiveSessionError",
  "message": "You're not connected to ChatKitty.",

which i suspect the user is logged out of ChatKitty after the app is closed. I am using firebase and user is logged out only if the app’s cache is cleared or triggered by the user.

  useEffect(() => {
		firebase.auth().onAuthStateChanged(async (user) => {
			if(!user) {
				/** if  user is not logged in*/
			} else {
				/** if  user is logged in*/
	}, []);

I would like to maintain this as I do not want to cause inconvenience to the users by always signing them out.

Is it possible to maintain connection to ChatKitty? Understand that a workaround is to store credentials for ChatKitty in AsyncStorage but also understand that it is not secured. Perhaps is there some session token that I can store to re-connect with ChatKitty and fetch chat info?

Any help is appreciated. Thanks in advance!

Hey @queries.eesee ! Welcome to ChatKitty community.

If you’re using Firebase, you can use pass the user’s firebase access token into startSession({ authParams: ... }) and check that in the User Attempted Start Session chat function

Like this

const googleCredential = firebase.auth.GoogleAuthProvider.credential(idToken, accessToken);

await firebase.auth().signInWithCredential(googleCredential);