Hi everyone! I’m trying to integrate RevenueCat into my Flutter app, which already uses Riverpod for state management, Firebase 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:
-
Authentication: Firebase Auth (users marked as "completed onboarding" in Firestore).
-
Routing: GoRouter with
redirect
logic to handle onboarding/auth flows. -
RevenueCat: Configured, but struggling to link Firebase users and prevent paywall errors.
Key Issues:
-
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.
-
-
Linking Firebase ↔ RevenueCat:
-
How do I ensure the Firebase user ID is synced with RevenueCat’s user ID after login?
-
-
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)
andref.watch(subscriptionProvider)
, but async states don’t always resolve in time.
Questions:
-
How do you synchronize Firebase users with RevenueCat reliably?
-
How to structure GoRouter redirects to wait for async checks (onboarding, subscription)?
-
Are there working examples of Flutter apps using Riverpod + RevenueCat + GoRouter?
Any code snippets, diagrams, or repos would be incredibly helpful!