When the app is launched, checked if an non-consumable item has already been purchased previously.

Hi all, I think what I want to do is extremely common but interestingly I could not find a single solution on the web. Those I have found are mostly outdated. Ideally there would be some copy and paste ready to use code.

Thanks a lot!

This may help Unity - Manual: Restoring Transactions

I am using the latest UnityPurchasing module 1.14.1.
I am having the same problem: when the app starts and I initialize the store i would like to check if a non-consumable item is available or not (it was purchased in the past). If I attempt to use the product.hasReceipt in the OnInitialized() callback, on iOS the password prompt appears immediately if this is the first time the app is started on the device. This is not good user experience. I would like to query the store about the availability of this product without risking password prompts on first start of the app and hopefully in a way that behaves well in offline-mode too. Ideally i need to be able to distinguish between the following use cases by checking the non-consumable product metadata at app launch:

  • product has not been purchased by the current user
  • product has been purchased by the current user
  • product purchase is currently deferred (due to ask-to-buy feature on ios)
  • product purchase status is currently unavailable (due to device being in offline mode and no past information available for example)
  • product purchase is currently pending (because for example an app-store promotional IAP is in the process and ProcessPurchase will be called after initializing has completed)
  • (optionally) product purchase has been refunded/withdrawn

I would like to get this info without risking showing password prompts and without starting purchase restoration automatically.

Please advise what code to write in the OnInitialized callback to find out which of the above states a non-consumable in-app-purchase is

What state is the purchase in when you receive the initial popup? If the purchase was completed previously, the expectation is there should be no password prompt. I will review your other questions also.

@seventythreeers @MariaAngelovaPD

Unity IAP does not have any inventory management features. It is left to the developer to determine the best way to handle saving and checking for existing purchases.