class Purchases
Purchases
is the main entry point of the RevenueCat
SDK. It provides access to all its features.Framework
RevenueCat is a powerful, reliable, and free to use in-app purchase server with cross-platform support. Our open-source framework provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy.
Whether you are building a new app or already have millions of customers, you can use RevenueCat to:
Fetch products, make purchases, and check subscription status with our native SDKs.
Host and configure products remotely from our dashboard.
Analyze the most important metrics for your app business in one place.
See customer transaction histories, chart lifetime value, and grant promotional subscriptions.
Get notified of real-time events through webhooks.
Send enriched purchase events to analytics and attribution tools with our easy integrations.
Sign up to get started for free.
RevenueCat | |
---|---|
✅ | Server-side receipt validation |
➡️ | Webhooks - enhanced server-to-server communication with events for purchases, renewals, cancellations, and more |
🖥 | iOS, tvOS, macOS and watchOS support |
🎯 | Subscription status tracking - know whether a user is subscribed whether they’re on iOS, Android or web |
📊 | Analytics - automatic calculation of metrics like conversion, mrr, and churn |
📝 | Online documentation up to date |
🔀 | Integrations - over a dozen integrations to easily send purchase data where you need it |
💯 | Well maintained - frequent releases |
📮 | Great support - Help Center |
When transitioning between our V3 SDK, we ported our entire SDK into Swift. Migrating from Objective-C to Swift required a number of API changes, but we feel that the changes resulted in the SDK having a more natural feel for developers. In addition, we introduced several new types and APIs.
Our RevenueCat V4 API Migration Guide provides information on how to migrate from V3 to V4.
For more detailed information, you can view our complete documentation at docs.revenuecat.com.
Or browse our iOS sample apps:
class Purchases
Purchases
is the main entry point of the RevenueCat
SDK. It provides access to all its features.static func configure(withAPIKey : String) -> Purchases
static func configure(withAPIKey : String, appUserID : String?) -> Purchases
static func configure(withAPIKey : String, appUserID : String?, observerMode : Bool) -> Purchases
UserDefaults
.static func configure(withAPIKey : String, appUserID : String?, observerMode : Bool, userDefaults : UserDefaults ?) -> Purchases
UserDefaults
.class Offerings
class Offering
Package
s, and they let you control which products are shown to users without requiring an app update.class Package
identifier
, packageType
, and underlying StoreProduct
.class StoreProduct
StoreKit
‘s product type’s properties.class SubscriptionPeriod
.month
, and the value is 3
, the subscription period is three months.func offerings() async throws -> Offerings
Offerings
for this user.func getOfferings (completion: (Offerings?, Error?) -> Void)
Offerings
for this user.func products([String]) async -> [StoreProduct ]
StoreProduct
s for your IAPs for given productIdentifiers
.func getProducts ([String], completion: ([StoreProduct ]) -> Void)
StoreProduct
s for your IAPs for given productIdentifiers
.class StoreTransaction
func purchase(package: Package) async throws -> PurchaseResultData
Package
.func purchase(package: Package, completion: PurchaseCompletedBlock )
Package
.func purchase(product: StoreProduct ) async throws -> PurchaseResultData
StoreProduct
.func purchase(product: StoreProduct , completion: PurchaseCompletedBlock )
StoreProduct
.class IntroEligibility
class PromotionalOffer
StoreProductDiscount
that has been validated and is ready to be used for a purchase.class StoreProductDiscount
StoreKit.Product.SubscriptionOffer
and SKProductDiscount
and provides access to their properties. Information about a subscription offer that you configured in App Store Connect.func checkTrialOrIntroDiscountEligibility (productIdentifiers : [String]) async -> [String : IntroEligibility ]
func checkTrialOrIntroDiscountEligibility (productIdentifiers : [String], completion: ([String : IntroEligibility ]) -> Void)
func checkTrialOrIntroDiscountEligibility (product: StoreProduct ) async -> IntroEligibilityStatus
func checkTrialOrIntroDiscountEligibility (product: StoreProduct , completion: (IntroEligibilityStatus ) -> Void)
func getPromotionalOffer (forProductDiscount : StoreProductDiscount , product: StoreProduct ) async throws -> PromotionalOffer
func getPromotionalOffer (forProductDiscount : StoreProductDiscount , product: StoreProduct , completion: (PromotionalOffer ?, Error?) -> Void)
PromotionalOffer
to use in purchase(package:promotionalOffer:)
or purchase(product:promotionalOffer:)
. iOS Promotional Offers.func purchase(package: Package, promotionalOffer : PromotionalOffer ) async throws -> PurchaseResultData
Package
. Call this method when a user has decided to purchase a product with an applied discount. Only call this in direct response to user input. From here Purchases
will handle the purchase with StoreKit
and call the PurchaseCompletedBlock
.func purchase(package: Package, promotionalOffer : PromotionalOffer , completion: PurchaseCompletedBlock )
Package
. Call this method when a user has decided to purchase a product with an applied discount. Only call this in direct response to user input. From here Purchases
will handle the purchase with StoreKit
and call the PurchaseCompletedBlock
.func purchase(product: StoreProduct , promotionalOffer : PromotionalOffer ) async throws -> PurchaseResultData
StoreProduct
with an applied PromotionalOffer
. If you are using the Offerings system, use purchase(package:promotionalOffer:completion:)
instead.func purchase(product: StoreProduct , promotionalOffer : PromotionalOffer , completion: PurchaseCompletedBlock )
StoreProduct
with a PromotionalOffer
.class CustomerInfo
Purchases
. These objects are non-mutable and do not update automatically.class EntitlementInfo
class EntitlementInfos
protocol PurchasesDelegate
Purchases
responsible for handling updating your app’s state in response to updated customer info or promotional product purchases.func getCustomerInfo (completion: (CustomerInfo ?, Error?) -> Void)
func customerInfo () async throws -> CustomerInfo
CustomerInfo
is cached.var customerInfoStream : AsyncStream <CustomerInfo >
AsyncStream
of CustomerInfo
changes, starting from the last known value.func logIn (String) async throws -> (customerInfo : CustomerInfo , created: Bool)
appUserID
.func logIn (String, completion: (CustomerInfo ?, Bool, Error?) -> Void)
appUserID
.func syncPurchases () async throws -> CustomerInfo
appUserID
.func syncPurchases (completion: ((CustomerInfo ?, Error?) -> Void)?)
appUserID
.func restorePurchases () async throws -> CustomerInfo
appUserID
. If the receipt is being used by an existing user, the current appUserID
will be aliased together with the appUserID
of the existing user. Going forward, either appUserID
will be able to reference the same user.func restorePurchases (completion: ((CustomerInfo ?, Error?) -> Void)?)
appUserID
. If the receipt is being used by an existing user, the current appUserID
will be aliased together with the appUserID
of the existing user. Going forward, either appUserID
will be able to reference the same user.func showManageSubscriptions () async throws
func showManageSubscriptions (completion: (Error?) -> Void)
func setAttributes ([String : String])
func setAd (String?)
func setEmail (String?)
func setDisplayName (String?)
func setKeyword (String?)
func setCampaign (String?)
func setCreative (String?)
func setAdGroup (String?)
func setPushToken (Data?)
func setMediaSource (String?)
func setPhoneNumber (String?)
func setAttributes ([String : String])
func collectDeviceIdentifiers ()
func setAdjustID (String?)
func setAppsflyerID (String?)
func setAirshipChannelID (String?)
func setMparticleID (String?)
func setOnesignalID (String?)
func setFBAnonymousID (String?)
class DangerousSettings
protocol RawDataContainer
typealias DeferredPromotionalPurchaseBlock
shouldPurchasePromoProduct(_:defermentBlock:)
typealias LogHandler
typealias PurchaseCompletedBlock
purchase(product:completion:)
typealias SK1Product
StoreKit/SKProduct
typealias SK1ProductDiscount
SKProductDiscount
typealias SK1Transaction
StoreKit.SKPaymentTransaction
typealias SK2Product
StoreKit.Product
typealias SK2ProductDiscount
StoreKit.Product.SubscriptionOffer
typealias SK2Transaction
StoreKit.Transaction
typealias VerboseLogHandler
enum AttributionNetwork
enum ErrorCode
enum IntroEligibilityStatus
enum LogLevel
enum PackageType
Package
types, as configured on the package.enum PeriodType
enum PurchaseOwnershipType
enum RefundRequestStatus
enum Store