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.

RNIap.getProducts not returning promise on ios

See original GitHub issue

Version of react-native-iap

“react-native-iap”: “^2.3.25”

Version of react-native

“react-native”: “0.57.4”,

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

IOS

Expected behavior

buyProduct should return promise ( .then() is not call ),

Actual behavior

buyProduct not returning any promise, in android its working fine, .then() call successfully, but in ios its not.

Tested environment (Emulator? Real Device?)

Real Device

Steps to reproduce the behavior

onBuyNowPress() {
    this.setState({ loading: true });
    RNIap.getProducts(['product_id']).then(success => { 
       RNIap.buyProduct('product_id').then(purchase => { 
        console.log("Purchase >>", purchase)
        this.setState({
          loading: false,
          receipt: purchase.transactionReceipt, 
        });
        Alert.alert('Purchase Successful!');
        this.props.getPurchase();
       }).catch(err => { 
         console.log(err.code, err.message);
          this.setState({ loading: false });
          Alert.alert(err.message);
          if(err.message === "You already own this item.") {
            this.props.getPurchase();
          }
        }) 
      }).catch(error => { 
        alert(error); 
        this.setState({ loading: false });
      })
  }

In ios i already buy product, so again when i press buy now, i get popup like you already purchase this product. but .then() or .catch() not getting call.

i also tried getAvailablePurchases() method, its always return []

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
ZeroCool00commented, Dec 29, 2018

@hyochan i finally solved the issue… problem is when i first test i didnt write this line await RNIap.finishTransaction(); in .then() method. i added it afterward. that was the problem, solution is i need to clear transaction(await RNIap.clearTransaction();), and it work.

Thanks again for your support n for this great library.

3reactions
hyochancommented, Dec 27, 2018

Could you try 2.4.0-beta4?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-iap - npm
Promise <Subscription[]>, Get a list of subscriptions. Note: With before iOS 11.2 , this method will also return products if they are ...
Read more >
react-native-iap getProducts return empty array - Stack Overflow
For those facing this issue with iOS, make sure you finalise the agreements and tax, then make sure to copy and paste this...
Read more >
React Native : Subscriptions, In-App Purchases & Service ...
Configure in-app purchase on iTunes Connect (for iOS) ... I've decided to redesign the Purchase Flow to not rely on Promise or Callback...
Read more >
RNIap is not working on Android but works in iOS with same ...
getProducts () printed in terminal. Actual behavior Promise is not returned. Error 'billing is not available'. Tested environment (Emulator? Real Device?)
Read more >
React-native-iap-badoo NPM | npm.io
In iOS, it will simply call canMakePayments method and return value. getProducts, string[] Product IDs/skus, Promise<Product[]>, Get a list of products ...
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