question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

restoring purchase made with redeem code doesn't work on IPhone SE, works on others

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
mars-lancommented, Jan 3, 2019

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?

1reaction
hyochancommented, Oct 24, 2018

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

If you can't find or use your in-app purchases - Apple Support
Restore your in-app purchases · Open the app that you used to buy the item. · Look for an option to restore. You...
Read more >
Restore purchased and deleted items to iPhone - Apple Support
You can download previously purchased items to iPhone, and you can recover recently deleted mail, photos, notes, and voice memos.
Read more >
Restore Purchase not Working | Apple Developer Forums
I've tested restoring purchases with a StorekitConfiguration in development, along with my own personal Apple ID in production and it works. The problem...
Read more >
If you can't redeem your Apple Gift Card or App Store & iTunes ...
If you see a message that says the code must be redeemed in another storefront, the card was probably purchased in another country...
Read more >
Problems and their solutions for Apple Pay, Apple Card, and ...
You can't redeem or return Apple Gift Cards, App Store & iTunes Gift Cards, or unused Apple ID balance for cash, except as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found