Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Specifies behavior for a caching API.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class PurchaseParams(val builder: PurchaseParams.Builder)
Link copied to clipboard

Entry point for Purchases. It should be instantiated 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.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Get latest available customer info. Coroutine friendly version of Purchases.getCustomerInfo.

Link copied to clipboard
fun Purchases.getCustomerInfoWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo) -> Unit)

Get latest available customer info.

fun Purchases.getCustomerInfoWith(fetchPolicy: CacheFetchPolicy, onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo) -> Unit)

Get customer info from cache or network depending on fetch policy.

Link copied to clipboard
fun Purchases.getOfferingsWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (offerings: Offerings) -> Unit)

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.

Link copied to clipboard
fun Purchases.getProductsWith(productIds: List<String>, onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onGetStoreProducts: (storeProducts: List<StoreProduct>) -> Unit)

Gets the StoreProduct(s) for the given list of product ids for all product types.

fun Purchases.getProductsWith(productIds: List<String>, type: ProductType?, onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onGetStoreProducts: (storeProducts: List<StoreProduct>) -> Unit)

Gets the StoreProduct(s) for the given list of product ids of type type

Link copied to clipboard
fun Purchases.logInWith(appUserID: String, onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo, created: Boolean) -> Unit)

This function will change the current appUserID. Typically this would be used after a log out to identify a new user without calling configure

Link copied to clipboard
fun Purchases.logOutWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo) -> Unit)

Logs out the Purchases client clearing the save appUserID. This will generate a random user id and save it in the cache.

Link copied to clipboard
fun Purchases.purchaseWith(purchaseParams: PurchaseParams, onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB, onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit)
Link copied to clipboard
fun Purchases.restorePurchasesWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (customerInfo: CustomerInfo) -> Unit)

Restores purchases made with the current Play Store account for the current user. This method will post all purchases associated with the current Play 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.

Link copied to clipboard
fun Purchases.syncPurchasesWith(onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, onSuccess: (CustomerInfo) -> Unit)

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 purchases. Otherwise, the onError callback will be called with a PurchasesError indicating the first error found.