Skip to content

· 11 min read · Nadeera Silva

Payments

Restore Purchases Not Working in Flutter: iOS and Android

Fix restore purchases in Flutter: why restorePurchases() hangs or returns nothing on iOS and Android, and a tested service that always gives the UI an answer.

Two hands tap a glowing teal button on a new phone at a linen-covered table, beside an old worn phone and an open phone box, like restoring purchases on a new device.

A user reinstalls your app, taps "Restore purchases", and the spinner never stops. Or it stops and nothing unlocks, even though they paid. Restore purchases not working in Flutter is rarely a store outage. With the in_app_purchase plugin it usually comes down to three things: restorePurchases() doesn't return the restored items, the results arrive later on purchaseStream (or, in one open iOS report, not at all), and restored purchases still have to be verified and sometimes completed. Here is what the plugin actually does on iOS and Android today, and a small RestoreService that always gives your UI an answer.

Quick answer

restorePurchases() returns Future<void>. The restored items come back on purchaseStream with PurchaseStatus.restored, sometimes after that Future has completed, and an empty list means there was nothing to restore. Subscribe to the stream before you call it, wait for the first batch with a timeout, then verify each item and call completePurchase when pendingCompletePurchase is true. Consumables that were already used never come back on either store.

What this means for your app or business

  • Paying users locked out. A broken restore button looks like you took their money. It shows up as one-star reviews and refund requests, not as a crash in your logs.
  • App Review can reject the build. Apple's guideline 3.1.1 says "you should make sure you have a restore mechanism for any restorable in-app purchases."
  • Usually a small fix. If purchases are set up correctly, fixing restore is mostly a day of client code and device testing.
  • Credits and coins are a separate job. Neither store restores consumables. If users expect coins back on a new phone, you need your own server records.
  • When to get help. If you sell subscriptions and have no server copy of who is entitled to what, fix that before you spend more on marketing.

Why is restore purchases not working in my Flutter app?

These are the causes I'd check, in order:

  1. The code waits on the Future instead of the stream. await InAppPurchase.instance.restorePurchases() tells you the request was sent, not what came back. Code that checks "did anything arrive?" right after the await can lose a race. A comment on flutter/flutter issue 112948 (27 October 2026) logged Android purchases reaching the listener about 10 to 15 ms after the Future completed.
  2. The listener ignores empty lists. On Android and on the StoreKit 1 path the plugin emits an empty list when there is nothing to restore. If your listener does if (purchases.isEmpty) return;, the spinner never hears the answer.
  3. No event at all on iOS. Issue 180396 (still open) reports that purchaseStream doesn't fire when a fresh sandbox account has nothing to restore, last confirmed with in_app_purchase_storekit 0.4.9 in May 2026. The current Swift code does send an empty batch, but I couldn't test it on a device, so treat silence as possible and use a timeout.
  4. The listener subscribes too late. purchaseStream is a broadcast stream. A batch emitted before you call listen is gone.
  5. Wrong account. Restore only returns purchases made with the Apple ID or Google account that is signed in to the store on that device.
  6. The product was consumed. A used consumable is no longer owned, so the stores don't return it.
Flow of a restore in Flutter: the app listens to purchaseStream, calls restorePurchases, the store looks up entitlements, and the result is an error, no event, an empty list or restored items
Every restore must end in one of four states, so the spinner always stops

What does restorePurchases() actually do on iOS and Android?

Platform pathWhat restore asks the storeWhat comes back on purchaseStreamNeeds completePurchase
iOS, StoreKit 2 (the default)Transaction.currentEntitlements on the device, no App Store sign-in promptOne batch of restored items, or an empty batchNo, pendingCompletePurchase is false
iOS, StoreKit 1 (opt in)restoreCompletedTransactions, which can prompt for the Apple IDRestored transactions, maybe in several batches, or an empty listYes, each one must be finished
Android, Billing Library 9.1.0queryPurchasesAsync for one-time products and subscriptionsOwned items as one batch, or an empty listOnly if not yet acknowledged

On Android the plugin's restorePurchases() runs two queryPurchasesAsync calls and marks every result restored. That means active subscriptions and one-time products that are still owned, including any consumable you haven't consumed yet. Purchase history is gone: Google removed queryPurchaseHistory() in Play Billing Library 8.0.0, per the release notes. If a query fails, the plugin throws an InAppPurchaseException and emits nothing, so your code has to catch it.

On iOS, in_app_purchase_storekit uses StoreKit 2 by default. Its restore walks Transaction.currentEntitlements, which Apple says lists non-consumables, active auto-renewable subscriptions and non-renewing subscriptions, never consumables or refunded items. It does not call AppStore.sync(), so it reads what the device already knows. enableStoreKit1() is deprecated and only switches to StoreKit 1 on devices without StoreKit 2.

Do I need a restore purchases button on Google Play?

I couldn't find a Google Play policy that requires one. Google's integration guide instead asks apps to call queryPurchasesAsync() in onResume() so purchases that changed while the app was closed get processed. In Flutter, the simplest match is to run the same restore quietly on launch and when the app returns to the foreground, and still keep the button for users who switch accounts.

How do I build a restore button that never hangs?

The service below listens first, starts a timeout, calls restorePurchases(), collects every batch until the stream has been quiet for 800 ms, then verifies and completes what came back. It returns restored, nothing or error, so the UI always has something to show.

import 'dart:async';

import 'package:in_app_purchase/in_app_purchase.dart';

enum RestoreStatus { restored, nothing, error }

class RestoreResult {
  const RestoreResult(
    this.status, {
    this.productIds = const <String>{},
    this.error,
    this.timedOut = false,
  });

  final RestoreStatus status;
  final Set<String> productIds;
  final Object? error;

  /// True when the store never answered on purchaseStream within the timeout.
  final bool timedOut;
}

/// Checks a purchase with your backend (or locally) and unlocks it.
/// Return true only when the entitlement is valid and has been granted.
typedef VerifyAndUnlock = Future<bool> Function(PurchaseDetails purchase);

class RestoreService {
  RestoreService({
    required this.purchaseStream,
    required this.restorePurchases,
    required this.completePurchase,
    required this.verifyAndUnlock,
    this.timeout = const Duration(seconds: 30),
    this.settle = const Duration(milliseconds: 800),
  });

  factory RestoreService.forStore(
    InAppPurchase iap, {
    required VerifyAndUnlock verifyAndUnlock,
    String? applicationUserName,
  }) {
    return RestoreService(
      purchaseStream: iap.purchaseStream,
      restorePurchases: () =>
          iap.restorePurchases(applicationUserName: applicationUserName),
      completePurchase: iap.completePurchase,
      verifyAndUnlock: verifyAndUnlock,
    );
  }

  final Stream<List<PurchaseDetails>> purchaseStream;
  final Future<void> Function() restorePurchases;
  final Future<void> Function(PurchaseDetails purchase) completePurchase;
  final VerifyAndUnlock verifyAndUnlock;
  final Duration timeout;
  final Duration settle;

  bool _running = false;

  Future<RestoreResult> restore() async {
    if (_running) {
      return RestoreResult(
        RestoreStatus.error,
        error: StateError('A restore is already running'),
      );
    }
    _running = true;

    final received = <PurchaseDetails>[];
    final finished = Completer<void>();
    Timer? settleTimer;
    var timedOut = false;

    // 1. Listen BEFORE calling restorePurchases so no batch is missed.
    final sub = purchaseStream.listen(
      (List<PurchaseDetails> batch) {
        received.addAll(batch);
        // An empty batch is the store saying "nothing to restore".
        // Every batch restarts the settle window, because StoreKit 1
        // can deliver restored transactions in several batches.
        settleTimer?.cancel();
        settleTimer = Timer(settle, () {
          if (!finished.isCompleted) finished.complete();
        });
      },
      onError: (Object e) {
        if (!finished.isCompleted) finished.completeError(e);
      },
    );

    // 2. Start the timeout now. The Future of restorePurchases() does not
    //    tell us when (or whether) events reach the stream.
    final waitForStore = finished.future.timeout(timeout, onTimeout: () {
      timedOut = true;
    });

    try {
      await restorePurchases();
      await waitForStore;
    } catch (e) {
      waitForStore.ignore();
      return RestoreResult(RestoreStatus.error, error: e);
    } finally {
      settleTimer?.cancel();
      await sub.cancel();
      _running = false;
    }

    // 3. Verify, unlock and complete what came back.
    final unlocked = <String>{};
    Object? lastError;
    for (final purchase in received) {
      if (purchase.status == PurchaseStatus.error) {
        lastError = purchase.error;
        continue;
      }
      if (purchase.status != PurchaseStatus.restored &&
          purchase.status != PurchaseStatus.purchased) {
        continue; // pending or canceled: not ours to finish here
      }
      try {
        final ok = await verifyAndUnlock(purchase);
        if (!ok) continue;
        unlocked.add(purchase.productID);
        // Restored does not mean finished. StoreKit 1 restores and
        // unacknowledged Google Play purchases still need this call.
        if (purchase.pendingCompletePurchase) {
          await completePurchase(purchase);
        }
      } catch (e) {
        lastError = e;
      }
    }

    if (unlocked.isNotEmpty) {
      return RestoreResult(RestoreStatus.restored, productIds: unlocked);
    }
    if (lastError != null) {
      return RestoreResult(RestoreStatus.error, error: lastError);
    }
    return RestoreResult(RestoreStatus.nothing, timedOut: timedOut);
  }
}

Wire it to the button and map each result to a message:

final service = RestoreService.forStore(
  InAppPurchase.instance,
  verifyAndUnlock: verifyWithBackend, // your own check
);

Future<void> onRestoreTapped() async {
  setState(() => busy = true);
  final result = await service.restore();
  if (!mounted) return;
  setState(() => busy = false);
  final message = switch (result.status) {
    RestoreStatus.restored => 'Purchases restored.',
    RestoreStatus.nothing =>
      'No purchases found for this Apple ID or Google account.',
    RestoreStatus.error => 'Could not reach the store. Please try again.',
  };
  ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
}

A few choices in there are deliberate. The service checks pendingCompletePurchase instead of the status, because in the current source a StoreKit 2 restored item reports false, a StoreKit 1 restored transaction reports true, and a Google Play purchase reports true until it's acknowledged. It only completes a purchase after verifyAndUnlock succeeds. And it de-duplicates product IDs, since StoreKit 1 replays every completed transaction.

Do restored purchases still need completePurchase?

Sometimes, and on Android it matters most. If a purchase was never acknowledged (the app crashed, or the old version skipped it), it comes back from restore with pendingCompletePurchase set to true, and Google refunds unacknowledged purchases after three days. I covered that failure in Google Play purchase not acknowledged. On StoreKit 1, restored transactions sit in the payment queue until you finish them.

What if a paying iOS user still sees nothing?

First check the account. In sandbox the test account lives under Settings > Developer, and it only appears after the first purchase attempt in a development-signed app, per Apple's sandbox testing guide. A purchase made with one sandbox account won't restore under another.

If the account is right, offer a second step. Apple's `AppStore.sync()` documentation says to call it only in rare cases, after an explicit user action, because it shows an App Store sign-in prompt. The plugin exposes it on the StoreKit addition:

import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';

Future<RestoreResult> syncAndRestore(RestoreService service) async {
  await InAppPurchase.instance
      .getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>()
      .sync(); // throws if the user cancels the sign-in
  return service.restore();
}

Should restore depend on the device at all?

For subscriptions, I'd rather it didn't. If your server stores each purchase and keeps it current from App Store Server Notifications and Google's notifications, restore becomes "ask the backend what this user owns", and it works across platforms and after account changes. I walked through the Apple side in verifying App Store Server Notifications V2 in Node. The device restore then becomes a backup that sends any missing transaction to the server.

applicationUserName helps here too. On Android it becomes the obfuscated account ID on the purchase. On StoreKit 1 it is passed to restoreCompletedTransactions. On StoreKit 2 and Android, restorePurchases() ignores it, so don't expect it to filter results.

Checklist before you ship

  • Subscribe to purchaseStream once, before any restore or purchase call.
  • Treat an empty list as "nothing to restore", not as noise.
  • Put a timeout on every restore and stop the spinner when it fires.
  • Catch exceptions from restorePurchases().
  • Verify restored items, then call completePurchase when pendingCompletePurchase is true.
  • Show a visible "Restore purchases" button on iOS for non-consumables and subscriptions.
  • Keep consumable balances on your own server.
  • Test restore on a fresh install with a second sandbox or license tester account that has bought nothing.

Frequently asked questions

What does restore purchases do?

It asks the App Store or Google Play which purchases the signed-in account still owns and gives them back to the app so it can unlock them again. It is used after a reinstall, on a new phone or when content seems to be missing.

Why is my restore purchase not working?

In Flutter the usual causes are code that waits on the restorePurchases() Future instead of purchaseStream, a listener that ignores empty lists, or a different Apple ID or Google account. Consumables that were already used are never restored.

Does restorePurchases() return the restored purchases?

No. It returns Future<void>, and the purchases arrive on purchaseStream with the status restored, sometimes after the Future completes. An empty list means there was nothing to restore.

Do I need a restore purchases button on Google Play?

I found no Google Play policy that requires one. Google asks apps to query purchases when they resume, but a button still helps users who change accounts.

Is a restore purchases button required on the App Store?

Apple's guideline 3.1.1 says you should make sure you have a restore mechanism for any restorable in-app purchases. Apps with non-consumables or subscriptions usually show a Restore purchases button for this.

Can consumable purchases be restored?

No. Neither store returns consumables that were already used, so coins or credits have to be stored on your own server if users expect them back on a new device.

Do I need to call completePurchase on restored purchases?

Call it when pendingCompletePurchase is true. That is the case for StoreKit 1 restores and for Google Play purchases that were never acknowledged, while StoreKit 2 restored items report false.

Why does restore work on one iPhone but not another?

Restore only returns purchases made with the Apple ID that is signed in on that device, and in sandbox that is the account under Settings then Developer. If the account is right, an explicit sync with the App Store can fetch missing transactions.

Sources

  1. in_app_purchase 3.3.1 (pub.dev, 2026-09-18)
  2. in_app_purchase_storekit 0.4.17 changelog (pub.dev, 2026-11-04)
  3. in_app_purchase_android 0.5.5 changelog (pub.dev, 2026-10-19)
  4. Google Play Billing Library release notes (Android Developers, 2026-10-23)
  5. Integrate the Google Play Billing Library into your app (Android Developers, 2026-11-13)
  6. App Review Guidelines (Apple Developer, 2026-10-16)
  7. AppStore.sync() (Apple Developer Documentation)
  8. Transaction.currentEntitlements (Apple Developer Documentation)
  9. Testing in-app purchases with sandbox (Apple Developer Documentation)
  10. purchaseStream not triggered for restorePurchases() when nothing to restore (GitHub flutter/flutter, 2025-12-30)
  11. InAppPurchase can't restore purchases in main (timing analysis comment) (GitHub flutter/flutter, 2026-10-27)
  12. restorePurchases crashes when StoreKit 2 returns an unverified entitlement (GitHub flutter/flutter, 2026-10-24)
  13. Flutter SDK releases (Flutter documentation, 2026-11-20)
SharePost on XLinkedIn

Comments

Share a question or note about this article.

Loading comments…

Flutter Restore Purchases Not Working? Fix the Spinner | Nadeera Silva