Question

Two separate paywall footers for separate entitlements/offerings

  • 2 April 2024
  • 2 replies
  • 43 views

Badge +1

I am thinking about configuring two separate entitlements in my app. One for “Premium” (access to GPT-3.5 among other features) users and another tier for “Plus” users who will have access to GPT-4 on top of premium features. Premium users should be the only users that can upgrade to Plus. GPT-4 API costs are expensive which is the reason to separate things out.

I’m struggling a bit to implement the syntax in SwiftUI. I have two separate entitlements so naturally I would like to implement two separate paywall footers on two paywall screens, but the only way to configure them separately is to give them an “Offering”. I’m not sure how to initialize this offering without introducing an optional into the equation.

.paywallFooter(offering: *initializedOffering*, condensed: true)

Writing things this way seems like hardcoding which would not allow me to change things remotely after each paywall has an offering fed to it. I would appreciate some insight into how I should proceed here.

My code in production with one paywall looks like this. It displays the one offering i’ve selected in RevenueCat which works fine for one paywall.

.paywallFooter(condensed: true)


This post has been closed for comments

2 replies

Badge +1
class IsEntitled: ObservableObject {
static var shared = IsEntitled()

@Published var offerings: [String: Offering] = [:]

init() {
refreshEntitlements()
}

func refreshEntitlements() {
Purchases.shared.getOfferings { offerings, error in
if let nonOptionalOfferings = offerings {
self.offerings = nonOptionalOfferings.all

[...]

}

struct Paywall: View {
@ObservedObject var entitlementManager: IsEntitled = IsEntitled.shared

var body: some View {
paywallContent()
.paywallFooter(entitlementManager.offerings["Default"] << returns an optional
}
}

This is what my code looks like so far

Userlevel 3
Badge +8

Hi,

Our Offering metadata feature may help here. You can send JSON data alongside an offering, which could allow you to toggle offerings in the dashboard and have them show up without code changes.

 

So for example, in the dashboard you could have the following Offerings: “standard”, “upsell”, and “upsell (aggressive)”

 

Then in your app, you could have something like (pseudocode)

if customerInfo.entitlements.premium.isEmpty {
// show default paywall
}

if customerInfo.entitlements.premium?.isActive == true {
// show the paywall with { defaultUpsellOffer: true } metadata
}

If you want to toggle between the “upsell” and “upsell (aggressive)” Offerings w/o a code change, just flip one’s metadata to true and the other to false for that parameter.