Example #1
0
        public async Task SignInWithFacebookIdAsync(string facebookId, string facebookToken)
        {
            LoggerService.Instance.Log("Account.SignInWithFacebookIdAsync...");

            var error   = string.Empty;
            var success = false;

            var response = await LoginClient.LoginWithFacebook(facebookId, facebookToken);

            if (response != null)
            {
                if (response.Success)
                {
                    var newUser = response.Data.ToObject <User>();
                    newUser.Name = newUser.FirstName + " " + newUser.LastName;
                    if (!string.IsNullOrEmpty(newUser.Token))
                    {
                        UserInfo = newUser;
                        await FetchUserCreditsAsync();

                        success = true;

                        UserStoreService.Instance.SaveUserCredentials(UserInfo);
                    }
                    else
                    {
                        LoggerService.Instance.Log("ERROR: Account.SignInWithFacebookIdAsync: token is null");
                        error = "There was an error signing in with Facebook";
                    }
                }
                else
                {
                    error = response.ErrorMessageClean;
                }
            }
            else
            {
                error = "There was an error signing in with Facebook";
            }

            if (!string.IsNullOrEmpty(error))
            {
                LoggerService.Instance.Log("ERROR: Account.SignInWithFacebookIdAsync: " + error);
            }
            else
            {
                LoggerService.Instance.Log("Account.SignInWithFacebookIdAsync: success");
            }

            OnPropertyChanged("SignedIn");
            await Fire_OnSignInComplete(success, error, false, SignInAErrorType.LoginError);
        }