Guide of Firebase Runtime Database

Hi, I am kind of new to Solar2D. I am trying out the demo projects and I’ve also been able to compile and test them and my own project on the Android with AdMobs and more.

Now I am looking for a guide/example of how to use Firebase Runtime Database which I am planning to use to store game data and other. I’ve searched the forum but there are very few real world examples. You know of any good guides/examples with Solar2D and Firebase Runtime Database? Can you please point me in the direction. Regards Fred

Hi, I’ve created a Firebase project in the Google Console, defined read and write access rules. I also and downloaded google-services.json from the Google console and put that file in the root folder of the Solar2D project. In my code, these lines seems OK:

local firebaseDatabase = require “plugin.firebaseDatabase”
firebaseDatabase.init()

But when I try to Get or Set any data the Android App is crashing all the time, here is the Get part:
firebaseDatabase.get(“testData”, function (ev)
if(ev.isError) then
native.showAlert( “Could not Get Data”, ev.error , {“Ok”} )
else
native.showAlert( “Data received”, json.encode( ev.data ) , {“Ok”} )
end

Since I am a beginner of Solar2D I don’t really know fix this. I’ve search the forum and Google with out luck. Anyone with a guide how to use Firebase Realtime Database?

Did you add the plugin to your build.settings?

Hi Scott,
Relevant question I guess since I am new to Solar2D. :slight_smile:

I’ve added this to file build.settings:
plugins = {

[“plugin.firebaseDatabase”] =
{
publisherId = “tech.scotth”
},
},

I assume this is what you ask, right? I am using verison 2020.3626.