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 URL to your game.project
dependencies:
https://github.com/defold/extension-firebase-analytics/archive/master.zip
We recommend using a link to a zip file of a specific release.
The steps below taken from the official Google Firebase Guides.
google-services.json
file. You can download this file again at any time.GoogleService-Info.plist
file. You can download this file again at any time.You can use the extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:
https://github.com/defold/extension-firebase/archive/master.zip
Or point to the ZIP file of a specific release (recommended!).
generate_xml_from_google_services_json.py
or generate_xml_from_google_services_json.exe
(both from Firebase C++ SDK) to convert the previously downloaded google-services.json
to an Android resource XML:$ ./generate_xml_from_google_services_json.py -i google-services.json -o google-services.xml
google-services.xml
file to a folder structure like this:<project_root>
|
+-bundle
|
+-android
|
+-res
|
+-values
|
+-google-services.xml
game.project
and set the Bundle Resources
entry under the Project
section to /bundle
to match the folder created in the step above. Read more about the Bundle Resources
setting in the Defold manual.GoogleService-Info.plist
file to a folder structure like this:<project_root>
|
+-bundle
|
+-ios
|
+-GoogleService-Info.plist
game.project
and set the Bundle Resources
entry under the Project
section to /bundle
to match the folder created in the step above. Read more about the Bundle Resources
setting in the Defold manual.function init(self)
-- use firebase only if it is supported on the current platform
if firebase then
firebase.init()
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
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