Question

Synchronise purchases made outside of the app (redempt ios offer codes via URL)

  • 28 February 2023
  • 4 replies
  • 89 views

Userlevel 1
Badge +2

Hello, we’ve recently implemented ios subscription offer codes, to give user a free trial for a certain amount of time. While testing the testflight version (ready to submit), and trying out those production offer codes, the user is redirected to the app store (https://www.revenuecat.com/docs/ios-subscription-offers) and purchases the subscription successfully...but when returning to the app it seams like RC does not catch that purchase and therefor user has no premium content access (I suppose RC does not receive the users track receipt and therefore can not send webhook for this event). We were being advised from your support to sync the user (call syncPurchases method before the user leaves the app and after the purchase (on foreground)), but I’ve came across the docs saying that we should not call sync purchases progammaticaly (

) so can you please expain how to use it the proper way inside our React Native app. thanks


4 replies

Userlevel 3
Badge +7

Hi,

We’ve updated our docs here on the recommended way to handle this, which is to call syncPurchases programmatically similar to what was mentioned in support.

When users click your link within your app to redeem the offer code, it will take them outside of the app to complete the purchase. It is important to call syncPurchases when the user returns back to your app to retrieve their purchase. This may be done by recording when the user leaves the app due to the link, and calling syncPurchases when the user returns to the app. If not, the user may need to trigger a restore within your app when they come back.

 

I didn’t see in the post you shared mentioned where it was mentioned not to call syncPurchases programmatically. However, we do mention that about restorePurchases,

The restorePurchases method should not be triggered programmatically, since it may cause OS level sign-in prompts to appear, and should only be called from some user interaction (e.g. tapping a "Restore" button.)

 

We also mention about syncPurchases that it is the way to programatically trigger a restore,

syncPurchases is a method we provide in our SDK which allows you to programmatically trigger a restore. This method, much like restorePurchases, reactivates any content that had previously been purchased from the same store account (Apple, Google, or Amazon).

 

(was a little lengthy here for those that may come later on)

Userlevel 1
Badge +2

https://www.revenuecat.com/docs/migrating-existing-subscriptions there is a section bellow that mentions this 

 

Userlevel 3
Badge +7

Thank you for pointing this out! This note was meant to discourage users from calling syncPurchases on every app launch for every app user when doing a migration. Calling it in the cases that a user leaves the app via offer code link and returns is perfectly fine, and the only alternative to having the user hit restore manually if the app does not pick it up.

Badge +4

Hello, this issue happened the same way here, with the difference that I was already calling sync purchases when the user returns to app due to the link, but that doesn’t seem to work… Is there a time to wait before calling sync purchases, so the method call actually returned nothing? 
If that’s the case, i should wait a few seconds before calling syncPurchases?

Or retry a couple times?

 

Thanks for the answer

Reply