This extension allows you to interact with Firebase Analytics in a uniform way for games on iOS and Android.
To use this library in your Defold project, add the following URLs to your game.project
dependencies:
Firebase C++ SDK | Firebase iOS SDK | Dependencies |
---|---|---|
Firebase C++ SDK 8.10.0 | Firebase iOS SDK 8.13.0 | https://github.com/defold/extension-firebase/archive/refs/tags/1.4.2.zip https://github.com/defold/extension-firebase-analytics/archive/refs/tags/2.2.0.zip |
Follow the main setup guide for integration of Firebase in Defold.
function init(self)
-- use firebase only if it is supported on the current platform
if not firebase then
return
end
-- initialise firebase and check that it was successful
local ok, err = firebase.init()
if not ok then
print(err)
return
end
-- initialise analytics
firebase.analytics.init()
-- log data
firebase.analytics.set_screen("myscreen", "collection")
firebase.analytics.log_string("character", "storm trooper")
firebase.analytics.log_int("kills", 152)
firebase.analytics.log_number("speed", 1.15)
local t = {
number = math.random(1,100),
boolean = true,
string = "some_string"
}
firebase.analytics.log_table("stats", t)
end
The source code is available on GitHub
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
GITHUB