What’s new: Integrations Update, Connection Builder, Custom Parameters in Rule’s Push Payloads, and more.Let’s see
Apphud
Why Apphud?PricingContact
Ren
Ren
May 15, 2025
11 min read

A Complete Guide to Restoring Purchases on Google Play and App Store

In this guide, we’ll dive deeper into the technical aspects of implementing purchase restoration on Google Play and Apple’s App Store.

11 min read
A Complete Guide to Restoring Purchases on Google Play and App Store

Restoring purchases is a critical functionality for mobile apps, allowing users to recover access to in-app purchases (IAPs) they've previously made, especially when transitioning to a new device, reinstalling an app, or after updates. This process ensures that users maintain access to features, content, or subscriptions they've paid for, without any additional cost or complications. 

Let's explore how to ensure your users can easily recover their purchases and continue enjoying everything your app has to offer.


Why Purchase Restoration is Crucial for User Retention

For app managers and developers, facilitating smooth purchase restoration is key to enhancing the user experience and maintaining customer loyalty. When users know their purchases are secure and easily recoverable, they feel more confident investing in your app. This assurance is vital for preventing user churn; frustrated users who can't easily access their purchases might abandon the app and switch to competitors.

Common Use Cases for Purchase Restoration

  • Device Migration: Users switching to a new phone will want to restore their purchases to continue enjoying the app without repurchase.
  • Reinstallation: Whether due to troubleshooting or freeing up space, users may delete and reinstall apps, necessitating an easy way to reclaim their purchases.
  • App Updates: Major updates can sometimes disrupt app states; having a solid restoration process mitigates any potential loss of access.

Ensuring seamless purchase restoration can lead to better reviews, increased user retention, and, ultimately, higher lifetime value (LTV) of users. It also reduces customer support queries, saving time and resources. By prioritizing this functionality, app developers can create a reliable and positive user experience, fostering trust and encouraging more in-app purchases.

How Purchase Restoration Works

Restoring purchases involves a series of steps where the app communicates with the respective app store to verify the user's purchase history and reinstate access to their paid features. Understanding the intricacies of in-app purchases (IAPs) and how they are stored and verified is crucial for implementing effective purchase restoration.

In-app purchases and subscriptions are stored in the app store's servers and linked to the user's account.

When a purchase is made, a receipt is generated, which serves as proof of the transaction. For app developers, verification entails checking these receipts against the app store's records to confirm their validity before restoring any purchases.

The primary task of the app is to retrieve the receipt, which contains a list of transactions (purchases). 

The Apphud SDK automatically sends this receipt to the server, where it is decoded and used as a data source for analytics.

Understanding the Difference Between StoreKit 1 and StoreKit 2 Receipts

One of the key changes introduced with StoreKit 2 is how purchase data is accessed and validated. In StoreKit 1, apps rely on a single receipt file (appStoreReceiptURL) that's stored on the user's device. This file includes a list of all in-app purchases made by the user and must be manually retrieved and sent to your server for validation, typically via Apple’s /verifyReceipt endpoint. Parsing this file requires base64-encoding, server-side validation, and dealing with ASN.1 decoding - a process that’s often considered cumbersome and error-prone.

StoreKit 2, on the other hand, introduces a modern Swift-based API that offers direct access to transaction and subscription data without needing to fetch or validate the receipt manually. Instead of relying on a single receipt file, StoreKit 2 exposes a structured list of transactions through methods like Transaction.currentEntitlements and Transaction.all, giving developers a much more readable and convenient way to access purchase history right on the device.

Another major difference is that StoreKit 2 transactions are cryptographically signed using JSON Web Signature (JWS). These signed transactions can optionally be sent to your backend for verification, but it's no longer mandatory to rely solely on server-side decoding. This allows for more flexibility in implementation, especially useful for apps that want to offer offline functionality or real-time entitlement checks without relying on a network call.

While StoreKit 2 dramatically simplifies receipt handling, developers working with legacy code or older iOS versions may still need to support StoreKit 1 receipts. Understanding the differences - and knowing when to use each - is essential for maintaining a robust and future-proof subscription system.


Apple Purchase Types

1. In-App Purchases

There are two primary categories of in-app purchases:

  • Consumable: Consumables are items that can be purchased multiple times and are depleted after use. Common examples include virtual currency, energy, or hints. These purchases are not restored automatically and must be tracked by your own backend if needed.
  • Non-Consumable: Non-consumables are purchased once and do not expire. Examples include unlocking a premium feature, removing ads, or purchasing additional game levels. These purchases are tied to the user’s Apple ID and can be restored on other devices using the Restore Purchases functionality.

2. Subscriptions

Subscriptions give users access to content or services for a set period of time. Apple supports two main types of subscriptions:

  • Auto-Renewable Subscriptions: These subscriptions automatically renew at the end of each billing period until the user cancels. They’re ideal for ongoing services such as streaming, cloud storage, or premium app features. Apple provides tools to manage pricing, territory availability, and more.
  • Non-Renewing Subscriptions: These are time-limited access subscriptions that do not automatically renew. Users must manually repurchase access when it expires. This type is more common in fixed-duration use cases like seasonal content or limited-time courses.

3. Subscription Options and Offers

Apple also provides several marketing and pricing tools to increase conversion and retention:

  • Introductory Offers: These are available to new subscribers and include:

1. Pay As You Go: Discounted rate for the first few billing periods (e.g., $0.99/month for 3 months).

2. Pay Up Front: A single upfront payment for a longer initial period (e.g., $9.99 for 6 months).

3. Free Trial: Users can try a subscription for free for a limited period. Trials can convert automatically into a paid plan unless canceled before the end of the trial.

  • Promotional Offers: These are available to existing or lapsed subscribers and can be used to win back users. They are more flexible than introductory offers and require the user to authenticate using their Apple ID.

All of these options can be combined strategically to build a subscription funnel that aligns with your app's business goals while giving users flexible, transparent pricing options.


How to Implement Restore Purchases in iOS and Android Apps

Implementing a Restore Purchases feature is essential for providing a seamless user experience. Here’s a step-by-step guide for both iOS and Android platforms.

Implementing Purchase Restoration in iOS Apps

Step 1: Set Up Your Project

  • Include StoreKit Framework: Ensure your project includes the StoreKit framework, which allows for in-app purchases.
  • Prepare Your App for In-App Purchases: Configure your app in App Store Connect with the necessary in-app products.

Step 2: Implement Restoration Logic

  • Create a Function for Restoring Purchases: Add a button in your app’s UI to allow users to restore their purchases.
  • Set Up the Payment Queue: Implement a method to handle the restoration
import StoreKit

class PurchaseManager: NSObject, SKPaymentTransactionObserver {

    func restorePurchases() {
        SKPaymentQueue.default().add(self)
        SKPaymentQueue.default().restoreCompletedTransactions()
    }

    func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
        for transaction in transactions {
            switch transaction.transactionState {
            case .restored:
                // Unlock the non-consumable purchase or subscription
                // Finish the restored transaction
                SKPaymentQueue.default().finishTransaction(transaction)
            default:
                break
            }
        }
    }
}

3. Handle Restored Transactions: Implement logic to unlock features related to restored purchases. Ensure transactions are properly finished to prevent duplicates.

Simplifying In-App Purchases with Apphud

One of the key advantages is automatic purchase restoration. Apphud handles restoring purchases automatically in the background, with no extra effort required from your side. The only case where manual restoration is recommended is on paywalls, where you may want to explicitly offer a "Restore" button for better UX transparency.

When switching to Apphud from another platform or your own in-house solution, there's no need for complex migration logic. The default integration is usually enough to recognize and carry over existing purchases seamlessly. Apphud retrieves the receipt, processes it on the server, and updates entitlements accordingly.

Import ApphudSDK

class PurchaseManager: NSObject {

    func restorePurchases() {
       Apphud.restorePurchases()
    }
}

Implementing Purchase Restoration in Android Apps

Step 1: Set Up Your Project

  • Add the Google Play Billing Library: Include the Google Play Billing Library in your app's build.gradle file:

implementation 'com.android.billingclient:billing:5.0.0'

2. Configure In-App Products in Google Play Console: Define your in-app products, such as non-consumables and subscriptions.

Step 2: Implement Restoration Logic

1. Connect to Google Play Billing: Set up the billing client in your activity or service

BillingClient billingClient = BillingClient.newBuilder(context)
    .setListener(purchasesUpdatedListener)
    .enablePendingPurchases()
    .build();

2. Query Purchases: Use the billing client to query purchases, which allows users to restore their purchases.

billingClient.startConnection(new BillingClientStateListener() {
    @Override
    public void onBillingSetupFinished(BillingResult billingResult) {
        if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
            Purchase.PurchasesResult purchasesResult = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
            handlePurchases(purchasesResult.getPurchasesList());
        }
    }

    @Override
    public void onBillingServiceDisconnected() {
        // Try reconnecting
    }
});

3. Handle Purchases: Implement logic to check and restore the user's previous purchases

void handlePurchases(List<Purchase> purchases) {
    for (Purchase purchase : purchases) {
        // Verify purchase and grant entitlement to the user
    }
}

Conclusion

Restoring purchases is a vital aspect of app development that ensures a seamless and user-friendly experience, safeguarding your users' investments and enhancing app loyalty. By implementing effective restoration mechanisms for both iOS and Android apps, you can reduce churn and improve user satisfaction. This approach not only retains your existing customers but also builds trust, encouraging further in-app purchases.

Showcase: Apphud - Subscription App Monetization Ecosystem

Apphud is an invaluable tool for app developers looking to optimize their subscription-based revenue strategies. It provides a comprehensive solution for managing in-app purchases and subscriptions. With features like automated receipt validation, user-friendly dashboards, and advanced analytics, Apphud streamlines the monetization process, ensuring that you maximize revenue while maintaining a high-quality user experience.

By integrating Apphud, developers can easily handle complex tasks like purchase restoration, subscription management, and data analysis, allowing them to focus on delivering great app features and customer service. Whether you're just starting or looking to enhance your app's monetization strategy, leveraging Apphud's capabilities can give you a competitive edge in today's dynamic app market. Sign up for free today!

Ren
Ren
Co-founder at Apphud
Ex iOS app and game developer. 11 years in the industry since iOS 3. More than 50 apps are in the background with 4 exits. Entrepreneur and traveler.

Related Posts