New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
firebase disconnects user when changing scene #326
Comments
This might be an issue with Unity cleaning up Firebase data between scenes. If you're holding onto the FirebaseApp object in a monobehavior and that object gets cleaned up, the FirebaseApp (and Auth) might get cleaned up with it, causing the user to get logged out. Try holding a global reference to the FirebaseApp object that will persist between scene transitions and see if that fixes the issue. |
Actually, thinking about it more, you should only need to hold on to a reference to Auth, not App, so you can try making the Auth object global instead (or do both, it won't hurt) |
I found it interesting, when I tested in the cellar, there was not this error of disconnecting, how can I make to remain always active the global firebase by the unity? could you show me an example? |
Thanks @alexames it works great with reference to Auth and FirebaseApp. public static Firebase.Auth.FirebaseAuth Auth; |
Hi @H4rdG4m3 Please let us know if this resolves your issue. If the issue remains, it would be very helpful if you can provide "error of disconnecting". |
Hi @H4rdG4m3 , I'd like to chime in here with one more pattern, storing the reference in a ScriptableObject. This will also persist between scenes, you can reference them in serialized fields, and can cut back on the some of the code smell of a static field singleton (although it's effectively the same as one). If the suggestions here don't resolve your issue, please feel free to re-open this bug! --Patrick [Edit: for code samples, this is the talk that caused me to adapt this pattern. I don't follow its recommendations exactly, but it's a great starting point https://www.youtube.com/watch?v=raQ3iHhE_Kk ] |
Please fill in the following fields:
Unity editor version: 2018.3.7
Firebase Unity SDK version: 5.4.4
Additional SDKs you are using (Facebook, AdMob, etc.): email
Platform you are using the Unity editor on (Mac, Windows, or Linux): windows
Platform you are targeting (iOS, Android, and/or desktop): android
Please describe the issue here:
(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)
Please answer the following, if applicable:
Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
For some reason when I log in through the Firebase auth, I go to the next scene, however, after that scene I go to another, my user is disconnected, does anyone know the reason?
The text was updated successfully, but these errors were encountered: