SignInWithAppleTest_Callbacks.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using Facebook.Unity.Example;
  3. using UnityEngine;
  4. #if UNITY_IOS
  5. using UnityEngine.iOS;
  6. //using UnityEngine.SignInWithApple;
  7. #endif
  8. public class SignInWithAppleTest_Callbacks : MonoBehaviour
  9. {
  10. private string userId;
  11. //#if UNITY_IOS
  12. // public void ButtonPress()
  13. // {
  14. // var siwa = gameObject.GetComponent<SignInWithApple>();
  15. // if(PlayerPrefs.GetInt("APPLE") == 0)
  16. // {
  17. // siwa.Login(OnLogin);
  18. // }
  19. // }
  20. // public void CredentialButton()
  21. // {
  22. // // User id that was obtained from the user signed into your app for the first time.
  23. // var siwa = gameObject.GetComponent<SignInWithApple>();
  24. // siwa.GetCredentialState(userId, OnCredentialState);
  25. // }
  26. // private void OnCredentialState(SignInWithApple.CallbackArgs args)
  27. // {
  28. // Debug.Log(string.Format("User credential state is: {0}", args.credentialState));
  29. // if (args.error != null)
  30. // Debug.Log(string.Format("Errors occurred: {0}", args.error));
  31. // }
  32. // private void OnLogin(SignInWithApple.CallbackArgs args)
  33. // {
  34. // if (args.error != null)
  35. // {
  36. // Debug.Log("Errors occurred: " + args.error);
  37. // return;
  38. // }
  39. // MenuManager._instance.ChangeLoginPopup.Hide();
  40. // UnityEngine.SignInWithApple.UserInfo userInfo = args.userInfo;
  41. // // Save the userId so we can use it later for other operations.
  42. // userId = userInfo.userId;
  43. // var allName = userInfo.displayName.Split(' ');
  44. // var _name = allName[0];
  45. // var _surname = allName[1];
  46. // // Print out information about the user who logged in.
  47. // SocialManager.Instance.userID = userInfo.userId;
  48. // SocialManager.Instance._name = _name;
  49. // SocialManager.Instance._surname = _surname;
  50. // SocialManager.Instance._usermail= userInfo.email;
  51. // SocialManager.Instance._username = userInfo.userId;
  52. // SocialManager.Instance._deviceId = GameDatabaseManager.Instance.GetDevice();
  53. // PlayerPrefs.SetString("UserID", userInfo.userId);
  54. // PlayerPrefs.SetInt("Login", 1);
  55. // PlayerPrefs.Save();
  56. // GameDatabaseManager.Instance.RegisterUser(userInfo.userId, _name, _surname, userInfo.displayName, userInfo.email, GameDatabaseManager.Instance.GetDevice(), OnLoginCompleted);
  57. // Debug.Log(
  58. // string.Format("Display Name: {0}\nEmail: {1}\nUser ID: {2}\nID Token: {3}", userInfo.displayName ?? "",
  59. // userInfo.email ?? "", userInfo.userId ?? "", userInfo.idToken ?? ""));
  60. // }
  61. // private void OnLoginCompleted(bool arg1, string arg2)
  62. // {
  63. // Debug.Log("arg2 " + arg2);
  64. // PlayerPrefs.SetInt("APPLE", 1);
  65. // PlayerPrefs.Save();
  66. // }
  67. //#endif
  68. }