Firebase RealtimeDB Save function not working?

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!?

1 Like

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.

1 Like

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?

1 Like

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.

1 Like

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?

1 Like

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:

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!

1 Like

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.
1 Like

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.

1 Like

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.

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