Beispiel #1
0
        public async Task LinkFacebook()
        {
            //If there is no Facebook client, we can't do this
            if (null == Facebook)
            {
                Logout();
                OnPlayFabError?.Invoke(new PlayFabError()
                {
                    ErrorMessage = "No FacebookClient was detected",
                });
            }

            //Check if the user needs to log into Facebook
            if (!Facebook.LoggedIn || string.IsNullOrEmpty(AuthTicket))
            {
                //sign up for the logged in event
                Facebook.OnLoginSuccess -= OnFacebookLoggedIn;
                Facebook.OnLoginSuccess += OnFacebookLoggedIn;
                Facebook.OnLoginError   -= Facebook_OnLoginError;
                Facebook.OnLoginError   += Facebook_OnLoginError;

                //try to log in
                Facebook.Login();
            }
            else
            {
                OnLoggingIn?.Invoke();

                //grab the auth ticket from that user
                AuthTicket = Facebook.User.Token;

                var result = await PlayFabClient.LinkFacebookAccountAsync(new LinkFacebookAccountRequest()
                {
                    AccessToken = AuthTicket,
                }).ConfigureAwait(false);

                LoginResult(result);
            }
        }