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

Created on 17 Oct 2018  路  20Comments  路  Source: dooboolab/react-native-iap

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.

馃摫 iOS

All 20 comments

@eis 1.3.6 is an quite old version. Please update our module and comeback.

@eis 1.3.6 is an quite old version. Please update our module and comeback.

@dooboolab which version can I upgrade to? Current version has issue #279 and 2.2.2, the one working before that has issue #287, both no-go issues. I can't break existing purchase functionality.

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

I have same problem with iPhone 5s. In production environment, RNIap.getAvailablePurchases() returns an empty array when using iPhone 5s, sandbox works fine. On iPhone 7 purchase can be restored without problems in production. I'm using react-native-iap version 2.3.1

@JVallius If it works fine in production. I think it is a config problem that relies on your apple account. Try use different account for sandbox user and production user.

Also I prefer you guys to use 2.3.14 which regression issue is solved today.

@JVallius If it works fine in production. I think it is a config problem that relies on your apple account. Try use different account for sandbox user and production user.

We are of course using different accounts for sandbox (testing) and prod, it is not possible even to do any other way. But the point is this:

| Environment | Product | Result |
| ------------- |:-------------:| -----:|
| sandbox | iphone 6 | works |
| production | iphone 6 | works |
| sandbox | iphone SE | works |
| production | iphone SE | doesn't work |
| sandbox | iphone 7 | works |
| production | iphone 7 | works |
| sandbox | iphone 5s | works |
| production | iphone 5s | doesn't work |

This has been tested with >20 devices (with 4 of them being iphone SE devices), so something seems to be wrong with using some of the older iphone models and production - in sandbox it seems to work.

But haven't yet upgraded the library, will try that next.

@eis Ok it sounds like concurrent with issue in flutter_inapp_purchase. I feel this happens cause of fragile support on the NSDictionary which I might have to handle different way. Let me try this and comeback.

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

@dooboolab I can confirm that this is still happening for 2.3.17. Please re-open the issue.

This is strange because I've heard the fixes in flutter_inapp-purchase providing same solution. @mars-lan Could you provide in which line of code this is occurring? @JVallius @eis Could you also confirm this?

I too were unable to reproduce this reliably. That said, two of our users have already reported the exact same issue in production so I suspect it's still not fixed.

@dooboolab unfortunately we're having currently an unrelated issue which is getting our app rejected in app store review, so have been unable to test. Will come back to report once we get it resolved.

Note though that like I wrote in the initial message,

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.

so if the fix was related to OS version like in the description of the issue you linked, it might be something different.

Yes I can confirm that this strange problem is still here. I implemented a custom logging system for my app to see debug messages in production environment, here are the results.

When I'm trying to restore a purchase, the _RNIap.getProducts(itemSkus)_ method returns a correct in-app product from Apple. But next, when calling _RNIap.getAvailablePurchases()_ method, the return value is an empty array. The product is redeemed by a code and is visible in App Store. Using iPhone 5s.

await RNIap.clearTransaction()
await RNIap.clearProducts()
var products = await RNIap.getProducts(itemSkus); // returns a correct product
var purchases = await RNIap.getAvailablePurchases(); // returns an empty array

I'll try to get logs about what will happen if I'm trying to make an actual purchase.

i am also seeing this in production on an iPhone X

@eis @mars-lan I've been experimenting this issue today, and found one missing changes when fetching products. Please install 2.3.23 and try again. Feel free to reopen when still facing the issue.

P.S. Strangely, last time when I edite my code in RNIapExample project, it applied well but currently it isn't. The changes not applied to 2.3.22 so I re-published to 2.3.33. Please try 2.3.33.

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?

Also seeing this issue with redeem codes failing to restore purchases on 2.3.23.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iutin picture iutin  路  4Comments

safciplak picture safciplak  路  3Comments

coldfins picture coldfins  路  3Comments

sanilcgs picture sanilcgs  路  3Comments

jvandenaardweg picture jvandenaardweg  路  4Comments