示例#1
0
 void HandleOnLoginSuccess(string message)
 {
     SaveLoginPathway();
     PlayFabLoginCalls.RequestSpinner();
     PlayFabLoginCalls.GetAccountInfo();
     this.activeState = LoginStates.LoggedIn;
 }
示例#2
0
    void handleButton(Button b)
    {
        Text buttonText = b.transform.FindChild("Text").GetComponent <Text>() as Text;

        switch (buttonText.text)
        {
        case "Use Device Id":
            PlayFabLoginCalls.RequestSpinner();
            PlayFabLoginCalls.LoginWithDeviceId(false);
            break;

        case "Register":
            authController.activeState = AuthenticationController.LoginStates.Register;
            break;

        case "Exit":
            //authController.activeState = AuthenticationController.LoginStates.Register;
            Application.Quit();
            break;

        case "Enter Account Manually":
            authController.activeState = AuthenticationController.LoginStates.Manual;
            break;
        }
    }
    /// <summary>
    /// Gets the device identifier and updates the static variables
    /// </summary>
    /// <returns><c>true</c>, if device identifier was obtained, <c>false</c> otherwise.</returns>
    static bool GetDeviceId()
    {
        if (PlayFabLoginCalls.CheckForSupportedMobilePlatform())
        {
                        #if UNITY_ANDROID
            //http://answers.unity3d.com/questions/430630/how-can-i-get-android-id-.html
            AndroidJavaClass  clsUnity    = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject objActivity = clsUnity.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject objResolver = objActivity.Call <AndroidJavaObject>("getContentResolver");
            AndroidJavaClass  clsSecure   = new AndroidJavaClass("android.provider.Settings$Secure");
            android_id = clsSecure.CallStatic <string>("getString", objResolver, "android_id");
                        #endif

                        #if UNITY_IPHONE
            ios_id = UnityEngine.iOS.Device.vendorIdentifier;
                        #endif
            return(true);
        }
        else
        {
            if (OnPlayFabError != null)
            {
                OnPlayFabError("Must be using android or ios platforms to use deveice id.", PlayFabAPIMethods.Generic);
            }
            return(false);
        }
    }
示例#4
0
 /// <summary>
 /// Callback function that we are directing our Android native plugin to return the token to. Currently this is a bit messy, but we needed to guarantee a gameObject would be active to catch the callback.
 /// </summary>
 /// <param name="token">Token from the native plugin</param>
 public void OnGoogleTokenReceived(string token)
 {
     Debug.Log("Token Recieved from the native plugin");
     PlayFabLoginCalls.Token = token;
     Debug.Log(string.Format("g+ Token: {0}", token));
     PlayFabLoginCalls.RequestSpinner();
     PlayFabLoginCalls.SignOnWithGoogle(token);
 }
示例#5
0
 void HandleCallbackSuccess(string message, PlayFabAPIMethods method)
 {
     if (method == PlayFabAPIMethods.RegisterPlayFabUser)
     {
         Debug.Log("Account Created, logging in with new account.");
         PlayFabLoginCalls.RequestSpinner();
         PlayFabLoginCalls.LoginWithUsername(user.text, pass1.text);
     }
 }
    /// <summary>
    /// Triggers the backend to send an account recovery email to the account provided
    /// </summary>
    /// <param name="email">Email to match</param>
    public static void SendAccountRecoveryEmail(string email)
    {
        PlayFabLoginCalls.RequestSpinner();
        SendAccountRecoveryEmailRequest request = new SendAccountRecoveryEmailRequest();

        request.Email   = email;
        request.TitleId = PlayFabSettings.TitleId;

        PlayFabClientAPI.SendAccountRecoveryEmail(request, OnSendAccountRecoveryEmailSuccess, OnPlayFabCallbackError);
    }
    /// <summary>
    /// Adds the user name and password to a partial (guest) account
    /// </summary>
    /// <param name="user">User - username to use (must be unique)</param>
    /// <param name="pass">Pass - password to use for the account, (must be > 5 characters)</param>
    /// <param name="email">Email - email to use (must be unique)</param>
    public static void AddUserNameAndPassword(string user, string pass, string email)
    {
        PlayFabLoginCalls.RequestSpinner();
        AddUsernamePasswordRequest request = new AddUsernamePasswordRequest();

        request.Email    = email;
        request.Password = pass;
        request.Username = user;

        PlayFabClientAPI.AddUsernamePassword(request, OnAddUserNameAndPasswordSuccess, OnPlayFabCallbackError);
    }
示例#8
0
 public void LogIn()
 {
     PlayFabLoginCalls.RequestSpinner();
     if (User.text.Contains("@"))
     {
         PlayFabLoginCalls.LoginWithEmail(User.text, Password.text);
     }
     else
     {
         PlayFabLoginCalls.LoginWithUsername(User.text, Password.text);
     }
 }
 /// <summary>
 /// Unlinks a mobile device from a PlayFab account
 /// </summary>
 public static void UnlinkDeviceId()
 {
     if (GetDeviceId())
     {
         PlayFabLoginCalls.RequestSpinner();
         if (!string.IsNullOrEmpty(android_id))
         {
             Debug.Log("Unlinking Android");
             UnlinkAndroidDeviceIDRequest request = new UnlinkAndroidDeviceIDRequest();
             PlayFabClientAPI.UnlinkAndroidDeviceID(request, OnUnlinkAndroidDeviceIdSuccess, OnPlayFabCallbackError);
         }
         else if (!string.IsNullOrEmpty(ios_id))
         {
             Debug.Log("Unlinking iOS");
             UnlinkIOSDeviceIDRequest request = new UnlinkIOSDeviceIDRequest();
             PlayFabClientAPI.UnlinkIOSDeviceID(request, OnUnlinkIosDeviceIdSuccess, OnPlayFabCallbackError);
         }
     }
 }
    void Login()
    {
        Debug.Log("Login Path: " + this.loginPathToUse);
        switch (this.loginPathToUse)
        {
        case PlayFabLoginCalls.LoginPathways.pf_username:
            PlayFabLoginCalls.RequestSpinner();
            PlayFabLoginCalls.LoginWithUsername(this.accountInfo.Username, this.password.text);
            break;

        case PlayFabLoginCalls.LoginPathways.pf_email:
            PlayFabLoginCalls.RequestSpinner();
            PlayFabLoginCalls.LoginWithEmail(this.accountInfo.PrivateInfo.Email, this.password.text);
            break;

        case PlayFabLoginCalls.LoginPathways.deviceId:
            PlayFabLoginCalls.RequestSpinner();
            PlayFabLoginCalls.TestDeviceIdHasAccount();
            break;

        case PlayFabLoginCalls.LoginPathways.facebook:
            this.isCounting = false;
            PlayFabLoginCalls.RequestSpinner();
            PlayFabLoginCalls.StartFacebookLogin();
            break;

        case PlayFabLoginCalls.LoginPathways.gameCenter:
            this.isCounting = false;
            PlayFabLoginCalls.RequestSpinner();
            PlayFabLoginCalls.StartGameCenterLogin();
            break;

        case PlayFabLoginCalls.LoginPathways.googlePlus:
            this.isCounting = false;
            PlayFabLoginCalls.RequestSpinner();
            PlayFabLoginCalls.StartGooglePlusLogin();
            break;

        case PlayFabLoginCalls.LoginPathways.steam:
            Debug.LogWarning("Steam Token Authentication not yet implemented.");
            break;
        }
    }
    void EvaluateAccountInfo()
    {
        if (PlayFabLoginCalls.LoggedInUserInfo != null)
        {
            this.InfoHeading.text = string.Format("PlayFab Account Info ({0}):", PlayFabLoginCalls.LoggedInUserInfo.PlayFabId);
            if (PlayFabLoginCalls.LoggedInUserInfo.Username == null && PlayFabLoginCalls.LoggedInUserInfo.PrivateInfo.Email == null)
            {
                partialAccount.gameObject.SetActive(true);
                completeAccount.gameObject.SetActive(false);
            }
            else
            {
                partialAccount.gameObject.SetActive(false);
                completeAccount.gameObject.SetActive(true);
                this.activeEmail.text = string.Format("Email: {0}", PlayFabLoginCalls.LoggedInUserInfo.PrivateInfo.Email);
                this.activeUser.text  = string.Format("Username: {0}", PlayFabLoginCalls.LoggedInUserInfo.Username);
            }

            if (!string.IsNullOrEmpty(PlayFabLoginCalls.LoggedInUserInfo.TitleInfo.DisplayName))
            {
                this.displayName.text = PlayFabLoginCalls.LoggedInUserInfo.TitleInfo.DisplayName;
            }

            if (string.IsNullOrEmpty(PlayFabLoginCalls.android_id) && string.IsNullOrEmpty(PlayFabLoginCalls.ios_id))
            {
                LinkDevice.GetComponent <Image>().color = Color.green;
                LinkDevice.transform.FindChild("Text").GetComponent <Text>().text = "Link this device to this account";
                LinkDevice.onClick.RemoveAllListeners();
                LinkDevice.onClick.AddListener(() => PlayFabLoginCalls.LinkDeviceId());
            }
            else
            {
                LinkDevice.GetComponent <Image>().color = Color.red;
                LinkDevice.transform.FindChild("Text").GetComponent <Text>().text = "Unlink this device to this account";
                LinkDevice.onClick.RemoveAllListeners();
                LinkDevice.onClick.AddListener(() => PlayFabLoginCalls.UnlinkDeviceId());
            }
        }
        else
        {
            Debug.Log("Account was null");
        }
    }
示例#12
0
 public void LogIn()
 {
     PlayFabLoginCalls.StartFacebookLogin();
 }
    /// <summary>
    /// Parses Unity PlayerPrefs for saved login information. See the gitHub readme for more information
    /// </summary>
    /// <returns> used for coroutine yielding </returns>
    IEnumerator ReadLoginDataRecord()
    {
        this.status.text = "Finding previous logins...";

        if (PlayerPrefs.HasKey("loginMethodUsed"))
        {
            this.status.text = "Previous login found... ";
            string raw = PlayerPrefs.GetString("loginMethodUsed");

            PlayFabLoginCalls.LoginPathways method = (PlayFabLoginCalls.LoginPathways)Enum.Parse(typeof(PlayFabLoginCalls.LoginPathways), raw);
            Debug.Log(method.ToString());

            switch (method)
            {
            case PlayFabLoginCalls.LoginPathways.pf_username:
                if (PlayerPrefs.HasKey("accountInfo"))
                {
                    this.accountInfo      = JsonConvert.DeserializeObject <UserAccountInfo>(PlayerPrefs.GetString("accountInfo"));
                    this.createNewAccount = false;
                    PrompForPassword();
                    this.details.text      = string.Format("PlayFab Username: {0} found...", this.accountInfo.Username);
                    this.instructions.text = "Enter password to continue, or change accounts manually by clicking below.";
                    this.loginPathToUse    = PlayFabLoginCalls.LoginPathways.pf_username;
                }
                break;

            case PlayFabLoginCalls.LoginPathways.pf_email:
                if (PlayerPrefs.HasKey("accountInfo"))
                {
                    this.accountInfo      = JsonConvert.DeserializeObject <UserAccountInfo>(PlayerPrefs.GetString("accountInfo"));
                    this.createNewAccount = false;
                    PrompForPassword();
                    this.details.text      = string.Format("Email: {0} found...", this.accountInfo.PrivateInfo.Email);
                    this.instructions.text = "Enter password to continue, or change accounts manually by clicking below.";
                    this.loginPathToUse    = PlayFabLoginCalls.LoginPathways.pf_email;
                }
                break;

            case PlayFabLoginCalls.LoginPathways.deviceId:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Device Id, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.deviceId;
                break;

            case PlayFabLoginCalls.LoginPathways.facebook:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Facebook, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.facebook;
                break;

            case PlayFabLoginCalls.LoginPathways.gameCenter:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "GameCenter, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.gameCenter;
                break;

            case PlayFabLoginCalls.LoginPathways.googlePlus:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Google+, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.googlePlus;
                break;

            case PlayFabLoginCalls.LoginPathways.steam:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Steam, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.steam;
                break;

            default:
                AutoNewAccount();
                break;
            }
        }
        else
        {
            if (PlayFabLoginCalls.CheckForSupportedMobilePlatform())
            {
                AutoNewAccount();
            }
            else
            {
                PlayFabLoginCalls.TestDeviceIdHasAccount();
                yield return(new WaitForSeconds(.333f));

                authController.activeState = AuthenticationController.LoginStates.Manual;
            }
        }
    }
 void CreateNewAndLogin()
 {
     this.newAccountPrompt.gameObject.SetActive(false);
     PlayFabLoginCalls.RequestSpinner();
     PlayFabLoginCalls.LoginWithDeviceId(this.createNewAccount);
 }
示例#15
0
 public void RegisterNewAccount()
 {
     PlayFabLoginCalls.RequestSpinner();
     PlayFabLoginCalls.RegisterNewPlayfabAccount(user.text, pass1.text, pass2.text, email.text);
 }
 void Logout()
 {
     PlayFabLoginCalls.Logout();
 }
示例#17
0
 public void LogIn()
 {
     PlayFabLoginCalls.RequestSpinner();
     PlayFabLoginCalls.StartGameCenterLogin();
 }
 // Use this for initialization
 void Start()
 {
     this.UpdateDisplayName.onClick.AddListener(() => PlayFabLoginCalls.UpdateDisplayName(this.displayName.text));
     this.CompleteAccount.onClick.AddListener(() => PlayFabLoginCalls.AddUserNameAndPassword(username.text, password.text, email.text));
     this.SendRecoveryEmail.onClick.AddListener(() => PlayFabLoginCalls.SendAccountRecoveryEmail(PlayFabLoginCalls.LoggedInUserInfo.PrivateInfo.Email));
 }
 public void LogIn()
 {
             #if !UNITY_EDITOR && UNITY_ANDROID
     PlayFabLoginCalls.StartGooglePlusLogin();
             #endif
 }