Godot Version
Godot 4
Question
New to Godot and self-taught, so I’m no expert!
I’ve added the Firebase plugin to my game. I’m using it to check the game’s version number vs the version number in the Realtime Database (comparing two floats - thats it - just reading some data from the database). It all works OK in the emulator, but when I port the game to real Android phone (I’ve tested on 3) the code’s execution always gets stuck in the same place.
My (simplified) code is as such:
var db_ref
func _ready():
Firebase.Auth.login_anonymous()
Firebase.Auth.signup_succeeded.connect(_on_FirebaseAuth_auth_succeeded)
Firebase.Auth.login_failed.connect(_on_login_failed)
func _on_FirebaseAuth_auth_succeeded(_auth):
print("login successful!")
db_ref = Firebase.Database.get_database_reference("config")
db_ref.new_data_update.connect(_on_db_new_data_update)
db_ref.patch_data_update.connect(_on_db_patch_data_update)
func _on_db_new_data_update(resource):
update_config(resource)
func _on_db_patch_data_update(resource):
update_config(resource)
- No problems executing the Firebase.Auth login
- No problem getting to the Firebase Auth Succeeded
So once that is achieved, the sticking point appears to be:
db_ref = Firebase.Database.get_database_reference("config")
Now, after the db_ref assignment is made I tested to see if it was still null, and NO, db_ref is NOT null, it does have a value.
However, neither _on_db_new_data_update or _on_db_patch_data_update executes. On my emulator the new_data executes and it is all good from there.
On the real device this is the sticking point. I don’t really know/understand what is happening here: Firebase.Database.get_database_reference(“config”) so it is hard for me to troubleshoot. I figure its getting a reference of the realtime database, with “config” referencing the json code I uploaded:
{
"config": {
"version_android": 1,
"version_ios": 1
}
}
I don’t have any idea what could be wrong here. I had a more senior coder assist me a few weeks ago to get this far with the code, but we only tested on a computer, not a real device.
I figure that I followed all the steps to integrate the plugin into my project correctly. There are a few things that trouble me:
-
Per the docs I was instructed to create a WebApp in Firebase. Now, there are options for iOS and Android Apps, but when you select those you don’t get the values needed for the .env file. Still, part of me thinks since the code executes on the computer but not via an Android device, then maybe the webapp vs. android app in firebase could be an issue.
-
The .env file. In my Firebase project I was not provided all the values for the .env template when I selected the WebApp. The following are missing:
“clientId”=“”
“clientSecret”=“”
“domainUriPrefix”=“”
“functionsGeoZone”=“”
“cacheLocation”=“”
authentication=“”
firestore=“”
realtimeDatabase=“”
functions=“”
storage=“”
dynamicLinks=“”
Again, it works just fine via the emulator without these values. Also, some of these values appear applicable to making user accounts and logging in and so on. But I don’t know if one of these fields being missing is the source of the error.
Any assistance would be appreciated! Thanks.