Display Products

After you are done configuring products and groups, it's time to show the products to your customers. You can control which products are shown to users without requiring an app update. Make sure to take full advantage of the package system of PurchaseStacks and have as less static code as possible for displaying your products.

Products

Fetching Groups And Packages

As soon as your configure the SDK, we will fetch the associated groups and products of the App from PurchaseStacks dashboard. The groups you have configured in the dashboard, can be accessed by their names and you can then access the packages inside the group by their names as well.

Displaying Products

Every package has an active product that you can display to your customer. Also there's another attribute, purchased product if the package is active. With this you can show another package with higher value to the user if the user has already purchased one package.

PSPurchase.shared.group { (groupsByName, error) in
if let groupsByName = groupsByName {
if let group = groupsByName["PREMIUM"] {
if let monthlyPackage = group.packageByName["Monthly"] {
showPaywall(monthlyPackage.activeProduct())
}
}
}
}

Displaying Consumable Products

We fetch all the consumable products information for you, before you even need to show the products.

PSPurchase.shared.getAllConsumableProducts { (products, error) in
if let products = products {
// These are only consumable products
}
}