Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get user info from a user that is already logged in without make a Payment first? #28

Closed
fershopls opened this issue May 15, 2021 · 1 comment

Comments

@fershopls
Copy link

Expected Behavior

Open the app.
User login succesfully.
Close the app.

Reopen the app.
Attempt to get user info.
Get user info successfully.

Everything ok!

Current Behavior

I can only get user info after start activity for result with CardPaymentActivity.IntentBuilder intent.
The auth observer with the LoggedIn object its being triggered after this.

Open the app.
User login succesfully.
Close the app.

Open the app.

Attempt to get user info.
Failed because the user is not logged in.

Attempt to make a payment
Attempt to get user info.
Get user info successfully.

How can I get user info from a user that is already logged in?

@bobzettle
Copy link
Contributor

Hi, apologies for not hearing from us. Have you managed to sort this out?

Otherwise when observing the IZettleSDK.user.state.toLiveData() you will get an AuthState back.
If that state is logged in, you'll be able to extract the user info from that state.

A bit of sample code:

IZettleSDK.user.state.toLiveData().observe(this, { state ->
    when(state) {
        is LoggedIn -> state.info // here is your User.Info object.
    }
})

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants