How do I use the Firebase API?

I’m new to solar 2d and I can’t figure out how to transfer data to the realtime database using a token. Please help, give an example of how this can be done. I want to use the database to store user game data.

My approach may not necessarily meet your needs, so refer to it with caution.

First,buy it. Solar2d Marketplace
Mr.scotth is a great developer in our Solar2D community and you can trust his products.

Then follow the basic settings in the document to set up your Firebase platform information.

Finally, I provide my “Realtime Check” code. As long as you understand this project, you will know how to write storage or other functions.

local json = require("json")

local firestore = require("plugin.firestore")
firestore.init("YourData", "YourData", "YourData")

local function GetInfo(DataK,DataV)
	if DataK == "YourFieldName1" then
		print(DataV,"YourFieldData1")
	elseif DataK == "YourFieldName2" then
		print(DataV,"YourFieldData2")
	end
	return true
end

firestore.checkRealtime("YourCollections","YourDocuments", function ( e )
	if (e.isError == true) then
		print(e.isError)
	else
		for k,v in pairs(json.decode(json.encode(e.data))) do
			GetInfo(k,v)
		end
	end
end)
2 Likes