logOut() throws "user is anonymous" error even if I check Purchases.isAnonymous first
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)
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!
Hi @lukepighetti,
That's strange, any chance you could print the result of !await Purchases.isAnonymous as well as the app user ID?
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
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();
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