DEV Community

Surik Sarkisyan for Qonversion

Posted on • Originally published at qonversion.io

What does restore purchase mean?

When users purchase non-consumables, auto-renewable subscriptions, or non-renewing subscriptions, they expect them to be available on all their devices and indefinitely.

For the cases when a user upgrades to a new phone or reinstalls the app, you should provide them with UI functionality for restoring purchases. This allows them to regain access to any previously purchased content without paying again. But how can you create the capability and ensure it works across both iOS and Android?

In this article, we will explore what does restore purchase mean, how to configure it on iOS and Android, and the primary differences between them.

What does restore purchase mean?

The restore purchase capability is a functionality (most commonly seen as a “Restore Purchase” button) that enables app users to maintain access to subscriptions and other in-app purchases without going through the purchase process again. This mechanism allows your users to restore purchases manually.

Image description

This method is Apple’s recommended approach to restoring purchases. However, if you enable this automatically, your users will be shown a login screen that interrupts user flow – which is anything but user-friendly.

In case you have an internal authorization logic that allows you to manage access without prompt screens, you can avoid placing this “Restore Purchase” button. However, the restore button is still the most common practice. This button should trigger the specific Restore method, which will unlock the needed permissions for your users.

Cases for restoring purchase

Our recommendation is to have this button by default. Why? Having a restore purchase feature set by default could be useful for your user:

  • If the user has multiple devices signed in to the same account
  • If the user upgraded their device
  • If the user reset their device to factory settings
  • If the app was deleted and reinstalled on a device

What products could be restored?

There are 3 types of In-App Purchases that can be restored:

Non-consumables: a type that customers purchase once. They don’t expire.
Auto-renewable subscriptions: services or content that customers purchase once and renew automatically on a recurring basis until customers decide to cancel.
Non-renewing subscriptions: services or content provide access over a limited duration and don’t renew automatically. Customers can purchase them again.
Consumables purchases are not applicable for restoring as they are associated with the account. For example, if a user previously purchased “coins,” these purchases are connected to his account, and there is nothing to restore from StoreKit or Google Play Billing Library. To learn more about this process, check out our guide on how to set up consumable and non-consumable purchases.

How to configure restore purchases on iOS?

In most cases, restoring purchases on iOS only requires you to refresh the app receipt and redeliver the products listed on the receipt. The refreshed receipt contains a record of the user’s purchases in this app from any device the user’s account is logged into. To restore purchases, use native StoreKit methods. In this guide, we’ll explore the StoreKit method as the most commonly used. We are excited by the potential of StoreKit 2, so you can learn more details about it in this the following article.

Use SKPaymentQueue restoreCompletedTransactions() to restore non-consumables, non renewable, and auto-renewable subscriptions. StoreKit notifies the app’s transaction observer by calling paymentQueue(_:updatedTransactions:) with a transaction state of SKPaymentTransactionState.restored for each restored transaction. If restoring fails, see restoreCompletedTransactions() discussion for details on how to resolve it.

If you use Qonversion to manage your in-app subscription, call this method:

Qonversion.restore { (permissions, error) in
  if let error = error {
    // Handle error
  }
  if let permission: Qonversion.Permission = permissions["plus"], permission.isActive {
    // Restored and permission is active 
  }
}


Enter fullscreen mode Exit fullscreen mode

How to configure restore purchases on Android?

When compared to Apple, Google doesn’t have a specific process for restoring purchases. As Google mentions, the history of purchases is available in Google’s cache, so users receive all associated permissions automatically. From our experience, it would be better to consider restoring purchase flow, as Google’s cache could consist of unactual information or could be cleaned.

To restore Google’s purchases, use this method:

public abstract void queryPurchaseHistoryAsync (QueryPurchaseHistoryParams queryPurchaseHistoryParams, 
                PurchaseHistoryResponseListener listener).

Enter fullscreen mode Exit fullscreen mode

There you get the items that are purchased, and that`s it. Take note that Google returns just the last purchase from each Product.

If you use Qonversion to manage your in-app subscription, call this method:

`
Qonversion.restore { weak self in
if let error = error {
// Handle error
}

if let permission: Qonversion.Permission = permissions["plus"], permission.isActive {
// Restored and permission is active
}
}
`

Conclusion

In this article, we explored what does restore purchase mean and the flow on how to configure restore purchases on iOS and Android. By implementing this feature, you can help customers continue their paid services with ease – and keep positive user reviews coming!

Want to learn more? We know a thing or two about in-app purchases, as Qonversion provides a complete cross-platform infrastructure that allows you to create and restore purchases, validate receipts, and provide your app with an accurate subscription status without the need to build your server.

So if you’d like to learn more about it or have any questions, feel free to contact us anytime. We’d love to help you discover how to build better subscription experience with Qonversion!

Top comments (0)