Question

Is it safe to call Purchases.configure() multiple times.

  • 15 November 2023
  • 4 replies
  • 61 views

Badge +4

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


4 replies

Userlevel 3
Badge +3

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

Badge +4

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

Userlevel 3
Badge +3

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

Badge +4

Thank you @Cesar 

Reply