Displaying Products
Configure Products
Before working with products in SDK, make sure you created all in-app purchases in App Store Connect / Google Play Console, and made necessary set up in Aphud Product Hub. Please follow our Configuring Products guide for details.
Placements
Placements offer a strategic method to integrate paywalls throughout your app. This feature allows app developers to position paywalls effectively in different app sections, such as onboarding, settings, etc., with each placement targeting a distinct user audience. For more comprehensive information, please refer to our Placements guide.
To utilize a paywall, first retrieve the corresponding placement. Once you have a specific placement object, you can access its associated paywall and the products:
Apphud.fetchPlacements { placements, error in
// if placements are already loaded, callback will be invoked immediately
if let placement = placements.first(where: { $0.identifier == "your_placement_id" }), let paywall = placement.paywall {
let products = paywall.products
Apphud.paywallShown(paywall)
// setup your UI with these products
}
}Task {
let onboardingPlacement = await Apphud.placement(ApphudPlacementID.onboarding.rawValue)
if let paywall = onboardingPlacement?.paywall {
let apphudProducts = paywall.products
Apphud.paywallShown(paywall)
// setup your UI with these products
}
}val placements = Apphud.placements()ApphudSDK.FetchPlacements((List<ApphudPlacement> list, ApphudError error)=>{});
Access Paywalls CorrectlyIt's crucial to retrieve paywalls correctly based on your chosen feature. If your app uses the Placements feature, you must obtain the paywall object directly from the corresponding placement object. Avoid using the standalone paywalls array from the SDK in this context. Fetching a paywall through
Apphud.paywalls()in a placement-based setup will disrupt your analytics, as purchases won't be accurately attributed to the respective placement.
Paywalls
Paywall structure allows you to operate with your products array remotely as well as run A/B experiments on them. You can read more in our Paywalls guide.
Technically, each ApphudPaywall contains array of ApphudProduct objects, paywall identifier, JSON dictionary, and a few other properties.
Manage A/B experimented paywallsSee more details about paywalls logic regarding A/B experiments
If products are missing in the responseIn case of App Store or Google Play products are missing in the paywalls structures, check out App Store and Google Play products setup checklists.
Log Paywall Shown
Logging Paywall Shown event is highly recommended, as it influences the calculation of 'Affected Users' and major Paywall Conversion Rates metrics, which are key components in Paywall Analytics, Placement Analytics, and A/B Experiments.
Apphud.paywallShown(paywall)ApphudSDK.PaywallShown(paywall)
Do not duplicatePlease make sure that this method is called just one time per payment screen shown.
Additional Resources:
Updated 9 days ago
