Skip to main content
Solved

Firebase auth + revenue cat - customer flow


Forum|alt.badge.img+3

I’ve successfully, it seems, integrate revenue cat with my firebase auth backend. Now I’m wondering what is the recommended customer journey in terms of what they do first? 

Should I ensure that my users first authenticate with firebase, before allowing them to purchase an in-app subscription?

What would happen if they first purchased the subscription and then authenticated on firebase after?

Thanks for any help or suggestions.

Best answer by cody

Hey @grin_phi!

From RevenueCat’s perspective, we’ll always track purchases once our SDK is configured, either with your configured user ID or with a random anonymous ID. If you don’t want to have anonymous IDs, I’d recommend first authenticating with Firebase, and passing that identifier into RevenueCat’s SDK during configure or `login`.

Generally, it will be up to your personal preference, but you can read more about user identifiers here: https://www.revenuecat.com/docs/user-ids

View original
Did this post help you find an answer to your question?

2 replies

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 487 replies
  • Answer
  • December 11, 2023

Hey @grin_phi!

From RevenueCat’s perspective, we’ll always track purchases once our SDK is configured, either with your configured user ID or with a random anonymous ID. If you don’t want to have anonymous IDs, I’d recommend first authenticating with Firebase, and passing that identifier into RevenueCat’s SDK during configure or `login`.

Generally, it will be up to your personal preference, but you can read more about user identifiers here: https://www.revenuecat.com/docs/user-ids


Forum|alt.badge.img+3
  • Author
  • New Member
  • 2 replies
  • December 11, 2023

Thanks @cody - appreciate the reply!

So, I think I’m doing what you suggest as a result of integrating Firebase with Revenue Cat. In DidFinishLaunchingWithOptions I’ve got:
 

Purchases.configure(withAPIKey: "<my_api_key>")
    Purchases.shared.delegate = self

      FirebaseApp.configure()

      Auth.auth().addStateDidChangeListener { (auth, user) in

              if let uid = user?.uid {

                  // identify Purchases SDK with new Firebase user
                  Purchases.shared.logIn(uid, completion: { (info, created, error) in
                      if let error {
                          print("Sign in error: \(error.localizedDescription)")
                      } else {
                          print("User \(uid) signed in")
                      }
                  })
              }
          }

 

Which I feel is passing the firebase uid to revene cat. 

Does it look like its doing that to you? 


Reply


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