Solved

Using `syncPurchases` for automatic restoring

  • 19 January 2023
  • 2 replies
  • 31 views

Badge +3
  • New Member
  • 4 replies

Hello,

 

In my iOS app the user IDs are RCAnonymousIDs since there’s no sign up to purchase a subscription. Since there’s no sign-up, when they install the app on a new device they have a new RCAnonymousID and they do not have immediate access to their subscription.

 

There’s a restorePurchase button, but would like to have an automatic restoring purchase feature on a fresh install. I read through a similar question in this community (link) and it seems like calling `syncPurchases` on a fresh app install will do the trick.

 

My only hesitiation of using it is if there will be an Apple ID sign-in alert if there’s no receipt on the device? I had a similar issue to this when implementing `checkTrialOrIntroductoryPriceEligibility` awhile ago (link) and want to make sure it just returns silently if there’s no receipt.

 

Any help is greatly appreciated and thank you in advance!

icon

Best answer by kaitlin 20 January 2023, 21:43

View original

2 replies

Userlevel 1
Badge +3

Hi @fra !

The main difference between syncPurchases and restorePurchases is how they react when there is not a receipt on the device. syncPurchases will fail silently, while restorePurchases could trigger a log in and then refresh the receipt from the store. 

Additionally, .syncPurchases unfortunately won’t work at fresh app install on a new device for anonymous ids - for custom ids, it will work like a restore, but for anonymous ids, it just syncs the receipt on the device. So if there is not a receipt on the device, it definitely won’t work (still silently).

It sounds like you already have a restore purchases button, so that’s a great start. Your anonymous id users may still need to utilize it even after .syncPurchases is called for them.

Let me know if you have any more questions - these two methods can be a little confusing!

Badge +3

Hi @kaitlin

 

Thank you for the quick response! This just saved me (and hopefully other devs who use anonymous ids) a lot of time!

Reply