How to view Firebase Logs


#1

Hello,
My app store and get all data but receive “Permission denied” error also.

Home Screen:

On good advice from @Ratthanin I use Web interface to autentificate user on Screen1 to access to Home Screen.
I thought I needed to save the login information and reconnect from the Home screen, but not the first login seems enough, it works.
But if i access to Home screen from Screen1 no error, If I refresh the Screen Home, after a Sleep Mode application for example i got two errors (Permission denied).

That’s why to understand what’s going on I need to see the Firebase log but I don’t know how to do it.
I saw this, but how do I get it into Thunkable?

Thanks!


#2

From my experience.
Avoid using more than one FkrebaseDB component in your app,
This make permissions deny error occur.
If you really want to query other real-time database node, just change firebase project bucket parameter.
Also check firebase database rule. Please read here. Firebase and where to put it?

I prefer using log in screen and home screen as the same screen but split them as login layout and home layout
When users logged in just hide login layout and show home layout.
This make app run faster.


#3

Actualy i just have only one FirebaseDB component in the app (Home Screen) i use WebViewer on Screen1 for login.
I just do 6 querys on the same DB.
I thing it’s too late to make my app One Screen but i’ll keep your advice for the next one thanks!


#4

OK I guess you’ve got uid from login screen and pass uid to home screen.
You use uid to access user database.

Everything is work until your app slept and the error occur when you open it again after sleeping?

Try using notifier to show uid again after return from sleeping. Just to be sure that the uid variable still exist.


#5

I test it and yes uid still there after sleeping.

I also noticed that if I click on button to send a data to Firebase just after opening the app (first 3 seconds) Firebase does not respond. Sometimes it responds instantly.
Do you think a Timer could interfere? I have a Timer that launches a webviewer every 5 seconds to see if there’s internet.

<script>
function doesConnectionExist() {
    var xhr = new XMLHttpRequest();
    var file = "https://www.freecodecamp.org/the-fastest-web-page-on-the-internet";
    var randomNum = Math.round(Math.random() * 10000);
 
    xhr.open('HEAD', file + "?rand=" + randomNum, true);
    xhr.send();
     
    xhr.addEventListener("readystatechange", processRequest, false);
 
    function processRequest(e) {
      if (xhr.readyState == 4) {
        if (xhr.status >= 200 && xhr.status < 304) {
          alert("connection exists!");
        } else {
          alert("connection doesn't exist!");
        }
      }
    }
}
</script>
<body onload="doesConnectionExist()"> 
</body>

What I also don’t understand is why all my queries received the data successfully if there are errors then the Initialize function only runs once.


#6

I don’t know how important to check internet connection every 5 seconds, this consume data connection.
You can use web component to check respond code, 200/403 no need to use js to check connections.
Good tutorial. How to check for “connection” and save data on or offline
Or you just check connections once whenever you query data from firebase

,“I also noticed that if I click on button to send a data to Firebase just after opening the app (first 3 seconds) Firebase does not respond. Sometimes it responds instantly.”
It’d because of connection speed or firebase server or even your own device. Don’t worry, another app built with Xcode for iPhone is also slow sometimes as well.


#7

I chose not to use the Web component because it was not compatible with the FirebaseAuth extension but now that I use WebViewer for autenthification instead it’s true it’s a good idea.
And a good idea also to check internet only after a query to Firebase. Thank you!

Since everything works, I think I’m gonna have to hide the error even I don’t like doing that too much.


#8

Finding errors and correct them is the best way. You can’t hide errors. I used to tried once, it never work
Please read this To hide runtime error notification dialog

I don’t see your whole blocks, so I couldn’t help you much but believe me. Be patient, try disable unnecessary blocks to find what block trig the errors
You can do it.


#9

OK you are right. After testing block by block :tired_face: i resolve the 2 errors.

The first one look like that it was due to the close request which makes absolutely no sense given Firebase’s ability to handle a high number of simultaneous requests.

The second one doesn’t seem to make sense either. It was a block that used the CryptoExtension extension from @Tiziano1960 . It has nothing to do with Firebase. What the heck!
Maybe it’s trying to sniff out my data? :stuck_out_tongue_winking_eye:

Anyway I no longer need the extension as I no longer need to store authentication information.

Resolved! Thanks.


#10

Congratulation!!! :grinning: