sdk-android icon indicating copy to clipboard operation
sdk-android copied to clipboard

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

Open fershopls opened this issue 5 years ago • 1 comments

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?

fershopls avatar May 15 '21 20:05 fershopls

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.

bobzettle avatar Sep 15 '21 08:09 bobzettle