PurchaseTracker
public protocol PurchaseTracker
Implement this protocol to verify whether a specific purchase has been paid for.
You may implement this against whatever receipt system you use, but typically this is StoreKit.
Flint will call this multiple times for each productID that is required in a PurchaseRequirement
,
so implementations only need to respond to single product requests.
-
Call to add an observer for changes to purchases
Declaration
Swift
func addObserver(_ observer: PurchaseTrackerObserver)
-
Call to remove an observer for changes to purchases
Declaration
Swift
func removeObserver(_ observer: PurchaseTrackerObserver)
-
Return whether or not the specified product ID has been paid for (and hence features requiring it can be enabled) by the user.
Note
If the status is not yet known, the implementation can returnnil
to indicate this indeterminate status.Declaration
Swift
func isPurchased(_ product: NonConsumableProduct) -> Bool?
-
Return whether or not there is an active subscription for this product, whether it is auto-renewing or not.
Note
If the status is not yet known, the implementation can returnnil
to indicate this indeterminate status.Declaration
Swift
func isSubscriptionActive(_ product: SubscriptionProduct) -> Bool?
-
Return whether or not past purchases, perhaps consumable credits, mean that this feature is currently enabled.
This is your application’s opportunity to implement custom purchase management such as allowing purchase of specific features with a given number of consumable in-app credits, or a custom cross-device purchase syncing mechanism, or
grandfathering
users in to new features because they bought the app outright in the past.Note
If the status is false, the result of prior calls toisPurchased
andisSubscriptionActive
will take precendent if appropriate. If this function returnstrue
, the feature will always be enabled if all its other constraints are met.Declaration
Swift
func isFeatureEnabledByPastPurchases(_ feature: FeatureDefinition.Type) -> Bool