Skip to main content
Question

Struggling with RevenueCat + Flutter (Riverpod, Firebase, GoRouter) Integration

  • March 19, 2025
  • 1 reply
  • 5 views

Forum|alt.badge.img

Hi everyone! I’m trying to integrate RevenueCat into my Flutter app, which already uses Riverpod for state managementFirebase for auth/onboarding status, and GoRouter for navigation. I’m running into issues with routing redirects, linking Firebase users to RevenueCat, and handling subscription states. Would appreciate guidance or examples!

My Setup:

  1. Authentication: Firebase Auth (users marked as "completed onboarding" in Firestore).

  2. Routing: GoRouter with redirect logic to handle onboarding/auth flows.

  3. RevenueCat: Configured, but struggling to link Firebase users and prevent paywall errors.

Key Issues:

  1. Routing Conflicts:

    • Using redirect in GoRouter, but async checks (onboarding status, subscription) cause race conditions.

    • Example: Sometimes the app shows the paywall even if the user has an active subscription, or redirects incorrectly.

  2. Linking Firebase ↔ RevenueCat:

    • How do I ensure the Firebase user ID is synced with RevenueCat’s user ID after login?

  3. State Management:

    • Using Riverpod to track onboarding, auth, and subscription status. How to coordinate these for routing?

What I’ve Tried:

  • RevenueCat Login: Calling Purchases.logIn(firebaseUID) after Firebase authentication.

  • Routing Logic: Redirecting based on ref.watch(authProvider) and ref.watch(subscriptionProvider), but async states don’t always resolve in time.

Questions:

  1. How do you synchronize Firebase users with RevenueCat reliably?

  2. How to structure GoRouter redirects to wait for async checks (onboarding, subscription)?

  3. Are there working examples of Flutter apps using Riverpod + RevenueCat + GoRouter?

Any code snippets, diagrams, or repos would be incredibly helpful!

 

1 reply

jeffrey_bunn
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 252 replies
  • March 21, 2025

Hi ​@leroyice111! Typically, you’ll call logIn when you have a custom authentication id from Firebase Authentication. Often, we see developers set up the authStateChanges listener and automatically calling logIn when the uid changes. You’ll want to ensure you only call logIn when the auth listener returns a different uid from the previous value, which you should be able to configure in Riverpod.

If you’re looking to replicate RevenueCat data in your Firestore database, you may want to consider setting up our Firebase integration.

You may want to reach out to the GoRouter or Riverpod teams regarding your routing issues, but you’ll want to ensure you inspect the latest CustomerInfo object regarding subscription status before showing your paywall. Thanks!


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