Solved

A little lost when it comes to restoring anonymous purchases

  • 16 January 2024
  • 2 replies
  • 81 views

Badge +2

I am a little lost here and could use some pointers/help.  I have a Flutter application which has Ads in it. I have no concept of a “user” in my app. I would like to add the ability to remove Ads. I created all the required store setup for both Google and Android.  I’ve added a button in my app to purchase the product I setup (I have only the one product) to remove Ads.  This all works as expected on both Android and iOS.  

 

I need to implement the “restore” capability in my app per the Apple App Store requirements.  I have questions as I can’t seem to figure out exactly how to do this.

  1. Since I use anonymous accounts wouldn’t the user, upon removal of the app and reinstallation get a new anonymous ID?  If so, how does the system know they already purchased my product?
  2. How is this done typically, should I show both a Purchase and a Restore option in the app?  Seems like there should be a way to ‘detect’ that the user already made a purchase and if so provide the ‘restore’ option...and if not then provide the ‘purchase’ option.
  3. From the docs Restoring Purchases (revenuecat.com) it appears I just call the following, then check to see if the entitlement isActive, is that correct?

CustomerInfo customerInfo = await Purchases.restorePurchases();

 

 

 

icon

Best answer by Haley Pace 20 January 2024, 03:19

View original

2 replies

Badge +2

Is it as simple as calling that API and that’s all?  On Android I believe that when I tried calling the purchase API it knew that the user already had bought and asked if they wanted to restore their purchase. Maybe that was iOS?? I’ve done so much testing the last few days it’s a blur :) Just need to get this last requirement done to get the update in the iOS store. Can anyone help?

Userlevel 4
Badge +8

Hi,

  1. Since I use anonymous accounts wouldn’t the user, upon removal of the app and reinstallation get a new anonymous ID?  If so, how does the system know they already purchased my product?

Yes, that is correct. If you are not configuring with a custom id, then an anonymous id will be assigned to the user. And if the user deletes and reinstalls the app, this will generate a new anonymous id for them. Upon calling restore purchases, the underlying store account being used will be checked to see if purchases were made for your app, and if there were then access to those will be restored.

 

  1. How is this done typically, should I show both a Purchase and a Restore option in the app?  Seems like there should be a way to ‘detect’ that the user already made a purchase and if so provide the ‘restore’ option...and if not then provide the ‘purchase’ option.

You can provide both buttons. Our API does not have a way to identify the underlying store account of the user, but if they try to repurchase the same product they already own, the underlying store will automatically restore purchases.

Another thing you could do is call syncPurchases() after configure() to automatically do this for users. Then you can check their CustomerInfo object to see if they have purchases and choose to display buttons accordingly.

https://www.revenuecat.com/docs/customer-info

https://www.revenuecat.com/docs/restoring-purchases#syncing-purchases-without-user-interaction

 

  1. From the docs Restoring Purchases (revenuecat.com) it appears I just call the following, then check to see if the entitlement isActive, is that correct?

CustomerInfo customerInfo = await Purchases.restorePurchases();

Yes, you’ll want to call Purchases.restorePurchases() after the user presses the ‘Restore Purchases’ button. Then you can check the user’s CustomerInfo for the entitlement.

 

Reply