react-native-iap: restoring purchase made with redeem code doesn't work on IPhone SE, works on others

Version of react-native-iap

1.3.6

Platforms you faced the error (IOS or Android or both?)

IOS

Expected behavior

Redeeming purchases would work

Actual behavior

Redeeming purchases don’t work

Tested environment (Emulator? Real Device?)

Real device, IPhone SE

Steps to reproduce the behavior

This is the relevant code I’m using to update product bought status:

    async initPurchasesIfNeeded() {
        if (this.state.iapInitialized) {
          return new Promise((resolve, reject) => resolve(true));
        }
        console.info('initializing iap connection');
        await RNIap.prepare()
          .then(() => {
            this.setState({iapInitialized: true});
            console.info('iap connection initialized');
            return new Promise((resolve, reject) => resolve(true));
          })
          .catch(err => console.error(err))
    }

    async updateProductBoughtStatus(albumId) {
        try {

            console.info('preparing products...');

            await this.initPurchasesIfNeeded();
            console.info('fetching products...');

            const products = await RNIap.getProducts(itemSkus);
            console.debug('got products: ' + JSON.stringify(products));

            products.forEach((product) => {
                if (product.productId === albumId) {
                    this.setState({albumPrice: product.localizedPrice});
                }
            });

            const boughtItems = await RNIap.getAvailablePurchases();
            console.debug('got bought items: ' + JSON.stringify(boughtItems));
            boughtItems.forEach((boughtItem) => {
            if (albumId === boughtItem.productId) {
                if (!this.state.albumBought)
                    this.setState({albumBought: true});

                this.setState({showRestorePurchases: false});
            }
            });
            if (!this.isEmpty(boughtItems)) {
                // store status in async storage
            }
        } catch (err) {
            console.warn(err);
        } finally {
            this.setState({albumState: albums});
        }
    }

This seems to work for android & ios, in sandbox and in production. However, in production we’ve started getting complaints from people using IPhone SE that when after they redeem their promo code for their iap, the status will not update to reflect that. Indeed, when I found an IPhone SE to play with, this seems to be the case. However, for all other iphones I’ve tested - for example IPhone 6, which is of older generation than IPhone SE - things seem to work fine. Any idea what could be wrong? This seems to be really hard to debug, as even for IPhone SE sandbox testing with purchases seems to work ok. However, there are no iap promo codes in sandbox, so I can’t test that specifically, and I can’t really debug the released production version either.

Updating OS version doesn’t seem to have any effect, the problem occurred with 11.4.1 as well as after updating to 12.0.1.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I can confirm that 65cea1e0df96d7bcf44646f1125190b83ea7546e didn’t fix this issue. User still failed to restore purchase redeemed via promo code on iPhone SE. @eis @JVallius @joshbalfour can you confirm the same too?

@eis I’ve just updated this in 2.3.15. You may try this and please reopen when this is still occuring. I will close this for now. Thank you for the hard test by the way.

Currently, I prefer you to use 2.2.2 because we are solving buySubscription regression issue in 2.3.*.