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.requestPurchase is not responding in iOS

See original GitHub issue

Version of react-native-iap

4.4.8

Version of react-native

0.61.5

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

iOS

Expected behavior

await RNIap.requestPurchase(sku, false)
console.log('REQUEST OVER') 

REQUEST OVER to be printed.

Actual behavior

In device i use sandbox tester account, it is responding and working well. But with any other devices or simulator it is not responding or resolving. This is vital since during app review, Apple keep rejecting my application with reason of tapping in BUY is not responding.

There is no problem about RNIap.getProducts(itemSkus)

Tested environment (Emulator? Real Device?)

Real Device and Simulator

Steps to reproduce the behavior

 async componentDidMount() {
    RNIap.getProducts(itemSkus)
      .then((products) => {
        this.setState({ products: products })
      })
      .catch((error) => {
        console.log(error.message)
      })
  }
requestPurchase = async (sku) => {
    try {
      await RNIap.requestPurchase(sku, false)
      console.log('REQUESTED OVER')
    } catch (err) {
      console.warn(err.code, err.message)
    }
}

render() {
 const { products } = this.state
 return (
  <View>
    {products.map((p, i) => { return (
       <TouchableWithoutFeedback onPress={() => this.requestPurchase(p.productId)}>
          <Text> BUY </Text>
       </TouchableWithoutFeedback> ) })}
 </View>)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
thaneroscommented, Jun 9, 2020

I had the same problem and @Panda313 suggestion to add await RNIap.initConnection() in componentDidMount worked. Too bad this is not better documented…

4reactions
Panda313commented, May 15, 2020

I may have fixed it by adding

const result = await RNIap.initConnection(); await RNIap.consumeAllItemsAndroid(); console.log(‘result’, result);

At the begining of componentDidMount ;

Let me know if that help

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to call back for purchased products ?IAP for React ...
We are requesting to## Heading ## purchase a product and able to purchase the product but not receving any product purchase call back....
Read more >
react-native-iap - npm
This react-native module will help you access the In-app purchases capabilities of your phone on the Android , iOS platforms and the Amazon ......
Read more >
React Native : Subscriptions, In-App Purchases & Service ...
First thing you should do is to define your items for iOS and Android separately like defined below. import * as RNIap from...
Read more >
React Native IAP - Javatpoint
React-native-app provides the basic features we need but is not a ... Then follow the instructions below, depending on the platform you're working...
Read more >
How to use the react-native-iap.requestPurchase function in ...
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
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