quickstart-unity
quickstart-unity copied to clipboard
[FR][Database] Support connection to local Firebase emulator (Android/iOS/desktop)
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2020.1.9 personal
- Firebase Unity SDK version: 6.15.2
- Source you installed the SDK: 6.15.2 (.unitypackage or Unity Package Manager)
- Problematic Firebase Component: firebase databse realtime (Auth, Database, etc.)
- Other Firebase Components in use: firestore, functions(Auth, Database, etc.)
- Additional SDKs you are using: none (Facebook, AdMob, etc.)
- Platform you are using the Unity editor on: windows (Mac, Windows, or Linux)
- Platform you are targeting: iOS, Android, desktop (iOS, Android, and/or desktop)
- Scripting Runtime: Mono (Mono, and/or IL2CPP)
[REQUIRED] Please describe the issue here:
(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)
Steps to reproduce:
Hi, I'm currently having a problem with the value change listening event in Unity. I use Firebase emulator locally. I just get the snapshot with null value. Can you help me solve this problem. Thanks.

This code is working when I use firebase database realtime on cloud.
+1 to this one, I've been trying a bunch of different tricks with no luck trying to get this to work for the past two months... tempted to roll my own client that leverages the REST API instead just to get past this hurdle. :/
@nhutthanh340 Just to confirm, the issue only happen when you run in editor, correct?
Taking a look of the documentation, it requires some special API like database.useEmulator("10.0.2.2", 9000); in order to connect to an emulator. And unfortunately this API is not available in C++/Unity SDK yet.
Let me change this to a feature request. If you are interested in seeing this feature, please upvote the first post to let us know.
I updated the firebase.database sdk to 7.0 and changed the "firebase_url" in both google-services.json and google-services-desktop.json. I can write data to the emulator database. However, it created another database (http://localhost:9000/?ns=127) instead of my original database(http://localhost:9000/?ns=abc). I don't know why.
I have the same issue, it seems when you set the Instance to your localhost, it doesnt accept the name space, and created a new database with the name 'localhost' #if UNITY_EDITOR return FirebaseDatabase.GetInstance("http://localhost:9000?ns=project-id"); #else return FirebaseDatabase.DefaultInstance; #endif
I also have the same issue when I tried to connect my Unity project to emulator database. It connected to wrong namespace. Please fix
This feature will also enable unit testing of database functionality. See: https://stackoverflow.com/questions/69126781/how-do-you-write-integration-tests-for-firestore-on-unity
I have upvoted the original post, and I'm hoping it can be prioritized by the Firebase team. 🙏