예제 #1
0
    /// <summary>
    /// Sign in with device
    /// </summary>
    private void SignInWithDeviceId()
    {
        debugReporter.text = debugReporter.text + "\n" + "SignInWithDeviceId(): Trying to sign in with device id...";

        PlayFabClientAPI.LoginWithAndroidDeviceID(new LoginWithAndroidDeviceIDRequest()
        {
            TitleId         = PlayFabSettings.TitleId,
            AndroidDevice   = SystemInfo.deviceModel,
            AndroidDeviceId = SystemInfo.deviceUniqueIdentifier,
            OS            = SystemInfo.operatingSystem,
            CreateAccount = true
        }, (result) =>
        {
            playFabId          = result.PlayFabId;
            isAuthenticated    = true;
            debugReporter.text = debugReporter.text + "\n" + "SignInWithDeviceId(): succesful with playFabId: " + result.PlayFabId.ToString();
            CheckVersionOnLogin();
            ChestObject.GetLastChestOpenTime();
        }, OnPlayFabError);
    }
예제 #2
0
    /// <summary>
    /// Sign in with google
    /// </summary>
    private void SignInWithGoogle()
    {
        debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() called";

        try
        {
            connectingAnimation.SetActive(true);
            Social.localUser.Authenticate((bool success) =>
            {
                if (success)
                {
                    debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : Success auth... ";
                    try
                    {
                        debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : createAccount true scenario stepped in";

                        debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : checking if google account exists with auth code: " + authCode;

                        PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
                        {
                            TitleId        = PlayFabSettings.TitleId,
                            ServerAuthCode = authCode,
                            CreateAccount  = true,
                        }, (result) =>
                        {
                            playFabId          = result.PlayFabId;
                            debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : Account created with id: " + result.PlayFabId;
                            debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : Preparing to call LinkDeviceIdWithAccount();";
                            SetDisplayName();
                            CheckVersionOnLogin();
                            ChestObject.GetLastChestOpenTime();
                        }, OnGoogleAccountLoginResultFailed);
                    }
                    catch (Exception exception)
                    {
                        debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : Authenticate to playfab or google auth code refresh failed with error: " + exception.Message;
                        connectingAnimation.SetActive(false);

                        if (Application.internetReachability == NetworkReachability.NotReachable)
                        {
                            FindObjectOfType <ShowErrorMessageController>().SetErrorMessage("PLEASE CONNECT TO THE INTERNET TO LOGIN");
                        }
                        else
                        {
                            FindObjectOfType <ShowErrorMessageController>().SetErrorMessage(exception.Message);
                        }
                    }
                }
                else
                {
                    if (Application.internetReachability == NetworkReachability.NotReachable)
                    {
                        FindObjectOfType <ShowErrorMessageController>().SetErrorMessage("PLEASE CONNECT TO THE INTERNET FIRST"); //legit
                        debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : Please connect to the internet first!";
                    }

                    debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : Authentication to google failed";
                    connectingAnimation.SetActive(false);
                }
            });
        }
        catch (Exception exception)
        {
            debugReporter.text = debugReporter.text + "\n" + "SignInWithGoogle() : Authenticate process failed with error: " + exception.Message;
            connectingAnimation.SetActive(false);
        }
    }