Hi all, I could not find this in the docs. I have 2 different paywalls and 2 different offerings. How do I call up a specific paywall within the app vs the other using UKIT or Swift/IOS? Thanks!
Hey
When using UIKit, you can pass an `offering` to the PaywallViewController initializer after fetching your offerings like this:
func openPaywall() async throws {
let offerings = try await Purchases.shared.offerings()
let myCustomOffering = offerings.offering(identifier: "customerOfferingIdentifier")
let paywall = PaywallViewController(offering: myCustomOffering, displayCloseButton: true)
self.present(paywall, animated: true)
}
Thanks that works!
Hey
When using UIKit, you can pass an `offering` to the PaywallViewController initializer after fetching your offerings like this:
func openPaywall() async throws {
let offerings = try await Purchases.shared.offerings()
let myCustomOffering = offerings.offering(identifier: "customerOfferingIdentifier")
let paywall = PaywallViewController(offering: myCustomOffering, displayCloseButton: true)
self.present(paywall, animated: true)
}
What about SwiftUI?
Hey
We have code examples for SwiftUI which can be found here: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls#tag/Project/operation/list-projects
If you would like to display a specific offering in a paywall using SwiftUI, I recommend following code similar to the code below:
import SwiftUI
import RevenueCat
import RevenueCatUI
struct YourPaywall: View {
let offering: Offering
var body: some View {
ScrollView {
// Your custom paywall design content
}
.paywallFooter(offering: offering, condensed: true) { customerInfo in
// Purchase completed! Thank your user and dismiss your paywall
}
}
}
Hey
We have code examples for SwiftUI which can be found here: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls#tag/Project/operation/list-projects
If you would like to display a specific offering in a paywall using SwiftUI, I recommend following code similar to the code below:
import SwiftUI
import RevenueCat
import RevenueCatUI
struct YourPaywall: View {
let offering: Offering
var body: some View {
ScrollView {
// Your custom paywall design content
}
.paywallFooter(offering: offering, condensed: true) { customerInfo in
// Purchase completed! Thank your user and dismiss your paywall
}
}
}
I think I have a different problem. Currently I am using the code below. I want to have two Paywalls to sell the same products but varying the text, because the same Paywall can be displayed in different places in the app. Can you help me do this?
PaywallView()
.onPurchaseCompleted { CustomerInfo in
userViewModel.isSubscriptionActive = true
self.isPaywallPresented = false
}
Hey
If you want to display two separate paywalls, you’ll can either:
- Display PaywallView with different offerings with two separate `isPresented` modifiers, or
- Use Placements to set an offering for each location in your app: https://www.revenuecat.com/docs/tools/targeting/placements
Placements are likely the more flexible option, to prevent hardcoding specific offerings in your app. You’ll fetch offerings by placement, then display the paywall with that offering:
let placementOffering = offerings.getCurrentOffering(forPlacement: "onboarding_end")
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.