Skip to content

Commit

Permalink
Add objc convenience inits for PaywallOverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuftor committed Apr 5, 2024
1 parent 62cacdd commit 5d6515a
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,63 @@ public final class PaywallOverrides: NSObject, Sendable {
self.presentationStyle = presentationStyleOverride
}

/// Override the default behavior and products of a paywall.
///
/// You can override one or more products of your choosing. For example, this is how you would override the first and third product on the paywall:
///
/// ```
/// PaywallOverrides(
/// products: [
/// "primary": firstProduct,
/// "tertiary": thirdProduct
/// ]
/// )
/// ```
///
/// This assumes that your products have the names "primary" and "tertiary" in the Paywall Editor.
///
/// Provide an instance of this to ``Superwall/getPaywall(forEvent:params:paywallOverrides:delegate:)``.
///
/// - parameters:
/// - productsByName: A dictionary mapping the name of the product to override on the paywall with a ``StoreProduct``.
public init(
productsByName: [String: StoreProduct]
) {
self.productsByName = productsByName
self.products = Self.mapToPaywallProducts(productsByName)
self.ignoreSubscriptionStatus = false
self.presentationStyle = .none
}

/// Override the default behavior and products of a paywall.
///
/// You can override one or more products of your choosing. For example, this is how you would override the first and third product on the paywall:
///
/// ```
/// PaywallOverrides(
/// products: [
/// "primary": firstProduct,
/// "tertiary": thirdProduct
/// ]
/// )
/// ```
///
/// This assumes that your products have the names "primary" and "tertiary" in the Paywall Editor.
///
/// Provide an instance of this to ``Superwall/getPaywall(forEvent:params:paywallOverrides:delegate:)``.
///
/// - parameters:
/// - productsByName: A dictionary mapping the name of the product to override on the paywall with a ``StoreProduct``.
public init(
productsByName: [String: StoreProduct],
ignoreSubscriptionStatus: Bool = false
) {
self.productsByName = productsByName
self.products = Self.mapToPaywallProducts(productsByName)
self.ignoreSubscriptionStatus = ignoreSubscriptionStatus
self.presentationStyle = .none
}

/// Override the default behavior and products of a paywall.
///
/// Provide an instance of this to ``Superwall/getPaywall(forEvent:params:paywallOverrides:delegate:)``.
Expand Down

0 comments on commit 5d6515a

Please sign in to comment.