React-native-iap: Cannot connect to iTunes store

Created on 12 Dec 2019  ·  11Comments  ·  Source: dooboolab/react-native-iap

Version of react-native-iap

4.3.0

Version of react-native

0.61.5

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

iOS 13 and later

Expected behavior

It should go for purchase or restore the product but it is getting error.
Code:
try{
const purchases = await RNIap.getAvailablePurchases();
if (purchases && purchases.length > 0) {
this.setState({isLoading: false});
Alert.alert('Restore Successful');
}else{
this.requestPurchase(itemSku);
}
}catch(err){
Alert.alert(err.message);
}
After this it's going to catch with error "E_UNKNOWN Cannot connect to iTunes Store" while user did not clicked any option.

Tested environment (Emulator? Real Device?)

I tested on both and behavior is same.

AppStore Review

We found that your in-app purchase products exhibited one or more bugs when reviewed on iPad running iOS 13.2.3 on Wi-Fi.

Specifically, an error message was displayed when we attempted to purchase.

Next Steps

When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code "Sandbox receipt used in production," you should validate against the test environment instead.

Resources

You can learn more about testing in-app purchase products in your development sandbox environment in App Store Connect Developer Help.

For more information on receipt validation, please see What url should I use to verify my receipt? in the In-App Purchase FAQ.

Learn how to generate a receipt validation code in App Store Connect Developer Help.

Please see attached screenshot for details.
Screen Shot 2019-12-13 at 2 27 06 AM

📱 iOS 🙏 help wanted 🚶🏻 stale

All 11 comments

same issue...

same, anyone solved?

I resolved this issue

I resolved this issue

How, can you share ?

There's nothing really to solve here. It's a notification that the User canceled.
Change your error listener to check for that code (E_USER_CANCELLED) and if it is returned, don't activate the subscription or provide the service and then let it fail quietly.

If you had not made any state changes in the purchase call, just add this:

if (error.code === "E_USER_CANCELLED") { return; }

as the first line of the listener's call block. That will just simply return back to the screen they were on. If you need to make changes to the state first, then instead of return; use something like this

if (error.code === "E_USER_CANCELLED") { 
  this.setState({ subscription: undefined, userCancelled: true, whateverElse: 'completed' }, () => { return; });

+1 - also experiencing this issue.

There's nothing really to solve here. It's a notification that the User canceled.
Change your error listener to check for that code (E_USER_CANCELLED) and if it is returned, don't activate the subscription or provide the service and then let it fail quietly.

That's not the code in his original post.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

This problem sandbox user only run Testflight app. I tested my app on testfligt. its working.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

We see this error consistently in tesflight but intermittently on production. Anyone find any solutions?

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings