I have started a project at Firebase and I defined a cloud variable (at database tab). I have copied the apiKey and databaseURL to my app (at Firebase Settings). I don’t know why I can’t change the value of this variable from Firebase.
Is there any video shows how to setup a cloud variable at Firebase and allocate its value to a corresponding variable at thunkable cross project?
Thanks,
Ahmed
@nicnok
The “cloud” type variables seem to be stored in the Thunkable real-timeDB, even after setting up firebase. If you want to be able to modify the data you save to cloud type variables, you can make calls to the realtimeDB and you can definitely find a tutorial on YouTube from @darren related to this topic! I would love to know more about this as well though but this has been my workaround for now.
Maybe someone else in the community has more info on this?
set the realtime db to ‘test’ mode, so no auth is required to write to it
copied the db url into the thunkable settings
copied the api key into the thunkable settings
He then goes back into firebase, views his db, and it automagically has a node corresponding to the cloud variable he created. I have done all of those things, and no such node exists. I’m going effing bonkers.
edit: I am not able to use the direct realtime db component in thunkable, because my project is in the drag-and-drop editor, which apparently can’t use that.
Thanks for responding! Here are my blocks. I had written a lot that was more complicated, but have stripped it back to remove as many variables as I could. When I click the button, I don’t navigate to the other screen. If I put the navigate block above the list block, I do navigate to the other screen, but either way, nothing shows up in firebase.
I’m sure this is not the only coding block in your project and therefore I need to ask you two questions.
Is your Firebase API key and database URL supplied in the project properties?
You are trying to use the cloud variable as a list. However when cloud variables are first created they hold null value and to be able to use them as list you will have to first initialize them in your code with empty list. Not doing that results in the operation to fail. Have you initialized your cloud variable somewhere in your code?
However when cloud variables are first created they hold null value and to be able to use them as list you will have to first initialize them in your code with empty list.
That was it! I didn’t know that there’s a difference between “null” and “empty”! I’ve added a block to set the cloud variable to an empty list, and now I can write to firebase. Huge step. Thanks!
Now my problem is that my code overwrites the same list item in firebase every time. I thought I would get successive nodes, each with its own value for ‘p1d’ on every click of the button, but it’s just overwriting the “0” node.
Hmm, I’m able to write to the DB now, but I can’t get that data back out with a query. I don’t want to take over this thread with a separate issue, but I did create another question (with screenshots, etc.) over here. Would really appreciate your thoughts: