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

RNIap.requestPurchase is not responding in iOS #1005

Closed
emreakbaba opened this issue May 13, 2020 · 14 comments
Closed

RNIap.requestPurchase is not responding in iOS #1005

emreakbaba opened this issue May 13, 2020 · 14 comments
Labels

Comments

@emreakbaba
Copy link

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>)
@Panda313
Copy link

Same here, however it seems to work on Android.

@Panda313
Copy link

Panda313 commented 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

@smarttouchtechnology
Copy link

smarttouchtechnology commented May 17, 2020

@hyochan Have you found a resolution to this? I am also experiencing the same problem in iOS. Its extremely frustrating, and I can't get past app review because calling RNIap.requestPurchase doesn't respond with the alert either promoting the user to agree to the subscription terms or confirming that the subscription is already active. If I force close the app and try it again, sometimes it works. I don't know if there is a problem with the sandbox or this library.

@hyochan
Copy link
Member

hyochan commented May 20, 2020

@smarttouchtechnology Have you called initConnection? This is needed from 4.4.5.

@Panda313
Copy link

It may be hard for @smarttouchtechnology to read the answer below that "solve" the "problem" ;)

@thaneros
Copy link

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

@Oguntoye
Copy link

Oguntoye commented Jul 7, 2020

@Panda313 ... You just saved me1 week sleepless night of apple rejection

@danleveille
Copy link

danleveille commented Aug 27, 2020

Could someone add this to the documentation so more people don't run into this issue? I'm not sure the best way to add it.

EDIT: Added here. #1088.

Feel free to review (I'm not confident I did it right.)

@EvgeniiKlepilin
Copy link

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

For iOS, I didn't have any response from requestSubscription. I tried adding await RNIap.initConnection(); in front of RNIap.requestSubscription and it worked for me. Now I am receiving purchase objects in listeners in the root of the app. And it also proceeds further down the code after it resolves either in error or in successful response.

@stale
Copy link

stale bot commented Dec 19, 2020

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.

@stale stale bot added the 🚶🏻 stale Stale label Dec 19, 2020
@stale
Copy link

stale bot commented Jan 19, 2021

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jan 19, 2021
@messycoding
Copy link

I am experiencing this right now but the scenario is . . I tried purchasing in a different account in my app when there is an active subscription so calling requestPurchase when there is active subscription seems an issue. I am expecting to have a return like an error.

@Mihai-github
Copy link

Hi... I have the same problem with apple pay... yesterday worked really nice got everything to work from fetching the products to getting the purchase history and validating the latest receipt and today for some kind of reason won't appear any more and there is no error or anything when calling requestPurchase..

RNIap.requestPurchase(resp[0].productId)
.then((purchase: any) => {
     alert(1);
     console.log({purchase});
})
   .catch((errorPurchase: any) => {
     alert(2);
     console.log({errorPurchase});
});

The then function never gets executed but also the catch never does... Any idea why?

@homiis
Copy link

homiis commented Aug 14, 2023

@Mihai-github We are experiencing this issue too. How did you fix?

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

No branches or pull requests