Advertisement
Guest User

Untitled

a guest
May 24th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. private Firebase.Auth.FirebaseAuth auth;
  2.  
  3. :
  4.  
  5. // Use this for initialization
  6. void Start () {
  7. auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
  8. }
  9.  
  10. :
  11.  
  12. public void OnClickLoginButton()
  13. {
  14. Text usernameField = GameObject.Find("UserNameText").GetComponent<Text>();
  15. Text passwordField = GameObject.Find("PasswordText").GetComponent<Text>();
  16. string username = usernameField.text;
  17. string password = passwordField.text;
  18. auth.CreateUserWithEmailAndPasswordAsync(username, password).ContinueWith(task0 => {
  19. if (!task0.IsCanceled && !task0.IsFaulted){
  20. Debug.Log(string.Format("Created {0}", usernameField.text));
  21. auth.SignInWithEmailAndPasswordAsync(username, password).ContinueWith(task1 =>{
  22. if(!task1.IsFaulted && !task1.IsCanceled){
  23. Debug.Log(string.Format("Logined {0}", usernameField.text));
  24. Firebase.Auth.FirebaseUser user = auth.CurrentUser;
  25. if(user != null){
  26. Debug.Log(string.Format("UserName is {0}", user.Email));
  27. Debug.Log(string.Format("UserID is {0}", user.UserId));
  28. // ここにログイン完了時の処理を入れる
  29. }
  30. }
  31. });
  32. }
  33. else{
  34. Debug.Log(string.Format("Creation failed {0}", usernameField.text));
  35. }
  36. });
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement