PurchaseRequirement
public class PurchaseRequirement : Hashable, Equatable, CustomStringConvertible
Use a PurchaseRequirement
to express the rules about what purchased products enable your Feature(s).
You can express complex rules about how your Features are enabled using a graph of requirements. Each Feature can have multiple purchase requirements (combined with AND), but one requirement can match one or all of a list of product IDs, as well as having dependencies on other requirements.
With this you can express the following kinds of rules:
- Feature X is available if Product A is purchased
- Feature X is available if Product A OR Product B OR Product C is purchased
- Feature X is available if Product A AND Product B AND Product C is purchased
- Feature X is available if Product A AND (Product B OR Product C) is purchased
- Feature X is available if (Product A OR Product B) AND ((Product B OR Product C) AND PRODUCT D) is purchased
- Feature X is available if (Product A OR Product B) AND ((Product B OR Product C) AND PRODUCT D AND PRODUCT E) is purchased
…and so on. This allows you to map Feature availability to a range of different product pricing strategies and relationships,
such as Basic
level of subscription plus a Founder
IAP that maybe offered to unlock all features in future for a one-off purchase,
provided they still have a basic subscription.
-
An enum type that determines how a products are matched.
See moreDeclaration
Swift
public enum Criteria : Hashable, Equatable
-
The set of products to match with this requirement
Declaration
Swift
public let products: Set<Product>
-
Optional list of requirements that must also be fulfilled for this requirement to be fulfilled. Using this you can express complex combinations of purchases and options
Declaration
Swift
public let dependencies: [PurchaseRequirement]?
-
The optional quantity of product for this requirement to be met. This is optional and only relates to ConsumableProduct types, and is purely informational because Flint does not handle allocation of consumable products/credits, but your app can access this information when you need to show a store UI to unlock the feature.
Declaration
Swift
public let quantity: UInt?
-
Initialise the requirement with its products, matching criteria and dependencies.
Declaration
Swift
public convenience init(products: Set<NonConsumableProduct>, matchingCriteria: Criteria, dependencies: [PurchaseRequirement]? = nil)
-
Undocumented
Declaration
Swift
public convenience init(_ product: NonConsumableProduct, dependencies: [PurchaseRequirement]? = nil)
-
Undocumented
Declaration
Swift
public convenience init(_ product: SubscriptionProduct, dependencies: [PurchaseRequirement]? = nil)
-
Undocumented
Declaration
Swift
public convenience init(_ product: ConsumableProduct, quantity: UInt, dependencies: [PurchaseRequirement]? = nil)
-
Call to see if this requirement and all dependent requirements are fulfilled
- param validator: The validator to use to see if each product in a requirement has been purchased
Declaration
Swift
public func isFulfilled(purchaseTracker: PurchaseTracker, feature: ConditionalFeatureDefinition.Type) -> Bool?
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
-
Declaration
Swift
public static func == (lhs: PurchaseRequirement, rhs: PurchaseRequirement) -> Bool