FirebaseAuthenticationManager.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using SimpleFirebaseUnity;
  4. public class FirebaseAuthenticationManager : Singleton<FirebaseAuthenticationManager>
  5. {
  6. protected override void Awake()
  7. {
  8. base.Awake();
  9. DontDestroyOnLoad(this);
  10. // InitFireBase();
  11. EnableEvents();
  12. }
  13. private void EnableEvents()
  14. {
  15. /* auth.OnSignInWithPasswordSuccess += OnSignInWithPasswordSuccess;
  16. auth.OnSignInWithPasswordFailed += OnSignInWithPasswordFailed;
  17. auth.OnSignUpWithPasswordSuccess += OnSignUpWithPasswordSuccess;
  18. auth.OnSignUpWithPasswordFailed += OnSignUpWithPasswordFailed;
  19. auth.OnSignInOrUpWithCredentialSuccess += OnSignInOrUpWithCredentialSuccess;
  20. auth.OnSignInOrUpWithCredentialFailed += OnSignInOrUpWithCredentialFailed;*/
  21. }
  22. private void OnSignInWithPasswordSuccess(FirebaseAuthentication sender, DataSnapshot snapshot)
  23. {
  24. // Debug.Log("[OK] Raw Json: " + snapshot.RawJson);
  25. // Dictionary<string, object> dict = snapshot.Value<Dictionary<string, object>>();
  26. List<string> keys = snapshot.Keys;
  27. if (keys != null)
  28. foreach (string key in keys)
  29. {
  30. // Debug.Log(key + " = " + dict[key].ToString());
  31. }
  32. }
  33. private void OnSignInWithPasswordFailed(FirebaseAuthentication sender, FirebaseError err)
  34. {
  35. // Debug.Log("[ERR] Login : " + err.Message + " (" + (int)err.Status + ")");
  36. }
  37. private void OnSignUpWithPasswordSuccess(FirebaseAuthentication sender, DataSnapshot snapshot)
  38. {
  39. // Debug.Log("[OK] Raw Json: " + snapshot.RawJson);
  40. // Dictionary<string, object> dict = snapshot.Value<Dictionary<string, object>>();
  41. List<string> keys = snapshot.Keys;
  42. if (keys != null)
  43. foreach (string key in keys)
  44. {
  45. // Debug.Log(key + " = " + dict[key].ToString());
  46. }
  47. }
  48. private void OnSignUpWithPasswordFailed(FirebaseAuthentication sender, FirebaseError err)
  49. {
  50. // Debug.Log("[ERR] Login : " + err.Message + " (" + (int)err.Status + ")");
  51. }
  52. private void OnSignInOrUpWithCredentialSuccess(FirebaseAuthentication sender, DataSnapshot snapshot)
  53. {
  54. // Debug.Log("[OK] Raw Json: " + snapshot.RawJson);
  55. // Dictionary<string, object> dict = snapshot.Value<Dictionary<string, object>>();
  56. List<string> keys = snapshot.Keys;
  57. if (keys != null)
  58. foreach (string key in keys)
  59. {
  60. // Debug.Log(key + " = " + dict[key].ToString());
  61. }
  62. }
  63. private void OnSignInOrUpWithCredentialFailed(FirebaseAuthentication sender, FirebaseError err)
  64. {
  65. // Debug.Log("[ERR] Login : " + err.Message + " (" + (int)err.Status + ")");
  66. }
  67. }