Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Products owned status changes on IOS Ionic Capacitor Live reload #1562

Open
studentrk opened this issue Apr 24, 2024 · 1 comment
Open

Products owned status changes on IOS Ionic Capacitor Live reload #1562

studentrk opened this issue Apr 24, 2024 · 1 comment

Comments

@studentrk
Copy link

studentrk commented Apr 24, 2024

Observed behavior

Using live reload:

  1. app starts
  2. buy a non-consumable product
  3. the owned status of non-consumable product changes to true
  4. make code changes, save them and the app gets reloaded
  5. all products from CdvPurchase.store.products have the owned status as false

When employing live reload with Ionic on iOS, purchasing a non-consumable product, making code changes, and triggering app restart, the CdvPurchase.store.products function returns all products as not owned. However, upon calling restorePurchases, the purchases are accurately restored. It appears that not all plugin code is reloaded during live reload, and the paymentQueue function is not executed again after the reload.

This issue doesn't require immediate fixing but might be beneficial to document.

Expected behavior

During live reload, purchasing a non-consumable product should retain its owned status even after recompilation.

Simple workaround

  1. app starts
  2. buy a non-consumable product
  3. the owned status of non-consumable product changes to true
  4. make code changes, save them and the app gets reloaded
  5. all products from CdvPurchase.store.products have the owned status as false
  6. close app and restart app --> this does set the correct status again
@j3k0
Copy link
Owner

j3k0 commented May 1, 2024

I believe thought that this would work if receipt validation is setup (is it your case?). Calling "initialize" should trigger a receipt validation call that'll make the plugin aware of non-consumable purchases (and subscriptions). Without receipt validation, on iOS, purchases won't be reported again.

That could potentially be fixed by keeping a cache of transactions on the native side, but could create other issues (like a reload after switching AppStore account would report incorrect transactions, other side effects maybe?).

Not sure how important that is, notice that in debug you could probably work with "TEST" products, that will work across reloads (because they're pure JS) -- cf https://github.com/j3k0/cordova-plugin-purchase/wiki/v13-reference:-Test-Adapter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants