Skip to main content

Hello, I am working with no anonymous Id’s on Flutter App. Once the user logs in for the first time I call Purchases.configure(PurchasesConfiguration(‘Key’)..appUserId = ‘id’);

If a user logs out and another logs back in I call Purchases.login(‘newId’);

I have a flag to know when I have called Purchases configuration for the first time in my business logic. However, I do not know if the persistance is going to be the same as with the Revenue Cat package when app is closed, reset, etc. Will it be safe to call Purchases.configure anytime a user logs in regardless if it has been already called? If not, is there a method to validate if Revenue Cat package has been loaded?

 

Thanks

Hi Luis, you can use `Purchases.isConfigured` to check if the package is ready. Calling Purchases.configure multiple times is not recommended and logIn and logOut are the functions you should be using to login and logout your users


Hello @Cesar , thanks for the response, really helpful.

Just one more detail. It says on the documentation to not LogOut the user on the “How to Only use Custom App Ids” section, it says to simply call the Login again on the new user. Is this safe and/or correct to do? Or has it changed since the documentation?

Thanks


Actually, you’re correct, I’m sorry for the confusion. Logging out will create a new anonymous ID. You can just Log In the new user with the new User ID without Logging Out the previous user. Thanks for pointing that out


Thank you @Cesar 


Hi Luis, you can use `Purchases.isConfigured` to check if the package is ready. Calling Purchases.configure multiple times is not recommended and logIn and logOut are the functions you should be using to login and logout your users

 

I tried this, but when I call `isConfigured()` I get “Error: There is no singleton instance. Make sure you configure Purchases before trying to get the default instance.”

Sounds like a bit of a chicken and egg problem… If I have to call `configure()` before `isConfigured()`, how can I check if `configure()` has already been called without getting the error above?


Maybe things have changed since this question was originally answered a year ago. But for now I just keep calling `conifigure()` multiple times without any extra checks. Seems to work fine for me 🤷‍♂️


Reply