Skip to main content

Hello,

I have previously implemented RevenueCat subscriptions using

Purchases.shared.getOfferings { offerings, error in

   if let offer = offerings?.current, error == nil { currentOffering = offer }

}

I am now trying to show a different set of upgraded offerings if the specific user already has our base level subscription. I  have reviewed the documentation for displaying packages, but there no examples on how to go from fetching a package and getting to a product for purchase.

 

I have tried to integrate the following code: 

Purchases.shared.getOfferings { (offerings, error) in

if let packages = offerings?.offering(identifier: "not the current offerings")?.package(identifier: "Monthly") {

// Display packages for sale}

}

But I don’t know how to display packages, or select them for purchasing. I’ve tried to create a selectedPackage State variable write to it in the function, but that didn't work for me either.

 

When I use the offerings.current code I can get my products to show up, but if try to fetch from the current offering using the packages code I can’t get the products to fetch. It seems like there should be a more comprehensive example where packages are shown instead of just using current offerings.

Hey There! 

 

You can access packages in a few different ways:

  1. via the .availablePackages property on an Offering.
  2. via the duration convenience property on an Offering
  3. via the package identifier directly

 

Each package will then carry a product under it that you can display accordingly, more information on that can be found here: https://www.revenuecat.com/docs/displaying-products#getting-the-product-from-the-package

 

This seems like a situation where you might want to display a different offering to the user based on their current entitlements, if so I recommend following this link: https://www.revenuecat.com/docs/displaying-products#choosing-which-offering-to-display

 


Reply