Skip to main content
Question

iOS SwiftUI Paywall v2 how select offering and paywall type


Forum|alt.badge.img+1

Got a default paywall that is working well with a state for showing a sheet and a sheet modifier

.sheet(isPresented: self.$displayPaywall) {
            PaywallView(displayCloseButton: true)
        }

 

But I would like to have another paywall in select places. I’m unable to find documentation on this. The params available include “offering” for PaywallView and I’ve tried setting it with a string matching my other paywall offering id and also tried declaring it prior to the view.

Does not work at all and makes the project not build.

Is there any documentation available on this for paywall v2? This page has nothing on how to use the offering parameter - https://www.revenuecat.com/docs/tools/paywalls-v2/displaying-paywalls

This post has been closed for comments

2 replies

Forum|alt.badge.img+1
  • Author
  • New Member
  • 1 reply
  • April 2, 2025

Answering my own question in case someone is interested as I have found zero documentation on this as noted in the original post. 

 

So PaywallView(offering: “StringIdentifier”) does not work. This is because the compiler expects an instance of Offering (Offering? - can be found if digging around a bit). Swift is type safe so it does not work with a string ID immediately matching the offering although that is the natural interpretation of that syntax. For me this just crashed xcode with a general compiler error (“not able to type check the expression in real time...”).

 

A solution - I’m sure there are plenty - is to load the offerings in the onappear modifier for the view and then call it - PaywallView(offering: selectedOffering).

 

Definitely approaching a point where doing it native without revenuecat is becoming interesting but the paywall edit is of course nice and handy :)

 

 


joan-cardona
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 364 replies
  • April 8, 2025

Hi ​@dstyp,

Thank you for your post and answer! You are saying that you’ll like to have different paywalls in selected places, have you thought about using Targeting by placement for that? You can define a place and then request the offering for that specific string. In that case, you’ll have already the offering for when presenting the paywall with something like:

let placementOffering = offerings.getCurrentOffering(forPlacement: "onboarding_end")

Offerings should also be cached automatically by the SDK so the call shouldn’t be very long and you can also access the cached data in case you want the offerings inmediatelly.

 

Let me know if this helps!


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