using System; using Facebook.Unity.Example; using UnityEngine; #if UNITY_IOS using UnityEngine.iOS; //using UnityEngine.SignInWithApple; #endif public class SignInWithAppleTest_Callbacks : MonoBehaviour { private string userId; //#if UNITY_IOS // public void ButtonPress() // { // var siwa = gameObject.GetComponent(); // if(PlayerPrefs.GetInt("APPLE") == 0) // { // siwa.Login(OnLogin); // } // } // public void CredentialButton() // { // // User id that was obtained from the user signed into your app for the first time. // var siwa = gameObject.GetComponent(); // siwa.GetCredentialState(userId, OnCredentialState); // } // private void OnCredentialState(SignInWithApple.CallbackArgs args) // { // Debug.Log(string.Format("User credential state is: {0}", args.credentialState)); // if (args.error != null) // Debug.Log(string.Format("Errors occurred: {0}", args.error)); // } // private void OnLogin(SignInWithApple.CallbackArgs args) // { // if (args.error != null) // { // Debug.Log("Errors occurred: " + args.error); // return; // } // MenuManager._instance.ChangeLoginPopup.Hide(); // UnityEngine.SignInWithApple.UserInfo userInfo = args.userInfo; // // Save the userId so we can use it later for other operations. // userId = userInfo.userId; // var allName = userInfo.displayName.Split(' '); // var _name = allName[0]; // var _surname = allName[1]; // // Print out information about the user who logged in. // SocialManager.Instance.userID = userInfo.userId; // SocialManager.Instance._name = _name; // SocialManager.Instance._surname = _surname; // SocialManager.Instance._usermail= userInfo.email; // SocialManager.Instance._username = userInfo.userId; // SocialManager.Instance._deviceId = GameDatabaseManager.Instance.GetDevice(); // PlayerPrefs.SetString("UserID", userInfo.userId); // PlayerPrefs.SetInt("Login", 1); // PlayerPrefs.Save(); // GameDatabaseManager.Instance.RegisterUser(userInfo.userId, _name, _surname, userInfo.displayName, userInfo.email, GameDatabaseManager.Instance.GetDevice(), OnLoginCompleted); // Debug.Log( // string.Format("Display Name: {0}\nEmail: {1}\nUser ID: {2}\nID Token: {3}", userInfo.displayName ?? "", // userInfo.email ?? "", userInfo.userId ?? "", userInfo.idToken ?? "")); // } // private void OnLoginCompleted(bool arg1, string arg2) // { // Debug.Log("arg2 " + arg2); // PlayerPrefs.SetInt("APPLE", 1); // PlayerPrefs.Save(); // } //#endif }