Solved

Firebase auth + revenue cat - customer flow

  • 7 December 2023
  • 2 replies
  • 96 views

Badge +2

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.

icon

Best answer by cody 11 December 2023, 17:04

View original

2 replies

Userlevel 6
Badge +8

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

Badge +2

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