Skip to main content
Question

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

  • November 15, 2023
  • 6 replies
  • 272 views

Forum|alt.badge.img+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

This post has been closed for comments

6 replies

Cesar
RevenueCat Staff
Forum|alt.badge.img+3
  • RevenueCat Staff
  • 65 replies
  • November 15, 2023

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


Forum|alt.badge.img+4
  • Author
  • New Member
  • 4 replies
  • November 15, 2023

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


Cesar
RevenueCat Staff
Forum|alt.badge.img+3
  • RevenueCat Staff
  • 65 replies
  • November 15, 2023

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


Forum|alt.badge.img+4
  • Author
  • New Member
  • 4 replies
  • November 15, 2023

Thank you @Cesar 


Forum|alt.badge.img+1
  • Active Member
  • 10 replies
  • April 10, 2025
Cesar wrote:

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?


Forum|alt.badge.img+1
  • Active Member
  • 10 replies
  • April 10, 2025

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 🤷‍♂️


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings