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

logOut() throws "user is anonymous" error even if I check Purchases.isAnonymous first #934

Open
lukepighetti opened this issue Jan 14, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@lukepighetti
Copy link

lukepighetti commented Jan 14, 2024

If I check that the current session is not anonymous before calling Purchases.logOut(), I still get a "user is anonymous" error

if (!await Purchases.isAnonymous) Purchases.logOut();

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(22, LogOut was called but the current user is anonymous., {message: LogOut was called but the current user is anonymous., readableErrorCode: LOGOUT_CALLED_WITH_ANONYMOUS_USER, code: 22, underlyingErrorMessage: , readable_error_code: LOGOUT_CALLED_WITH_ANONYMOUS_USER}, null)

@lukepighetti lukepighetti added the bug Something isn't working label Jan 14, 2024
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@mshmoustafa
Copy link
Contributor

Hi @lukepighetti,
That's strange, any chance you could print the result of !await Purchases.isAnonymous as well as the app user ID?

@AlexSeednov
Copy link

Hi guys! Also saw this strange situation couple weeks ago. As I understood it's not a regular issue, just happened sometimes.

Maybe it's better to not to throw exception in this case? Just do the same checking await Purchases.isAnonymous inside logOut function and make a log out only if it's false without throwing exceptions or logging errors otherwise.

Anyway, thanks for your time and your package! It's awesome

@mshmoustafa
Copy link
Contributor

Hi all,

After discussing with the mobile engineering team we decided that since calling logOut with an anonymous iD is a non-successful state, we're going to keep this as an exception.

One thing that came up: you may have to use if (!await Purchases.isAnonymous) await Purchases.logOut();

@lukepighetti
Copy link
Author

I'm having a hard time understanding the last message posted.

if (!await Purchases.isAnonymous) Purchases.logOut();

and

if (!await Purchases.isAnonymous) await Purchases.logOut();

Should both work

and ideally, Purchases.logOut() would just make this check internally so we don't have to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants