Skip to main content
Question

Introprice returns wrong free trial number in Android - React Native Purchases SDK 6


Forum|alt.badge.img+4
  • New Member
  • 1 reply

Hi,

 

I have been developing an app for iOS, and I can get the free trial as intro price in getOfferings response of the SDK. Now, I have upgraded to SDK 6 and trying to do the same on Android. The free trials are there in intro price, but they are returning wrong numbers. There are free trials as subscription options which have right number of days.

 

Is this a bug or expected?

 

Thank you in advance!

12 replies

MarcosC
RevenueCat Staff
Forum|alt.badge.img+7
  • RevenueCat Staff
  • 164 replies
  • June 21, 2023

@fred 

Can you share the values you are getting?


Forum|alt.badge.img+1

I’m getting the same problem in flutter, the intro price should be 3 months but it shows 1 year (that is the subscription lifetime). I don’t have the values since it is in production and I don’t know the way of testing it in a different environment or how to get the values in production app


MarcosC
RevenueCat Staff
Forum|alt.badge.img+7
  • RevenueCat Staff
  • 164 replies
  • June 23, 2023

@ricardo-6e38b7 

What version of flutter are you using?


Forum|alt.badge.img+1
MarcosC wrote:

@ricardo-6e38b7

What version of flutter are you using?

flutter --version
Flutter 3.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 796c8ef792 (12 days ago) • 2023-06-13 15:51:02 -0700
Engine • revision 45f6e00911
Tools • Dart 3.0.5 • DevTools 2.23.1
 


MarcosC
RevenueCat Staff
Forum|alt.badge.img+7
  • RevenueCat Staff
  • 164 replies
  • June 26, 2023

Sorry, I meant, what version of RevenueCat SDK are you using?


Forum|alt.badge.img+1
MarcosC wrote:

Sorry, I meant, what version of RevenueCat SDK are you using?

purchases_flutter: ^5.1.0

Forum|alt.badge.img+1

This is my current code:

 


        final String result = _remoteConfig.getString('revenuecat_offering_id');

        final Offerings offerings = await Purchases.getOfferings();
        final Offering? foundOffering = offerings.getOffering(result);
        final Offering? offering = foundOffering ?? offerings.current;
        final purchaseUser = await Purchases.getCustomerInfo();
        final bool canUserHaveFreeTrial;
        if (Platform.isIOS) {
          final mapEligibility =
              await Purchases.checkTrialOrIntroductoryPriceEligibility(
                  purchaseUser.entitlements.all.keys.toList());
          canUserHaveFreeTrial = mapEligibility.values.any((element) =>
              element.status ==
              IntroEligibilityStatus.introEligibilityStatusEligible);
        } else {
          // user has had access to an entitlement which means
          // they're not eligible for the offer
          // or
          // user has never had access to any entitlements
          // show intro offer
          canUserHaveFreeTrial = purchaseUser.entitlements.all.isEmpty;
        }
        if (offering != null) {
          final List<Package> packages = offering.availablePackages;
          final sortedPrices = _sortPrices(packages);
          final int selectedIndex = _findIndexWithBiggestDiscount(sortedPrices);
          emit(PaywallLoadSuccess(
            packages: sortedPrices,
            selectedIndex: selectedIndex,
            canUserHaveIntroPrice: canUserHaveFreeTrial,
          ));
        }

Here is my widget:

 


                      Visibility(
                        visible: state.canUserHaveIntroPrice,
                        replacement: ElevatedButton(
                          style: ElevatedButton.styleFrom(
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(18.0),
                            ),
                            minimumSize: const Size(double.infinity, 45),
                          ),
                          child: Text(
                            S.of(context).supermarketBtnContinue,
                            style: const TextStyle(
                              fontSize: 20,
                            ),
                          ),
                          onPressed: () {
                            _bloc.add(PaywallPaymentRequest(
                              product: selectedProduct,
                            ));
                          },
                        ),
                        child: ElevatedButton(
                          style: ElevatedButton.styleFrom(
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(18.0),
                            ),
                            minimumSize: const Size(double.infinity, 45),
                          ),
                          child: Text(
                            _paymentButtonText(
                                selectedProduct.introductoryPrice),
                            textAlign: TextAlign.center,
                            style: const TextStyle(
                              fontSize: 20,
                            ),
                          ),
                          onPressed: () {
                            _bloc.add(PaywallPaymentRequest(
                              product: selectedProduct,
                            ));
                          },
                        ),
                      ),

This is the method that the widget uses:

 

  String _paymentButtonText(final IntroductoryPrice? introductoryPrice) {
    if (introductoryPrice != null) {
      final translatedPeriod = _translatePeriodUnit(
          introductoryPrice.periodUnit, introductoryPrice.cycles);
      final periodString = '${introductoryPrice.cycles} '
              '$translatedPeriod'
          .toLowerCase();
      return S.of(context).paywallTxtFreeTrial(periodString);
    }
    return S.of(context).supermarketBtnContinue;
  }

 


MarcosC
RevenueCat Staff
Forum|alt.badge.img+7
  • RevenueCat Staff
  • 164 replies
  • June 27, 2023

@ricardo-6e38b7 I saw you posted the issue here → https://github.com/RevenueCat/purchases-flutter/issues/743, I’ll ask somebody from the team to see if they can reproduce the issue. 


Forum|alt.badge.img+1
MarcosC wrote:

@ricardo-6e38b7 I saw you posted the issue here → https://github.com/RevenueCat/purchases-flutter/issues/743, I’ll ask somebody from the team to see if they can reproduce the issue. 

Yes, I hope I posted enough information, please let me know if you need more :)


MarcosC
RevenueCat Staff
Forum|alt.badge.img+7
  • RevenueCat Staff
  • 164 replies
  • June 27, 2023

@ricardo-6e38b7 Release with a fix coming soon 

This seems to be the issue - https://github.com/RevenueCat/purchases-hybrid-common/pull/446


Forum|alt.badge.img+1
MarcosC wrote:

@ricardo-6e38b7 Release with a fix coming soon 

This seems to be the issue - https://github.com/RevenueCat/purchases-hybrid-common/pull/446

Hey, I just updated my revenuecat dependency, and I’m going to release a new version of my app and let you know if everything goes fine :). Thank you for your quickly deploy.


Forum|alt.badge.img+4
  • Author
  • New Member
  • 1 reply
  • June 30, 2023

Sorry, I’m late. It seems that you have identified the issue. As a workaround, we added a different logic for Android using subscribe by subscription option and finding if there’s any free phase, but it seems that you have fixed this in the latest version. We’ll try this in the next version to make our iOS and Android code consistent and let you know how it goes. 

 

Thank 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