Skip to main content
Solved

What are the differences between login and setup methods?


Forum|alt.badge.img+6

For what I could understand from reading the docs, RevenueCat has two different methods by which we can identify the user.

  • One method is by calling Purchases.login().
  • The other method is by calling Purchases.setup().

What are the differences between these two methods of identifying the user?

At first I thought I should call Purchases.setup() in my app initialization, and the login() method should be user right after I authenticate my user in my application, but it looks like I misundersdood it, because I am having some weird errors of unexpected transfers between anonymous and authenticated UIDs.

The correct way then is to use both of these two methods but only after I know which UID to apply to the user? And the setup() method should be called only once, and after it has been called then I should only call the login method?

Best answer by Andy

Hey @UlyssesAlves,

 

The setup method should be called only once, and that starts the SDK. If you pass in the appUserID to setup, it’s roughly the equivalent of doing setup + login instantly. 

 

The reason that the methods are separate is that some apps might not have the appUserID available by the time they need to call setup, so they can log in later if needed. 

 

If you call setup without an appUserID, an anonymous ID will be generated and used until you call logIn. More information on this here.

View original
Did this post help you find an answer to your question?
This post has been closed for comments

2 replies

Andy
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 237 replies
  • Answer
  • August 5, 2022

Hey @UlyssesAlves,

 

The setup method should be called only once, and that starts the SDK. If you pass in the appUserID to setup, it’s roughly the equivalent of doing setup + login instantly. 

 

The reason that the methods are separate is that some apps might not have the appUserID available by the time they need to call setup, so they can log in later if needed. 

 

If you call setup without an appUserID, an anonymous ID will be generated and used until you call logIn. More information on this here.


Forum|alt.badge.img+6
  • Author
  • Dedicated Member
  • 29 replies
  • August 5, 2022

Hi again, @Andy .

Is it OK if I design my app to not configure RevenueCat for anonymous users? As I stated in my other thread, I’m working to make my app only configure RevenueCat when I have the app user id to pass to itand my app will call login only if configure has already been called previously.

I think this could impact on how many anonymous users will be reported in RevenueCat’s dashboard. This number will become much smaller, probably, becausse in my app users only need to create their account when they are ready to buy something, although in some cases the user may create his account but not finish the purchase by canceling it manually or because of a problem on the purchase process.

Besides that, is there another concern I should be aware of when I stop calling the configure method for every user, and call it only for authenticated users in my application?


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