0

I try to do some chechking everytime when user try to start the application. This is my code example:

      protected override async void OnStart()
        {


            // Handle when your app starts
            var user = await FinDataStore.GetUserToken(DependencyService.Get<ISharedFunctions>().GetUser().UserName,   DependencyService.Get<ISharedFunctions>().GetUserPassword());
            if (user != null && user.AccessToken != null)
            {
                DependencyService.Get<ISharedFunctions>().SaveAccessToken(user.AccessToken);
                DependencyService.Get<ISharedFunctions>().SaveUser(user);
                DependencyService.Get<ISharedFunctions>().SaveRefreshToken(user.RefreshToken);
                DependencyService.Get<ISharedFunctions>().SaveUserFirmi(user.Firmi);
            }
            else
            {
                ((App)Application.Current).Logout();
            }
        }

but i get the error:

Error   CS0120  An object reference is required for the non-static field, method, or property 'FinDataStore.GetUserToken(string, string)'   

This is the call :

  public async Task<User> GetUserToken(string username, string password)

How to solve this?

1 Answer 1

1

It's seems not to be a async problem. It seems you should do something like:

var myclass = new FinDataStore();

then you can

var ret = await myClass.GetUserToken...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.