Purchases
Entry point for Purchases. This class can be instantiated using Purchases.configure. This should be done as soon as your app has a unique user id for your user. This can be when a user logs in if you have accounts or on launch if you can generate a random user identifier. Make sure you follow the quickstart guide to setup your RevenueCat account. Only one instance of Purchases should be instantiated at a time! Access the singleton instance with Purchases.sharedInstance.
Types
Properties
The delegate is responsible for handling promotional product purchases (App Store only) and changes to customer information.
Functions
Get the latest available customer info.
Gets the StoreProducts for the given list of product ids for all product types.
This function will change the current Purchases.appUserID. Typically this would be used after a log out to identify a new user without calling Purchases.configure.
Resets the Purchases client clearing the save Purchases.appUserID. This will generate a random user id and save it in the cache.
Fetch the configured offerings for this users. Offerings allows you to configure your in-app products vis RevenueCat and greatly simplifies management. See the guide for more info.
App Store only. Use this method to fetch a PromotionalOffer to use with awaitPurchase.
App Store only. Purchases packageToPurchase. 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.
App Store only. Use this function if you are not using the Offerings system to purchase a StoreProduct with an applied PromotionalOffer. If you are using the Offerings system, use the overload with a Package parameter instead.
Purchases packageToPurchase. On the Play Store, if packageToPurchase represents a subscription, upgrades from the subscription specified by oldProductId and chooses the default SubscriptionOption from packageToPurchase.
Purchases storeProduct. On the Play Store, if storeProduct represents a subscription, upgrades from the subscription specified by oldProductId and chooses storeProduct's default SubscriptionOption.
Play Store only. Purchases subscriptionOption.
Restores purchases made with the current Store account for the current user. This method will post all purchases associated with the current Store account to RevenueCat and become associated with the current appUserID. If the receipt token 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.
Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation for subscriptions anytime a sync is needed, such as when migrating existing users to RevenueCat.
Automatically collect subscriber attributes associated with the device identifiers $gpsAdId
, $androidId
, $ip
Get the latest available customer info.
Fetch the configured offerings for this users. Offerings allows you to configure your in-app products vis RevenueCat and greatly simplifies management. See the guide for more info.
App Store only. Use this method to fetch a PromotionalOffer to use with purchase.
Invalidates the cache for customer information.
This function will change the current appUserID. Typically this would be used after a log out to identify a new user without calling configure()
.
App Store only. Use this function if you are not using the Offerings system to purchase a StoreProduct with an applied PromotionalOffer. If you are using the Offerings system, use the overload with a Package parameter instead.
App Store only. Purchases packageToPurchase. 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 either onSuccess or onError.
Purchases storeProduct. On the Play Store, if storeProduct represents a subscription, upgrades from the subscription specified by oldProductId and chooses storeProduct's default SubscriptionOption.
Play Store only. Purchases subscriptionOption.
Purchases packageToPurchase. On the Play Store, if packageToPurchase represents a subscription, upgrades from the subscription specified by oldProductId and chooses the default SubscriptionOption from packageToPurchase.
iOS only. Always returns an error on iOS < 15.
Restores purchases made with the current Store account for the current user. This method will post all purchases associated with the current Store account to RevenueCat and become associated with the current appUserID. If the receipt token 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.
Subscriber attribute associated with the install ad group for the user
Subscriber attribute associated with the Adjust Id for the user Required for the RevenueCat Adjust integration
Subscriber attribute associated with the Airship Channel ID Required for the RevenueCat Airship integration
Subscriber attribute associated with the AppsFlyer Id for the user Required for the RevenueCat AppsFlyer integration
Subscriber attributes are useful for storing additional, structured information on a user. Since attributes are writable using a public key they should not be used for managing secure or sensitive information such as subscription status, coins, etc.
Subscriber attribute associated with the install campaign for the user
Subscriber attribute associated with the CleverTap ID for the user Required for the RevenueCat CleverTap integration
Subscriber attribute associated with the install ad creative for the user
Subscriber attribute associated with the display name for the user
Subscriber attribute associated with the Facebook SDK Anonymous Id for the user Recommended for the RevenueCat Facebook integration
Subscriber attribute associated with the Firebase App Instance ID for the user Required for the RevenueCat Firebase integration
Subscriber attribute associated with the install keyword for the user
Subscriber attribute associated with the install media source for the user
Subscriber attribute associated with the Mixpanel Distinct ID for the user
Subscriber attribute associated with the mParticle Id for the user Recommended for the RevenueCat mParticle integration
Subscriber attribute associated with the OneSignal Player Id for the user Required for the RevenueCat OneSignal integration. Deprecated for OneSignal versions above v9.0.
Subscriber attribute associated with the OneSignal User ID for the user Required for the RevenueCat OneSignal integration with versions v11.0 and above.
Subscriber attribute associated with the phone number for the user
Subscriber attribute associated with the push token for the user
Google Play and App Store only, no-op for Amazon. Displays the specified in-app message types to the user as a snackbar if there are any available to be shown. If PurchasesConfiguration.showInAppMessagesAutomatically is enabled, this will be done automatically.
This method will send an Amazon purchase to the RevenueCat backend. This function should only be called if you have set PurchasesAreCompletedBy to PurchasesAreCompletedBy.MyApp or when performing a client side migration of your current users to RevenueCat.
Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation for subscriptions anytime a sync is needed, such as when migrating existing users to RevenueCat. The onSuccess callback will be called if all purchases have been synced successfully or there are no Otherwise, the onError callback will be called with a PurchasesError indicating the first error found.