# Firebase RealtimeDB Save function not working?

**URL:** <https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912>\
**Category:** Questions about Thunkable X\
**Created:** [February 2, 2022, 7:03am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912 "2022-02-02T07:03:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![slothball](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@slothball](https://community.thunkable.com/u/slothball)\
**Post date:** [February 2, 2022, 7:03am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/1 "2022-02-02T07:03:50Z")

</div>

Hi there

I have just published an app. One of the features is that it saves certain data inputted by users to a realtime database in Firebase using the RealtimeDB save blocks. The feature works perfectly when using the Thunkable Live app. However, the functionality does not work when users use the published app (Apple and Google Play Store). No data is being saved.

The API key and database URL are both correct in the app settings.

Am I making a basic error!?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 2, 2022, 7:32am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/2 "2022-02-02T07:32:56Z")

</div>

Does it work correctly when downloaded to iOS and Android from Thunkable?

The Realtime DB block has an error block so you could publish an update or test it in TestFlight first and display that error value for further testing.

---

<div class="post-metadata">

**Author:** ![slothball](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@slothball](https://community.thunkable.com/u/slothball)\
**Post date:** [February 2, 2022, 7:41am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/3 "2022-02-02T07:41:35Z")

</div>

Hi @tatiang - yes it does work when downloaded as an iOS app. Would you recommend I use the error block and then test this in Testflight?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 2, 2022, 7:49am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/4 "2022-02-02T07:49:26Z")

</div>

I would expect it to work the same with Testflight but yes, I think it makes sense to test it there to see if it still fails.

---

<div class="post-metadata">

**Author:** ![slothball](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@slothball](https://community.thunkable.com/u/slothball)\
**Post date:** [February 2, 2022, 8:16am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/5 "2022-02-02T08:16:23Z")

</div>

So for some reason, I am getting a “PERMISSION DENIED” error when trying to save to the REaltimeDB. I have the user permissions in Firebase set to “auth.uid != null” and Firebase authentication is by email/password. Any idea on how I can fix this?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 2, 2022, 8:22am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/6 "2022-02-02T08:22:52Z")

</div>

Are you signing in to Firebase as a user and confirming that the account is verified?

This is more or less what your sign in blocks should look like:

> **[Email Sign In by Firebase](https://docs.thunkable.com/sign-in-1#sign-in)**

---

<div class="post-metadata">

**Author:** ![slothball](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@slothball](https://community.thunkable.com/u/slothball)\
**Post date:** [February 2, 2022, 8:24am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/7 "2022-02-02T08:24:50Z")

</div>

Yep, I have done that and this has been working for months. I’ll play around some more to see what might be going wrong. Thanks @tatiang!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 2, 2022, 9:54am UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/8 "2022-02-02T09:54:46Z")

</div>

I have previously explained this behavior for other members.

Basically, you are using the email ID that you use for your Thunkable and for your browser in your computer and for your Android mobile device as the same email ID used to create the Realtime DB.

This means you are not a user to Firebase but you are an **owner** of the database and therefore you have access to the database even if your login using the app is not successful.

This is the reason why your users are not able to access the database.

You need to look into two things:

- Make sure the `Sign In` component is executed without errors.
- Make sure the Database **rules** do not have time restrictions.

---

<div class="post-metadata">

**Author:** ![slothball](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@slothball](https://community.thunkable.com/u/slothball)\
**Post date:** [February 2, 2022, 1:40pm UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/9 "2022-02-02T13:40:10Z")

</div>

Thanks @muneer. Inexplicably, the database is now working perfectly. I’m checking with Firebase whether they might have a problem with their servers. Thanks for your explanation above - I went back to double-check the sign-in components were working.

For the database rules, if I have not set any time restrictions, presumably users are not logged out after a period of time?

Thanks again.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [February 2, 2022, 2:05pm UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/10 "2022-02-02T14:05:27Z")

</div>

Firebase will log the user out if the session expired, ie the user closed the app or if the app is idle for **one hour**.

So you should not worry about this.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [May 3, 2022, 2:05pm UTC](https://community.thunkable.com/t/firebase-realtimedb-save-function-not-working/1710912/11 "2022-05-03T14:05:32Z")

</div>

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