SQLite sometimes not loading in iOS

Hi there! First time posting here. I have a problem in iOS. I believe the SQLite Plugin is not being loaded sometimes when I start my application. To give you some context, I have a menu that shows how much data has been inserted (a little circle with the number). This menu is shown on startup. Sometimes when I load the application the number is there, but sometimes it shows 0, meaning it couldn’t read the data in the sqlite database. Furthermore, when I press one of the other buttons in the menu, it is supposed to change screens and load a basic data from one of the tables, but the error I’m getting (and this is the only error I was able to debug in the Safari console) is that it couldn’t read a property which is supposed to be filled with data that was read from the database. Now, like I said, this only happens sometimes, very inconsistently. I can’t pinpoint an actual event that is causing this. I just close my application (double click home then swipe up the app) and reopen and check the little number I mentioned.

I am currently not having this problem with Android, or at least I haven’t been able to recreate it there. I have taken the same steps as in iOS and I don’t get this error. I have a hunch it’s something with the plugins, maybe they are not loading correctly or something. I really have no way of telling because I can’t debug the startup in the Safari console (at least I don’t know how to do it, I open the console when the startup is done). And I can debug in Android but I’m not getting this error there.

Any help at all will be appreciated.

I think I found the problem. I’m seeing that the deviceReady is sometimes firing late. So I need to find a way to make sure that my code executes AFTER deviceReady is fired.