How to connect Firebase values with Thunkable

Hey everyone! I am confused as to how to get the value from firebase and receive the value from thunkable using cloud variables. Can anybody help me?

1 Like

In Thunkable there are 3 types of variables that you can set in the initialize stage.

  • App variables which will only be available as long as the app is running and once the app is closed or exit then the values are gone.

  • Stored variables which will save the values in your mobile so that the next time the app runs can read these variables and show/manipulate the values.

  • Cloud variables are those who maps the keys of the Firebase RTDB. So when you want to read data stored in Firebase under user_id/job_id/job_code for example then you just add a cloud variable to your app and the name of the variable is the database key (in this example user_id/job_id/job_code) and the variable will show the content of this key in the database.

That is in short.

So how do I get the value that is under that key?

1 Like

Just have the cloud variable name to be the same as the key in the database.

But how do I retrieve the value? Should I set the my label to the cloud variable?

1 Like

Assign the cloud variable to a label in your screen and the value will show as the label text


Is this correct?

No. You need to use this block to set firebase values:

image

And this block to retrieve them:

image

Change the variable type from “app” to “cloud” and replace “name” with “user_id”:

image

2 Likes

Like this?

Nope. What are you trying to do? Are you wanting someone to type in a value and then have it stored in Firebase? Because that’s what the third set of blocks I posted above would do.

I want to retrieve the value from Firebase. I have a value under the name “user_id” in firebase. I want to set the text input to the value of “user_id”

How do I do that?

Thank you. I also wanted to retrieve my keys from Firebase (not values). How do I do that?

1 Like

See this