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

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

Closed
eis opened this issue Oct 17, 2018 · 20 comments
Closed
Labels
📱 iOS Related to iOS

Comments

@eis
Copy link

eis commented Oct 17, 2018

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.

@hyochan hyochan added the 📱 iOS Related to iOS label Oct 17, 2018
@hyochan
Copy link
Member

hyochan commented Oct 17, 2018

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

@eis
Copy link
Author

eis commented Oct 17, 2018

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

@hyochan
Copy link
Member

hyochan commented Oct 18, 2018

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

@JVallius
Copy link

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

@hyochan
Copy link
Member

hyochan commented Oct 24, 2018

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

@hyochan
Copy link
Member

hyochan commented Oct 24, 2018

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

@eis
Copy link
Author

eis commented Oct 24, 2018

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

@eis
Copy link
Author

eis commented Oct 24, 2018

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

@hyochan
Copy link
Member

hyochan commented Oct 24, 2018

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

hyochan added a commit that referenced this issue Oct 24, 2018
By changing mutable array.
@hyochan
Copy link
Member

hyochan commented 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.

@hyochan hyochan closed this as completed Oct 24, 2018
@mars-lan
Copy link
Contributor

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

@hyochan hyochan reopened this Oct 30, 2018
@hyochan
Copy link
Member

hyochan commented Nov 6, 2018

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?

@mars-lan
Copy link
Contributor

mars-lan commented Nov 7, 2018

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.

@eis
Copy link
Author

eis commented Nov 7, 2018

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

@eis
Copy link
Author

eis commented Nov 7, 2018

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.

@JVallius
Copy link

JVallius commented Nov 7, 2018

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.

@joshbalfour
Copy link

i am also seeing this in production on an iPhone X

@hyochan
Copy link
Member

hyochan commented Dec 15, 2018

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

hyochan referenced this issue Dec 15, 2018
Changes not made.
hyochan added a commit that referenced this issue Dec 15, 2018
Change has not been made previously.
@mars-lan
Copy link
Contributor

mars-lan commented Jan 3, 2019

I can confirm that 65cea1e 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?

@impaler
Copy link

impaler commented Mar 2, 2019

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

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

No branches or pull requests

6 participants