Question

originalPurchaseDate nil in production environment.

  • 23 November 2023
  • 4 replies
  • 43 views

Badge +5

I’m using the following code to set originalPurchaseDate:
 

Purchases.shared.getCustomerInfo { info, error in

            if let error = error {

                print(error)

                return

            }

            if let date = info?.originalPurchaseDate {

                UserDefaults.standard.originalPurchaseDate = date

            }

        }
However I noticed `info?.originalPurchaseDate` is nil (either the info or originalPurchaseDate) in production. (I extracted UserDefaults on my JB device, the app is installed from the AppStore and I can see the StoreKit/receipt is present as expected)
In the debug build the info (CustomerInfo) is not nil, but as expected the `originalPurchaseDate` is not available.

What could be the problem?
I want to use this code in my second app which I’m moving from the paid-upfront to freemium, but it seems I might not be able to use it.
Thank you.


4 replies

Userlevel 5
Badge +9

Hey @boramaapps,

That property requires you to send the receipt to RevenueCat. You can do this by calling syncPurchases or any of the purchase methods.

Alternatively you can use our receipt parsing library to read the receipt on the device.

Badge +5

Thank you.

Do you also provide a way to get the data from the device and from AppStore (if needed)?
 

Badge +5

It looks like the library you provide don’t have the originalPurchaseDate value. 

Userlevel 5
Badge +9

Hi @boramaapps sorry about that, you’re correct. I’ll pass this feedback to the team. In this case the only way to get the original purchase date is by sending the receipt to RevenueCat using syncPurchases, restorePurchases, purchasePackage, or purchaseProduct. 

Reply