### Setup Development Environment Source: https://github.com/revenuecat/purchases-android/blob/main/CONTRIBUTING.md Run this command after setting up mise to install project dependencies and configure the development environment. ```bash bundle exec fastlane setup_dev ``` -------------------------------- ### Setup Local Properties Source: https://github.com/revenuecat/purchases-android/blob/main/fastlane/README.md Fetches integration test secrets from 1Password and writes them to local.properties. Requires the 1Password CLI (op) to be installed and signed in. ```shell [bundle exec] fastlane android setup_local_properties ``` -------------------------------- ### Setup Android Development Environment Source: https://github.com/revenuecat/purchases-android/blob/main/fastlane/README.md Configures the development environment for Android projects. ```shell [bundle exec] fastlane android setup_dev ``` -------------------------------- ### Fastlane Setup Development Environment Source: https://github.com/revenuecat/purchases-android/blob/main/AGENTS.md Sets up the development environment using Fastlane, including linking pre-commit hooks. This is a crucial first step for new developers. ```bash # Setup development environment (links pre-commit hooks) bundle exec fastlane setup_dev ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/revenuecat/purchases-android/blob/main/fastlane/README.md Ensures the latest version of Xcode command line tools are installed. ```shell xcode-select --install ``` -------------------------------- ### Gradle Version Catalog Setup Source: https://github.com/revenuecat/purchases-android/blob/main/codegen/README.md Configures the plugin in the Gradle version catalog by defining the plugin version and its ID. This is the first step in integrating the codegen plugin into your project. ```toml [versions] purchases = "PURCHASES_VERSION" [plugins] revenuecat-codegen = { id = "com.revenuecat.purchases.codegen", version.ref = "purchases" } ``` -------------------------------- ### Load AdMob Interstitial Ad (Standard) Source: https://github.com/revenuecat/purchases-android/blob/main/feature/admob/README.md Standard AdMob interstitial ad loading. This example shows the loading process and how to set up the `FullScreenContentCallback` for showing the ad. ```kotlin InterstitialAd.load( this, "AD_UNIT_ID", AdRequest.Builder().build(), object : InterstitialAdLoadCallback() { override fun onAdLoaded(ad: InterstitialAd) { interstitialAd = ad } override fun onAdFailedToLoad(adError: LoadAdError) { interstitialAd = null } }, ) // Later, to show: interstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() { override fun onAdDismissedFullScreenContent() { interstitialAd = null } } interstitialAd?.show(this) ``` -------------------------------- ### Get Offerings with Async/Await Source: https://github.com/revenuecat/purchases-android/blob/main/examples/CustomEntitlementComputationSample/README.md Retrieve available offerings using the `awaitOfferings` method for asynchronous operations. Ensure the SDK is configured before calling. ```kotlin val offerings = Purchases.sharedInstance.awaitOfferings() ``` -------------------------------- ### Run Android Bump Release with Fastlane Source: https://github.com/revenuecat/purchases-android/blob/main/RELEASING.md Execute this command locally to initiate the release process using Fastlane. It will guide you through version confirmation, changelog updates, and automatically create a PR. Ensure your fastlane/.env file is configured with your GitHub API token. ```bash bundle exec fastlane android bump ``` -------------------------------- ### GoogleSubscriptionOption Constructors Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Constructors for creating a GoogleSubscriptionOption object. These allow for various combinations of parameters including offer details, pricing phases, tags, product details, offer tokens, and optional context or installment information. ```APIDOC ## GoogleSubscriptionOption Constructors ### Description Constructors for creating a GoogleSubscriptionOption object. These allow for various combinations of parameters including offer details, pricing phases, tags, product details, offer tokens, and optional context or installment information. ### Constructors - `GoogleSubscriptionOption(String productId, String basePlanId, String? offerId, List pricingPhases, List tags, ProductDetails productDetails, String offerToken)` - `GoogleSubscriptionOption(String productId, String basePlanId, String? offerId, List pricingPhases, List tags, ProductDetails productDetails, String offerToken, PresentedOfferingContext? presentedOfferingContext)` - `GoogleSubscriptionOption(String productId, String basePlanId, String? offerId, List pricingPhases, List tags, ProductDetails productDetails, String offerToken, PresentedOfferingContext? presentedOfferingContext, GoogleInstallmentsInfo? installmentsInfo)` - `GoogleSubscriptionOption(String productId, String basePlanId, String? offerId, List pricingPhases, List tags, ProductDetails productDetails, String offerToken, String presentedOfferingId)` (Deprecated) ``` -------------------------------- ### launchWithOptions Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface with a comprehensive set of options provided in a dedicated options object. ```APIDOC ## launchWithOptions ### Description Launches the paywall interface using a `PaywallActivityLaunchOptions` object for configuration. ### Method public void launchWithOptions(...) ### Parameters #### Path Parameters - **options** (com.revenuecat.purchases.ui.revenuecatui.activity.PaywallActivityLaunchOptions) - An object containing various options for launching the paywall. ``` -------------------------------- ### Set Tenjin Analytics Installation ID Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Sets the Tenjin Analytics Installation ID. ```APIDOC ## setTenjinAnalyticsInstallationID ### Description Sets the Tenjin Analytics Installation ID. ### Method public void setTenjinAnalyticsInstallationID(String? tenjinAnalyticsInstallationID) ### Parameters #### Request Body - **tenjinAnalyticsInstallationID** (String?) - The Tenjin Analytics Installation ID. ``` -------------------------------- ### InstallmentsInfo Interface Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Provides information about installment payments for a subscription. ```APIDOC ## InstallmentsInfo ### Description Interface for retrieving information about installment payments for a subscription. ### Methods - `getCommitmentPaymentsCount()`: Returns the total number of commitment payments. - `getRenewalCommitmentPaymentsCount()`: Returns the number of commitment payments for renewals. ### Properties - `commitmentPaymentsCount` (int): The total number of commitment payments. - `renewalCommitmentPaymentsCount` (int): The number of commitment payments for renewals. ``` -------------------------------- ### GoogleStoreProduct Constructors Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt The GoogleStoreProduct class has multiple constructors to initialize a product with various details, including product ID, base plan ID, type, price, name, description, period, subscription options, default option, product details, and optionally presented offering identifier and context. ```APIDOC ## GoogleStoreProduct Constructors ### Description Constructors for initializing `GoogleStoreProduct` objects. ### Constructors - `GoogleStoreProduct(String productId, String? basePlanId, com.revenuecat.purchases.ProductType type, com.revenuecat.purchases.models.Price price, String title, String description, com.revenuecat.purchases.models.Period? period, com.revenuecat.purchases.models.SubscriptionOptions? subscriptionOptions, com.revenuecat.purchases.models.SubscriptionOption? defaultOption, com.android.billingclient.api.ProductDetails productDetails, optional String? presentedOfferingIdentifier)` - `GoogleStoreProduct(String productId, String? basePlanId, com.revenuecat.purchases.ProductType type, com.revenuecat.purchases.models.Price price, String name, String title, String description, com.revenuecat.purchases.models.Period? period, com.revenuecat.purchases.models.SubscriptionOptions? subscriptionOptions, com.revenuecat.purchases.models.SubscriptionOption? defaultOption, com.android.billingclient.api.ProductDetails productDetails)` - `GoogleStoreProduct(String productId, String? basePlanId, com.revenuecat.purchases.ProductType type, com.revenuecat.purchases.models.Price price, String name, String title, String description, com.revenuecat.purchases.models.Period? period, com.revenuecat.purchases.models.SubscriptionOptions? subscriptionOptions, com.revenuecat.purchases.models.SubscriptionOption? defaultOption, com.android.billingclient.api.ProductDetails productDetails, optional String? presentedOfferingIdentifier)` - `GoogleStoreProduct(String productId, String? basePlanId, com.revenuecat.purchases.ProductType type, com.revenuecat.purchases.models.Price price, String name, String title, String description, com.revenuecat.purchases.models.Period? period, com.revenuecat.purchases.models.SubscriptionOptions? subscriptionOptions, com.revenuecat.purchases.models.SubscriptionOption? defaultOption, com.android.billingclient.api.ProductDetails productDetails, optional String? presentedOfferingIdentifier, optional com.revenuecat.purchases.PresentedOfferingContext? presentedOfferingContext)` ``` -------------------------------- ### getLogLevel Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Gets the current log level for the Purchases SDK. ```APIDOC ## getLogLevel ### Description Gets the current `LogLevel` for the Purchases SDK. ### Method `getLogLevel(): LogLevel` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **LogLevel**: The current log level. #### Response Example None ``` -------------------------------- ### Build All Modules Source: https://github.com/revenuecat/purchases-android/blob/main/AGENTS.md Use this command to compile all modules in the project. It's a fundamental step before running tests or deploying. ```bash # Build all modules ./gradlew build ``` -------------------------------- ### getLogHandler Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Gets the current log handler for the Purchases SDK. ```APIDOC ## getLogHandler ### Description Gets the current `LogHandler` used by the Purchases SDK. ### Method `getLogHandler(): LogHandler` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **LogHandler**: The current log handler. #### Response Example None ``` -------------------------------- ### launchIfNeededWithOptions Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface if needed, with a comprehensive set of options provided in a dedicated options object. ```APIDOC ## launchIfNeededWithOptions ### Description Launches the paywall interface if needed, using a `PaywallActivityLaunchIfNeededOptions` object for configuration. ### Method public void launchIfNeededWithOptions(...) ### Parameters #### Path Parameters - **options** (com.revenuecat.purchases.ui.revenuecatui.activity.PaywallActivityLaunchIfNeededOptions) - An object containing various options for launching the paywall if needed. ``` -------------------------------- ### getLogHandler Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Gets the current log handler used by the RevenueCat SDK. ```APIDOC ## getLogHandler ### Description Retrieves the current handler responsible for processing logs within the RevenueCat SDK. ### Method `getLogHandler` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) * **logHandler** (com.revenuecat.purchases.LogHandler) - The current log handler instance. ``` -------------------------------- ### AmazonStoreProductKt Utility Function Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Utility function to get an AmazonStoreProduct from a generic StoreProduct. ```APIDOC ## AmazonStoreProductKt Utility Function ### getAmazonProduct ```java public static com.revenuecat.purchases.amazon.AmazonStoreProduct? getAmazonProduct(com.revenuecat.purchases.models.StoreProduct) ``` Attempts to cast a `StoreProduct` to an `AmazonStoreProduct`. Returns `null` if the product is not from the Amazon store. ``` -------------------------------- ### launch (deprecated) Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface using an offering identifier. This is a deprecated method and should be replaced with the overload that accepts an Offering object directly. ```APIDOC ## launch (deprecated) ### Description Launches the paywall interface using an offering identifier. This method is deprecated. ### Method @Deprecated @kotlin.jvm.JvmSynthetic public void launch(...) ### Parameters #### Path Parameters - **offeringIdentifier** (String) - The identifier of the offering to display. #### Optional Parameters - **fontProvider** (com.revenuecat.purchases.ui.revenuecatui.fonts.ParcelizableFontProvider?) - Provides custom fonts for the paywall. - **shouldDisplayDismissButton** (boolean) - Whether to display a dismiss button. - **edgeToEdge** (boolean) - Whether to enable edge-to-edge display. ``` -------------------------------- ### Build AdMob Integration Sample for Android Source: https://github.com/revenuecat/purchases-android/blob/main/fastlane/README.md Builds an AdMob Integration Sample APK for Android. ```shell [bundle exec] fastlane android build_admob_integration_sample ``` -------------------------------- ### AmazonStoreProductKt Extension Function Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Extension function to get Amazon-specific product details from a StoreProduct. ```APIDOC ## AmazonStoreProductKt Extension Function ### getAmazonProduct ```java public static com.revenuecat.purchases.amazon.AmazonStoreProduct? getAmazonProduct(com.revenuecat.purchases.models.StoreProduct); ``` Converts a generic StoreProduct to an AmazonStoreProduct if it's an Amazon product. ``` -------------------------------- ### GoogleInstallmentsInfo Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Data class representing installment information specific to Google Play. It includes details about commitment payments. ```APIDOC ## GoogleInstallmentsInfo ### Description Data class representing installment information specific to Google Play. It includes details about commitment payments. ### Properties - **commitmentPaymentsCount** (int) The total number of commitment payments. - **renewalCommitmentPaymentsCount** (int) The number of renewal commitment payments. ``` -------------------------------- ### launchIfNeeded (with only display block) Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface if needed, solely based on a provided display block. ```APIDOC ## launchIfNeeded (with only display block) ### Description Launches the paywall interface if needed, based solely on a provided display block. ### Method public void launchIfNeeded(...) ### Parameters #### Optional Parameters - **shouldDisplayBlock** (kotlin.jvm.functions.Function1) - A block that determines if the paywall should be displayed. ``` -------------------------------- ### ReplacementMode Interface Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Defines the ReplacementMode interface for managing replacement modes within the Purchases SDK. It extends Parcelable and provides a method to get the name of the mode. ```APIDOC ## Interface ReplacementMode ### Description Represents a mode for replacements within the Purchases SDK. This interface is parcelable. ### Methods - **getName()**: `String` - Returns the name of the replacement mode. ### Properties - **name**: `String` - The name of the replacement mode. ``` -------------------------------- ### PaywallActivityLaunchOptions.Builder Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Builder class for configuring PaywallActivityLaunchOptions. ```APIDOC ## Class PaywallActivityLaunchOptions.Builder ### Description Builder for creating `PaywallActivityLaunchOptions`. ### Methods #### `build()` Builds the `PaywallActivityLaunchOptions` object. Returns: - `PaywallActivityLaunchOptions`: The constructed options object. #### `setCustomVariables(customVariables: Map)` Sets custom variables for the paywall. - **customVariables** (Map) - A map of custom variables. Returns: - `PaywallActivityLaunchOptions.Builder`: The builder instance. #### `setEdgeToEdge(edgeToEdge: Boolean)` Enables or disables edge-to-edge display mode for the paywall. - **edgeToEdge** (Boolean) - True to enable edge-to-edge, false otherwise. Returns: - `PaywallActivityLaunchOptions.Builder`: The builder instance. #### `setFontProvider(fontProvider: ParcelizableFontProvider?)` Sets a custom font provider for the paywall. - **fontProvider** (ParcelizableFontProvider?) - The font provider to use. Returns: - `PaywallActivityLaunchOptions.Builder`: The builder instance. #### `setListener(listener: PaywallListener?)` Sets a listener for paywall events. This is an experimental API. - **listener** (PaywallListener?) - The listener to set. Returns: - `PaywallActivityLaunchOptions.Builder`: The builder instance. #### `setOffering(offering: Offering?)` Sets the offering to be displayed in the paywall. - **offering** (Offering?) - The offering to display. Returns: - `PaywallActivityLaunchOptions.Builder`: The builder instance. #### `setPurchaseLogic(purchaseLogic: PaywallPurchaseLogic?)` Sets custom purchase logic for the paywall. This is an experimental API. - **purchaseLogic** (PaywallPurchaseLogic?) - The purchase logic to use. Returns: - `PaywallActivityLaunchOptions.Builder`: The builder instance. #### `setShouldDisplayDismissButton(shouldDisplayDismissButton: Boolean)` Determines whether the dismiss button should be displayed on the paywall. - **shouldDisplayDismissButton** (Boolean) - True to display the dismiss button, false otherwise. Returns: - `PaywallActivityLaunchOptions.Builder`: The builder instance. ``` -------------------------------- ### configure Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Configures the Purchases SDK. Use this method to set up the SDK with your API key and optionally an app user ID, or use a configuration object for custom entitlement computation. ```APIDOC ## configure ### Description Configures the Purchases SDK. You can provide the context, API key, and app user ID, or use a configuration object for custom entitlement computation. ### Method `public static com.revenuecat.purchases.Purchases configureInCustomEntitlementsComputationMode(android.content.Context context, String apiKey, String appUserID)` ### Method `public static com.revenuecat.purchases.Purchases configureInCustomEntitlementsComputationMode(com.revenuecat.purchases.PurchasesConfigurationForCustomEntitlementsComputationMode configuration)` ``` -------------------------------- ### Fastlane Run Backend Integration Tests Source: https://github.com/revenuecat/purchases-android/blob/main/AGENTS.md Runs backend integration tests via Fastlane. This command simplifies the execution of complex integration test setups. ```bash # Run backend integration tests bundle exec fastlane run_backend_integration_tests ``` -------------------------------- ### launchIfNeeded (with entitlement identifier and offering) Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface if needed, based on a required entitlement identifier and an optional offering. ```APIDOC ## launchIfNeeded (with entitlement identifier and offering) ### Description Launches the paywall interface if needed, based on a required entitlement identifier and an optional offering. ### Method public void launchIfNeeded(...) ### Parameters #### Path Parameters - **requiredEntitlementIdentifier** (String) - The identifier of the required entitlement. #### Optional Parameters - **offering** (com.revenuecat.purchases.Offering?) - The offering to display. ``` -------------------------------- ### AmazonConfiguration.Builder Constructor Source: https://github.com/revenuecat/purchases-android/blob/main/feature/amazon/api.txt Initializes the AmazonConfiguration.Builder. ```APIDOC ## AmazonConfiguration.Builder Constructor ### Description Constructs a new `AmazonConfiguration.Builder` instance. ### Method ```java public AmazonConfiguration.Builder(android.content.Context context, String apiKey) ``` ### Parameters * **context** (`android.content.Context`) - The application context. * **apiKey** (`String`) - Your RevenueCat API key. ``` -------------------------------- ### configure Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Configures the RevenueCat SDK with the provided configuration. This must be called before any other methods in the SDK. ```APIDOC ## configure ### Description Configures the RevenueCat SDK with the provided configuration. This must be called before any other methods in the SDK. ### Method `public static com.revenuecat.purchases.Purchases configure(com.revenuecat.purchases.PurchasesConfiguration configuration)` ``` -------------------------------- ### Load App Open Ad (AdMob Only) Source: https://github.com/revenuecat/purchases-android/blob/main/feature/admob/README.md Use this code to load an app open ad using AdMob's SDK. Ensure you have the necessary AdMob setup. ```kotlin AppOpenAd.load( context, "AD_UNIT_ID", AdRequest.Builder().build(), object : AppOpenAdLoadCallback() { override fun onAdLoaded(ad: AppOpenAd) { appOpenAd = ad } override fun onAdFailedToLoad(loadAdError: LoadAdError) { // Handle error. } }, ) // Later, to show: appOpenAd?.show(activity) ``` -------------------------------- ### Load Rewarded Interstitial Ad (AdMob Only) Source: https://github.com/revenuecat/purchases-android/blob/main/feature/admob/README.md Use this code to load a rewarded interstitial ad using AdMob's SDK. Ensure you have the necessary AdMob setup. ```kotlin RewardedInterstitialAd.load( this, "AD_UNIT_ID", AdRequest.Builder().build(), object : RewardedInterstitialAdLoadCallback() { override fun onAdLoaded(ad: RewardedInterstitialAd) { rewardedInterstitialAd = ad } override fun onAdFailedToLoad(adError: LoadAdError) { rewardedInterstitialAd = null } }, ) // Later, to show: rewardedInterstitialAd?.show(this) { rewardItem -> val rewardAmount = rewardItem.amount val rewardType = rewardItem.type } ``` -------------------------------- ### launchIfNeeded (with entitlement identifier, offering, and font provider) Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface if needed, based on a required entitlement identifier, an optional offering, and an optional font provider. ```APIDOC ## launchIfNeeded (with entitlement identifier, offering, and font provider) ### Description Launches the paywall interface if needed, based on a required entitlement identifier, an optional offering, and an optional font provider. ### Method public void launchIfNeeded(...) ### Parameters #### Path Parameters - **requiredEntitlementIdentifier** (String) - The identifier of the required entitlement. #### Optional Parameters - **offering** (com.revenuecat.purchases.Offering?) - The offering to display. - **fontProvider** (com.revenuecat.purchases.ui.revenuecatui.fonts.ParcelizableFontProvider?) - Provides custom fonts for the paywall. ``` -------------------------------- ### Initiate a Purchase with awaitPurchase Source: https://github.com/revenuecat/purchases-android/blob/main/examples/CustomEntitlementComputationSample/README.md Use `awaitPurchase` to initiate a purchase flow. Handle `PurchasesTransactionException` to manage user cancellations and various error codes, providing specific user feedback for each. ```kotlin val purchaseParams = PurchaseParams.Builder(activity, aPackage).build() try { val (transaction, customerInfo) = Purchases.sharedInstance.awaitPurchase(purchaseParams) // refresh entitlements with your backend } catch (error: PurchasesTransactionException) { if (error.userCancelled) { _uiState.update { it.copy(displayErrorMessage = "Purchase was cancelled by the user") } } else { val errorMessage = when (error.code) { PurchasesErrorCode.ReceiptAlreadyInUseError -> "The receipt is already in use by another subscriber. " + "Log in with the previous account or contact support " + "to get your purchases transferred to regain access" PurchasesErrorCode.PaymentPendingError -> "The purchase is pending and may be completed at a later time. " + "This can happen when awaiting parental approval or going " + "through extra authentication flows for credit cards " + "in some countries" PurchasesErrorCode.ProductAlreadyPurchasedError -> "Subscription is already purchased. Log in with the account " + "that originally performed this purchase if you're using a different one." PurchasesErrorCode.PurchaseNotAllowedError -> "Purchasing wasn't allowed, which is common if the card is declined " + "or the purchase is not available in the country " + "you're trying to purchase from." PurchasesErrorCode.StoreProblemError -> "There was a problem with the Google Play Store. This is a generic " + "Google error, and there's not enough information to " + "determine the cause." else -> "FAILED TO PURCHASE: ${error.message}" } _uiState.update { it.copy(displayErrorMessage = errorMessage) } } } ``` -------------------------------- ### Run Lint for Static Code Analysis Source: https://github.com/revenuecat/purchases-android/blob/main/AGENTS.md Performs static code analysis using Android Lint to identify potential bugs, performance issues, and style guide violations. ```bash # Run lint (static code analysis) ./gradlew lint ``` -------------------------------- ### Configure Native AdLoader with Tracking Source: https://github.com/revenuecat/purchases-android/blob/main/feature/admob/api.txt Create an AdLoader.Builder for native ads with tracking capabilities. This includes options for placement, ad listener, paid event listener, and a callback for when a native ad is loaded. ```kotlin public static com.google.android.gms.ads.AdLoader.Builder forNativeAdWithTracking(com.google.android.gms.ads.AdLoader.Builder builder, String adUnitId, optional String? placement, optional com.google.android.gms.ads.AdListener? adListener, optional com.google.android.gms.ads.OnPaidEventListener? onPaidEventListener, optional kotlin.jvm.functions.Function1 onNativeAdLoaded); ``` -------------------------------- ### Build Custom Entitlement Computation Sample for Android Source: https://github.com/revenuecat/purchases-android/blob/main/fastlane/README.md Builds a Magic Weather Compose APK for the custom entitlement computation sample. ```shell [bundle exec] fastlane android build_custom_entitlement_computation_sample ``` -------------------------------- ### OriginalTemplatePaywallFooterView Methods Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Methods available for configuring the OriginalTemplatePaywallFooterView after initialization. ```APIDOC ## OriginalTemplatePaywallFooterView Methods ### Description Methods to configure the `OriginalTemplatePaywallFooterView`. ### Methods - `setDismissHandler(Function0? dismissHandler)`: Sets the handler to be called when the paywall is dismissed. - `setFontProvider(FontProvider? fontProvider)`: Sets the font provider for custom fonts. - `setOfferingId(String? offeringId)`: (Deprecated) Sets the offering ID. - `setPaywallListener(PaywallListener? listener)`: Sets the listener for paywall events. ``` -------------------------------- ### purchaseWith Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Initiates a purchase flow for the given `PurchaseParams`. This method handles the entire purchase process, including interacting with the store. ```APIDOC ## purchaseWith ### Description Initiates a purchase flow for the given `PurchaseParams`. This method handles the entire purchase process, including interacting with the store. ### Method `purchaseWith` ### Parameters - `purchases` (com.revenuecat.purchases.Purchases) - The Purchases instance. - `purchaseParams` (com.revenuecat.purchases.PurchaseParams) - An object containing all necessary information for the purchase. - `onError` (optional kotlin.jvm.functions.Function2) - A callback function invoked if an error occurs during the purchase. The boolean indicates if the error is from the user. - `onSuccess` (kotlin.jvm.functions.Function2) - A callback function invoked with the `StoreTransaction` and updated `CustomerInfo` upon successful purchase. ### Response #### Success Response - `StoreTransaction` (com.revenuecat.purchases.models.StoreTransaction?) - The transaction details if the purchase was successful. - `CustomerInfo` (com.revenuecat.purchases.CustomerInfo) - The updated customer information. #### Error Response - `PurchasesError` (com.revenuecat.purchases.PurchasesError) - An error object detailing the purchase failure. - `Boolean` - Indicates if the error originated from the user (e.g., cancellation). ``` -------------------------------- ### launchIfNeeded (with display block) Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface if needed, based on a block that determines display conditions. This overload also accepts an offering and font provider. ```APIDOC ## launchIfNeeded (with display block) ### Description Launches the paywall interface if needed, based on a display block and optional offering and font provider. ### Method public void launchIfNeeded(...) ### Parameters #### Optional Parameters - **offering** (com.revenuecat.purchases.Offering?) - The offering to display. - **fontProvider** (com.revenuecat.purchases.ui.revenuecatui.fonts.ParcelizableFontProvider?) - Provides custom fonts for the paywall. - **shouldDisplayDismissButton** (boolean) - Whether to display a dismiss button. - **shouldDisplayBlock** (kotlin.jvm.functions.Function1) - A block that determines if the paywall should be displayed. ``` -------------------------------- ### Load and Track App Open Ad with RevenueCat Source: https://github.com/revenuecat/purchases-android/blob/main/feature/admob/README.md Integrate app open ad loading with RevenueCat for impression and click tracking. Pass the fullScreenContentCallback directly to the load function. ```kotlin Purchases.sharedInstance.adTracker.loadAndTrackAppOpenAd( context = context, adUnitId = "AD_UNIT_ID", adRequest = AdRequest.Builder().build(), placement = "app_launch", loadCallback = object : AppOpenAdLoadCallback() { override fun onAdLoaded(ad: AppOpenAd) { appOpenAd = ad } override fun onAdFailedToLoad(loadAdError: LoadAdError) { // Handle error. } }, // ⚠️ Pass fullScreenContentCallback here — not on the ad object later. // The adapter wraps it with tracking; assigning ad.fullScreenContentCallback // afterward replaces the wrapper and breaks impression/click tracking. fullScreenContentCallback = object : FullScreenContentCallback() { override fun onAdDismissedFullScreenContent() { appOpenAd = null } }, ) // Later, to show (unchanged): appOpenAd?.show(activity) ``` -------------------------------- ### PaywallActivityLaunchIfNeededOptions.Builder Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Builder class for configuring PaywallActivityLaunchIfNeededOptions. ```APIDOC ## Class PaywallActivityLaunchIfNeededOptions.Builder ### Description Builder for creating `PaywallActivityLaunchIfNeededOptions`. ### Methods #### `build()` Builds the `PaywallActivityLaunchIfNeededOptions` object. Returns: - `PaywallActivityLaunchIfNeededOptions`: The constructed options object. #### `setCustomVariables(customVariables: Map)` Sets custom variables for the paywall. - **customVariables** (Map) - A map of custom variables. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setEdgeToEdge(edgeToEdge: Boolean)` Enables or disables edge-to-edge display mode for the paywall. - **edgeToEdge** (Boolean) - True to enable edge-to-edge, false otherwise. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setFontProvider(fontProvider: ParcelizableFontProvider?)` Sets a custom font provider for the paywall. - **fontProvider** (ParcelizableFontProvider?) - The font provider to use. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setListener(listener: PaywallListener?)` Sets a listener for paywall events. This is an experimental API. - **listener** (PaywallListener?) - The listener to set. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setOffering(offering: Offering?)` Sets the offering to be displayed in the paywall. - **offering** (Offering?) - The offering to display. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setPaywallDisplayCallback(paywallDisplayCallback: PaywallDisplayCallback?)` Sets a callback to be invoked when the paywall is displayed. - **paywallDisplayCallback** (PaywallDisplayCallback?) - The callback to invoke. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setPurchaseLogic(purchaseLogic: PaywallPurchaseLogic?)` Sets custom purchase logic for the paywall. This is an experimental API. - **purchaseLogic** (PaywallPurchaseLogic?) - The purchase logic to use. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setRequiredEntitlementIdentifier(requiredEntitlementIdentifier: String)` Sets the identifier for the required entitlement to display the paywall. - **requiredEntitlementIdentifier** (String) - The entitlement identifier. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setShouldDisplayBlock(shouldDisplayBlock: Function1)` Sets a block that determines whether the paywall should be displayed based on `CustomerInfo`. - **shouldDisplayBlock** (Function1) - A function that takes `CustomerInfo` and returns a boolean. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. #### `setShouldDisplayDismissButton(shouldDisplayDismissButton: Boolean)` Determines whether the dismiss button should be displayed on the paywall. - **shouldDisplayDismissButton** (Boolean) - True to display the dismiss button, false otherwise. Returns: - `PaywallActivityLaunchIfNeededOptions.Builder`: The builder instance. ``` -------------------------------- ### PresentedOfferingContext Class Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Provides context about the offering that was presented to the user. ```APIDOC ## PresentedOfferingContext Class ### Description Provides context about the offering that was presented to the user. ### Constructors - `PresentedOfferingContext(String offeringIdentifier)` - `PresentedOfferingContext(String offeringIdentifier, String? placementIdentifier, TargetingContext? targetingContext)` ### Methods - `getOfferingIdentifier()`: Returns the identifier of the offering. - `getPlacementIdentifier()`: Returns the identifier of the placement, if available. - `getTargetingContext()`: Returns the targeting context, if available. ### Properties - `offeringIdentifier` (String): The identifier of the offering. - `placementIdentifier` (String?): The identifier of the placement, if available. - `targetingContext` (TargetingContext?): The targeting context, if available. ``` -------------------------------- ### launch Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface. This method has multiple overloads to allow for different configurations, including specifying an offering, font provider, dismiss button visibility, edge-to-edge display, and custom variables. ```APIDOC ## launch ### Description Launches the paywall interface with various configuration options. ### Method public void launch(...) ### Parameters #### Optional Parameters - **offering** (com.revenuecat.purchases.Offering?) - The offering to display. - **fontProvider** (com.revenuecat.purchases.ui.revenuecatui.fonts.ParcelizableFontProvider?) - Provides custom fonts for the paywall. - **shouldDisplayDismissButton** (boolean) - Whether to display a dismiss button. - **edgeToEdge** (boolean) - Whether to enable edge-to-edge display. - **customVariables** (java.util.Map) - A map of custom variables to pass to the paywall. ``` -------------------------------- ### launchIfNeeded (deprecated) Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Launches the paywall interface if needed, using both a required entitlement identifier and an offering identifier. This is a deprecated method. ```APIDOC ## launchIfNeeded (deprecated) ### Description Launches the paywall interface if needed, using both a required entitlement identifier and an offering identifier. This method is deprecated. ### Method @Deprecated @kotlin.jvm.JvmSynthetic public void launchIfNeeded(...) ### Parameters #### Path Parameters - **requiredEntitlementIdentifier** (String) - The identifier of the required entitlement. - **offeringIdentifier** (String) - The identifier of the offering to display. #### Optional Parameters - **fontProvider** (com.revenuecat.purchases.ui.revenuecatui.fonts.ParcelizableFontProvider?) - Provides custom fonts for the paywall. - **shouldDisplayDismissButton** (boolean) - Whether to display a dismiss button. - **edgeToEdge** (boolean) - Whether to enable edge-to-edge display. - **paywallDisplayCallback** (com.revenuecat.purchases.ui.revenuecatui.activity.PaywallDisplayCallback?) - A callback for when the paywall is displayed. ``` -------------------------------- ### PaywallView Constructors Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Provides various constructors for initializing the PaywallView with different configurations, including context, offering, listener, font provider, dismiss button display, purchase logic, and dismiss handler. ```APIDOC ## PaywallView Constructors ### Description Initializes the PaywallView with different configurations. ### Constructors - `PaywallView(Context context)` - `PaywallView(Context context, AttributeSet? attrs)` - `PaywallView(Context context, AttributeSet? attrs, int defStyleAttr)` - `PaywallView(Context context, Offering? offering)` - `PaywallView(Context context, Offering? offering, PaywallListener? listener)` - `PaywallView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider)` - `PaywallView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider, Boolean? shouldDisplayDismissButton)` - `PaywallView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider, Boolean? shouldDisplayDismissButton, PaywallPurchaseLogic? purchaseLogic)` - `PaywallView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider, Boolean? shouldDisplayDismissButton, PaywallPurchaseLogic? purchaseLogic, Function0? dismissHandler)` - `PaywallView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider, Boolean? shouldDisplayDismissButton, Function0? dismissHandler)` ``` -------------------------------- ### configure Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Configures the Purchases SDK with the provided configuration. This method must be called before any other Purchases method. ```APIDOC ## configure ### Description Configures the Purchases SDK with the provided `PurchasesConfiguration`. This is the first method that should be called. ### Method `configure(configuration: PurchasesConfiguration): Purchases` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **configuration** (PurchasesConfiguration) - Required - The configuration object for the Purchases SDK. ### Request Example None ### Response #### Success Response (200) - **Purchases**: The configured Purchases instance. #### Response Example None ``` -------------------------------- ### Load API Keys and Project ID from local.properties Source: https://github.com/revenuecat/purchases-android/blob/main/codegen/README.md Securely load API keys and project IDs for local development by reading them from a local.properties file. This file should be added to .gitignore to prevent committing sensitive credentials. ```kotlin // build.gradle.kts val localProps = java.util.Properties().apply { rootProject.file("local.properties").takeIf { it.exists() }?.inputStream()?.use { load(it) } } revenuecat { apiKey.set(localProps.getProperty("REVENUECAT_API_KEY", "")) projectId.set(localProps.getProperty("REVENUECAT_PROJECT_ID", "")) packageName.set("com.example.app.rc") } ``` ```properties # local.properties (add to .gitignore) REVENUECAT_API_KEY=sk_your_v2_secret_key REVENUECAT_PROJECT_ID=proj_your_project_id ``` -------------------------------- ### TestStoreProduct Methods Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Details the available methods for interacting with TestStoreProduct objects, including copying with updated offering IDs or context, and retrieving various product details. ```APIDOC ## TestStoreProduct Methods ### Description Details the available methods for interacting with `TestStoreProduct` objects, including copying with updated offering IDs or context, and retrieving various product details. ### Methods - `copyWithOfferingId(String offeringId)`: Returns a new `StoreProduct` with the specified offering ID. Deprecated. - `copyWithPresentedOfferingContext(com.revenuecat.purchases.PresentedOfferingContext? presentedOfferingContext)`: Returns a new `StoreProduct` with the specified presented offering context. - `getDefaultOption()`: Returns the default `SubscriptionOption` for the product. - `getDescription()`: Returns the description of the product. - `getId()`: Returns the unique identifier of the product. - `getName()`: Returns the name of the product. - `getPeriod()`: Returns the subscription period of the product. - `getPresentedOfferingContext()`: Returns the `PresentedOfferingContext` associated with the product. - `getPresentedOfferingIdentifier()`: Returns the identifier of the presented offering. Deprecated. - `getPrice()`: Returns the price of the product. - `getPurchasingData()`: Returns the purchasing data associated with the product. - `getSku()`: Returns the SKU of the product. - `getSubscriptionOptions()`: Returns the available `SubscriptionOptions` for the product. - `getTitle()`: Returns the title of the product. - `getType()`: Returns the `ProductType` of the product. ``` -------------------------------- ### getOfferingsWith Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Retrieves the customer's offerings, which include their available in-app products to purchase. This method is useful for displaying products to the user. ```APIDOC ## getOfferingsWith ### Description Retrieves the customer's offerings, which include their available in-app products to purchase. This method is useful for displaying products to the user. ### Method `getOfferingsWith` ### Parameters - `purchases` (com.revenuecat.purchases.Purchases) - The Purchases instance. - `onError` (optional kotlin.jvm.functions.Function1) - A callback function that is invoked if an error occurs during the retrieval of offerings. - `onSuccess` (kotlin.jvm.functions.Function1) - A callback function that is invoked with the retrieved `Offerings` object upon successful retrieval. ### Response #### Success Response - `Offerings` (com.revenuecat.purchases.Offerings) - An object containing the customer's offerings. #### Error Response - `PurchasesError` (com.revenuecat.purchases.PurchasesError) - An error object detailing the issue if retrieval fails. ``` -------------------------------- ### awaitCustomerInfo Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-defauts.txt Asynchronously fetches the customer information. Allows specifying a cache fetch policy. ```APIDOC ## awaitCustomerInfo ### Description Asynchronously fetches the customer information. Allows specifying a cache fetch policy. ### Method `suspend` ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin val customerInfo = purchases.awaitCustomerInfo(fetchPolicy = CacheFetchPolicy.NETWORK_ONLY) ``` ### Response #### Success Response - **customerInfo** (CustomerInfo) - The customer's information. #### Response Example ```json { "purchaserInfo": "..." } ``` ``` -------------------------------- ### OriginalTemplatePaywallFooterView Constructors Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Provides various constructors for initializing the OriginalTemplatePaywallFooterView with different configurations. ```java public class OriginalTemplatePaywallFooterView extends android.widget.FrameLayout { ctor public OriginalTemplatePaywallFooterView(android.content.Context context); ctor public OriginalTemplatePaywallFooterView(android.content.Context context, android.util.AttributeSet? attrs); ctor public OriginalTemplatePaywallFooterView(android.content.Context context, android.util.AttributeSet? attrs, int defStyleAttr); ctor public OriginalTemplatePaywallFooterView(android.content.Context context, optional com.revenuecat.purchases.Offering? offering); ctor public OriginalTemplatePaywallFooterView(android.content.Context context, optional com.revenuecat.purchases.Offering? offering, optional com.revenuecat.purchases.ui.revenuecatui.PaywallListener? listener); ctor public OriginalTemplatePaywallFooterView(android.content.Context context, optional com.revenuecat.purchases.Offering? offering, optional com.revenuecat.purchases.ui.revenuecatui.PaywallListener? listener, optional com.revenuecat.purchases.ui.revenuecatui.fonts.FontProvider? fontProvider); ctor public OriginalTemplatePaywallFooterView(android.content.Context context, optional com.revenuecat.purchases.Offering? offering, optional com.revenuecat.purchases.ui.revenuecatui.PaywallListener? listener, optional com.revenuecat.purchases.ui.revenuecatui.fonts.FontProvider? fontProvider, optional boolean condensed); ctor public OriginalTemplatePaywallFooterView(android.content.Context context, optional com.revenuecat.purchases.Offering? offering, optional com.revenuecat.purchases.ui.revenuecatui.PaywallListener? listener, optional com.revenuecat.purchases.ui.revenuecatui.fonts.FontProvider? fontProvider, optional boolean condensed, optional kotlin.jvm.functions.Function0? dismissHandler); } ``` -------------------------------- ### awaitOfferingsResult Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Asynchronously fetches the customer's offerings, returning the result as a Kotlin `Result` object. ```APIDOC ## awaitOfferingsResult ### Description Asynchronously fetches the customer's offerings, returning the result as a Kotlin `Result` object. ### Method `suspend` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response - **Result** - A `Result` object containing the customer's offerings or an exception. #### Response Example N/A ``` -------------------------------- ### Load and Track Banner Ad using Extension Source: https://github.com/revenuecat/purchases-android/blob/main/examples/admob-sample/README.md Loads and tracks a banner ad using the extension function provided by the adapter. This is the primary method demonstrated in the sample for banner ads. ```kotlin adView.loadAndTrackAd( adRequest = AdRequest.Builder().build(), placement = "home_banner", ) ``` -------------------------------- ### Configure Cache TTL to 0 for Immediate Fetching Source: https://github.com/revenuecat/purchases-android/blob/main/codegen/README.md Set `cacheTtlMinutes` to `0` in the `revenuecat` block to force fetching the schema on every build. Be aware this can add network latency and increase the risk of hitting API rate limits. ```kotlin revenuecat { cacheTtlMinutes.set(0) } ``` -------------------------------- ### Load and Track App Open Ad Source: https://github.com/revenuecat/purchases-android/blob/main/feature/admob/api.txt Use this method to load and track App Open Ads. It requires an AdTracker, Context, ad unit ID, and AdRequest. Optional parameters include placement, load callback, full screen content callback, and paid event listener. ```kotlin package com.revenuecat.purchases.admob { public final class AdTrackerAdMob { method @com.revenuecat.purchases.ExperimentalPreviewRevenueCatPurchasesAPI @kotlin.jvm.JvmSynthetic public static void loadAndTrackAppOpenAd(com.revenuecat.purchases.ads.events.AdTracker, android.content.Context context, String adUnitId, com.google.android.gms.ads.AdRequest adRequest, optional String? placement, optional com.google.android.gms.ads.appopen.AppOpenAd.AppOpenAdLoadCallback? loadCallback, optional com.google.android.gms.ads.FullScreenContentCallback? fullScreenContentCallback, optional com.google.android.gms.ads.OnPaidEventListener? onPaidEventListener); } } ``` -------------------------------- ### getOfferings Source: https://github.com/revenuecat/purchases-android/blob/main/purchases/api-entitlement.txt Retrieves the customer's offerings. This method uses a callback to return the offerings. ```APIDOC ## getOfferings ### Description Retrieves the customer's offerings. The results will be returned asynchronously via the provided callback. ### Method `public void getOfferings(com.revenuecat.purchases.interfaces.ReceiveOfferingsCallback listener)` ``` -------------------------------- ### OriginalTemplatePaywallFooterView Constructors Source: https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/api.txt Constructors for the OriginalTemplatePaywallFooterView class, allowing initialization with various configurations including context, offering, listener, font provider, condensed state, and dismiss handler. ```APIDOC ## OriginalTemplatePaywallFooterView Constructors ### Description Constructors for initializing the `OriginalTemplatePaywallFooterView`. ### Constructors - `OriginalTemplatePaywallFooterView(Context context)` - `OriginalTemplatePaywallFooterView(Context context, AttributeSet? attrs)` - `OriginalTemplatePaywallFooterView(Context context, AttributeSet? attrs, int defStyleAttr)` - `OriginalTemplatePaywallFooterView(Context context, Offering? offering)` - `OriginalTemplatePaywallFooterView(Context context, Offering? offering, PaywallListener? listener)` - `OriginalTemplatePaywallFooterView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider)` - `OriginalTemplatePaywallFooterView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider, boolean condensed)` - `OriginalTemplatePaywallFooterView(Context context, Offering? offering, PaywallListener? listener, FontProvider? fontProvider, boolean condensed, Function0? dismissHandler)` ```