I have two subscriptions and two RevenueCat paywalls are attached for each subscription. Now i want to show the paywall for each product in my .sheet () modifier passing the entitlement and offerings in SwiftUI.
can i do achieve through this
.presentPaywallIfNeeded(requiredEntitlementIdentifier: "", offering: Offering(identifier: "", serverDescription: "", availablePackages: []))
SwiftUI, show paywall based on offering and entitlement ids?
+2
You wouldn’t initialize the offering directly, but rather obtain it from the SDK, and then pass it in to the presentPaywallIfNeeded method.
Something like
// do this somewhere in your app. It could be a .task on the view, or it could be
// another class that is dedicated to interacting with the RevenueCat SDK.
do {
let offerings = try await Purchases.shared.offerings()
guard let offering1 = offerings["offering1"] else {
// handle error for missing offering, probably a configuration error in the dashboard
}
self.offering1 = offering1
} catch {
// handle errors when getting offerings
// this could be a connection error, misconfiguration, etc
}
// then in your view:
struct MyView: View {
var body: some View {
StuffThatGoesBehindPaywall()
.presentPaywallIfNeeded(requiredEntitlementIdentifier: "entitlement1", offering: self.offering1)
}
}
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.