Skip to main content
Question

Issues Integrating RevenueCat Paywall v2 with Flutter, Firebase, and Riverpod

  • April 25, 2025
  • 1 reply
  • 15 views

Forum|alt.badge.img

Hello everyone,

I hope you're all doing well. I'm currently working on a Flutter application that integrates Firebase for authentication and utilizes Riverpod and GoRouter for state management and navigation. While I've successfully implemented RevenueCat in previous projects, I'm encountering challenges with this particular setup.

Current Setup:

  • Flutter

  • Firebase Authentication

  • Riverpod

  • GoRouter

  • RevenueCat with Firebase integration

Issues Faced:

  1. Paywall v2 Not Detected: In my previous applications, Paywall v1 functioned without issues. However, after transitioning to Paywall v2, the paywall isn't being detected or displayed as expected. I've reviewed the documentation but haven't found a solution.​

  2. User Management and Exception Handling: I'm uncertain about the best practices for managing users and handling exceptions post-purchase. Specifically, I'm looking for guidance on:

    • Ensuring that once a user completes a purchase, their entitlements are correctly recognized and maintained.

    • Handling scenarios where a user logs out and logs back in, ensuring their purchase history and entitlements persist.

    • Managing errors and exceptions that might arise during the purchase process to provide a seamless user experience.​

I've integrated the RevenueCat Firebase plugin, and the initial setup appears correct. However, these issues are hindering the app's functionality, and I aim to make the application production-ready.

Any insights, suggestions, or guidance would be immensely appreciated. Thank you in advance for your support!

This is some of my code:

    try {
      print('💰 Paywall: Verificando estado premium');
      
      // Verificar con RevenueCat
      final customerInfo = await Purchases.getCustomerInfo();
      final hasActiveEntitlement = customerInfo.entitlements.active.isNotEmpty;
      
      print('📊 Paywall: Estado de suscripción:');
      print('   - Entitlements activos: ${customerInfo.entitlements.active.keys.join(", ")}');
      print('   - Es premium: $hasActiveEntitlement');

      if (hasActiveEntitlement) {
        // Actualizar Firestore
        await FirebaseFirestore.instance.collection('users').doc(user.uid).update({
          'onboardingCompleted': true,
          'premiumStatus': true,
          'lastPremiumCheck': FieldValue.serverTimestamp(),
        });
        
        if (mounted) {
          print('✅ Paywall: Usuario premium verificado, redirigiendo a basescreen');
          context.go('/basescreen');
        }
      } else {
        print('⚠️ Paywall: Usuario aún no es premium, mostrando paywall');
        await RevenueCatUI.presentPaywallIfNeeded(
          "BlissPaywall2",
          offering: null,
          displayCloseButton: true,
        );
      }
    } catch (e) {
      print('❌ Paywall: Error: $e');
      if (mounted) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text('Error al procesar el estado premium: $e')),
        );
      }
    } finally {
      if (mounted) {
        setState(() {
          _isLocalLoading = false;
        });
      }
    }
  }

 

 

This post has been closed for comments

1 reply

joan-cardona
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 404 replies
  • April 29, 2025

Hi ​@leroyice111,

There can be some things happening here that you could check. The first thing is that you should check that your Flutter SDK version is compatible with paywalls v2, you can upgrade to the latest version to make sure everything you use in your paywall is available in the SDK.

Another thing I’d check is that your paywall is saved and published, if you don’t publish your paywall then the SDK can’t find it. Also make sure you have an offering associated to that paywall and that’s set as default offering or that you are manually fetching for that offering id.

 

Let me know if any of this works!


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