[Solved] How do I work with Firebase and Cloud Variables?

Hi, I’m mentoring a group of students in a coding challenge. We created an app that uses cloud variables. But they really wanted a proper login, so I followed the instructions here:

The login works great, but now the cloud variables do not work. They start working again if I take out the Firebase credentials. It’s just a demo, so I’m inclined to take the login out, but can anyone tell me if anything can be done to make the cloud variables work again? (We have a whole app build around cloud variables, and the deadline is soon, so it’s not really possible to use another cloud storage solution.)

Here is a screenshot of the signup code. Most is copied right from the Thunkable Firebase login docs. Then the login email is added to a cloud variable list of user emails.

Thank you!

This screen does not show Sign Up but Sign In code and does not show any information about what you are explaining.

Can you explain why you are using the last block in list ..... insert at last....?

Hey @tsequoia000d9a66

These are common issues and always root back to how things are set up.

How did you configure you Firebase settings in the project settings?

How are your rules configured in the Realtime Database? Do you have them open/closed/authenticated users only?

2 Likes

Yes, that should be sign up. I had removed the block and must have put in back in incorrectly. But either way the user’s email will be stored in the cloud variable users only if I remove my firebase credentials.

The Insert at Last is to add the user’s email to the cloud variable users, which is a list. (It’s initialized as an empty list elsewhere.)

1 Like

Firebase settings in the project settings are fine. I know because I can log in and sign up and reset password, all as promised in the documentation. I can also see my signup emails in Firebase.

I am not familiar with the “Realtime Database”. That’s not mentioned in the documentation. I will read up on it, thanks.

Is it that when I connected to my own Firebase account in order to handle authentication, cloud variables will be stored there as well? When I don’t use Firebase, where do they go? I’ve never really been clear on that.

1 Like

This way you will make it prone for errors. If you are initializing the cloud variable users somewhere else then you should also move the initialization block to the same screen.

In normal practice, the Login Screen will be the first screen unless you have a splash screen that you use to start before the Login Screen.

This means the in list ..... insert at last.... block will fail because the cloud variable users is not yet initialized as a list.

1 Like

It’s initialized, it just didn’t make it into the screen shot. Anyway the login works fine, and now I got the cloud variables working. Thanks for looking at it!

Works! Thank you sooo much! For anyone following along, I had to create the Realtime DB in Firebase, and then add a Realtime DB component to my project.

It would be good to add a reference to this step to the Thunkable doc “Email Sign In by Firebase”, since could variable will not work without it.

1 Like

Good that you have solved the issue. Let me comment as follows:

  • First of all, you do not need a Realtime DB component to work with cloud variables. The idea of cloud variables is treating the keys/buckets of Firebase database as variables not as components.
  • Second and most important, you said the cloud variable works before adding the Sign In screen and this would only be true if you have already created a Realtime DB in Firebase.

OK, I will not worry about the component.

But actually, I spoke too soon. The cloud variable will be saved for a bit, then disappears. It is never seen in my Firebase data. So really, I guess the issue is that I can’t get Thunkable to save the data to my Firebase.

FYI the Cloud variables absolutely DO work if I clear out the Firebase credentials. From Thunkable’s doc on Variables:
“By default, the cloud variable is saved to the Thunkable default Firebase database. We recommend saving them to your own private Firebase DB…”

So I’m still working on it. At least I know what’s going on now. Thanks.

1 Like

Yes, the cloud variables will be saved in Thunkable cloud but it will be removed shortly after you exit the app and would not persist between sessions which defeats the whole purpose of having cloud variables any way.

I just wanted to highlight the fact that cloud variables could be used without Firebase integration but would never properly saved nor written to your database if you have not set up the Realtime DB component in Firebase.

Happy Thinking!

1 Like

My cloud variables totally persist between sessions without Firebase integration. They’re not saved anywhere I can see them, and I know it’s not secure or recommended, but I’ve never had a problem with it.

1 Like

If you wait long enough they will be deleted and if another developer used the same cloud variable names then you both will share the same variables and will overwrite each others’ data.

Anyway, it is good to go through these experiences to appreciate the security and privacy of data.

Good luck with your app.

1 Like

These data aren’t necessarily deleted on any fixed timeframe that I am aware of when saved to a cloud variable in a project not connected to a specific firebase project. What is more likely to occur is that your data will be overwritten or exposed to anyone else using the same key and occasionally.

In short, please dont trust that you can reliably use the cloud variables for any length of time beyond daily testing. Even then, it would wisest to prepend or concatenate some string to your cloud variables to ensure to a greater degree that the value will persist between sessions. This could be a student number or initials or anything you desire.

We provide access to this ‘public’ database to provide an easement, so to speak, for new users to the platform or those who have no clue how to set up firebase but want to start building their app today. By default, the cloud variable is saved to the Thunkable default Firebase database. We recommend saving them to your own private Firebase DB by connecting a private Firebase DB to your app.

3 Likes

Good to know. I’m glad they’re available, I only use them for demos, and they’ve been really handy, thanks!

2 Likes

PS that link says “Oops! That page doesn’t exist or is private.” I’m still trying to get a cloud variable saved in my Firebase account, and I thought it might help.

fixed! Thank you!

Thanks! NOW I think it is actually working. I had to update my database url with the one for my newly created database, duh.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.