Ejemplo n.º 1
0
    private void SignInWithApple()
    {
        var loginArgs = new AppleAuthLoginArgs(LoginOptions.IncludeEmail | LoginOptions.IncludeFullName);

        this._appleAuthManager.LoginWithAppleId(
            loginArgs,
            credential =>
        {
            // If a sign in with apple succeeds, we should have obtained the credential with the user id, name, and email, save it
            PlayerPrefs.SetString(AppleUserIdKey, credential.User);
            this.SetupGameMenu(credential.User, credential);
        },
            error =>
        {
            Debug.LogWarning("Sign in with Apple failed " + error.ToString());
            this.SetupLoginMenuForSignInWithApple();
        });
    }
Ejemplo n.º 2
0
    void ApplesSignin()
    {
        var loginArgs = new AppleAuthLoginArgs(LoginOptions.None);

        this.appleAuthManager.LoginWithAppleId(loginArgs,
                                               credential =>
        {
            isLoggedInwithApple = true;
            // Obtained credential, cast it to IAppleIDCredential
            var appleIdCredential = credential as IAppleIDCredential;
            if (appleIdCredential != null)
            {
                // Apple User ID
                // You should save the user ID somewhere in the device
                var userId = appleIdCredential.User;
                // Email (Received ONLY in the first login)
                var email = appleIdCredential.Email;
                // Full name (Received ONLY in the first login)
                var fullName = appleIdCredential.FullName;
                // Identity token
                var identityToken = Encoding.UTF8.GetString(appleIdCredential.IdentityToken,
                                                            0, appleIdCredential.IdentityToken.Length);

                IToken = identityToken;
                // Authorization code
                var authorizationCode = Encoding.UTF8.GetString(appleIdCredential.AuthorizationCode,
                                                                0, appleIdCredential.AuthorizationCode.Length);
                // And now you have all the information to create/login a user in yo
            }
        },
                                               error =>
        {
            // Something went wrong
            var authorizationErrorCode = error.GetAuthorizationErrorCode();
        });
    }