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
[iOS] - purchaseUpdatedListener does not works properly #756
Comments
Honestly, I'm not quite sure how to overcome this issue. I hope you could further invest this and bring up workarounds to this problem. Or any future ideas would be helpful. |
I assume that something is not right with iOS native method, I'll wait for some fix/update for now. |
I am running into the same issue. The Edit: |
I've heard that this cause only in |
@hyochan So far only tested in sandbox. However, since removing async from |
@hyochan I did not tested on production, maybe you are right, because sandbox UI and production UI for iOS is different. @jeffreyvr I'm still stuck on listener |
I also encountered this issue... It seems like whatever I want to buy, be it a subscription or consumable product the listener only gets triggered on iOS on app relaunch. Mind you I only tested in Sandbox mode so far |
@TStupariu What helped me was that I was calling |
I saw that but unfortunately no, It's called in a regular componentDidMount (no async or other stuff). If I don't find anything the only thing left would be to test in a non-sandbox environment because I have no other ideas. |
If anyone is having this issue, at least in the case of one-time purchases here is what I found (I only had time to test those)... I had my listener registered in a componentDidMount and them I removed it on componentWillUnmount... I removed the bit of code that removes the listeners and now it seems to pick up purchases. My guess at least is that on iOS the modal for payment somehow sends the app in a background mode and forces the component to trigger an unmount (on iOS at least) and by doing that it made the listeners disconnect. |
@TStupariu Thanks for sharing this. This is very useful and I'll keep this in mind. |
Hey can you please help me out too. In my case the purchaseUpdatedListener is getting called in the Sandbox environment and in Production for some In App products it is getting called. Can you please suggest me what wrong I may be doing? I didn't implement any checks regarding the Sandbox and Production environment in the Code. The same code is getting executed for both the Environment. I am using |
I did not manage still anything new. Because differents behaviors of purchaseListener between Android and iOS I export IAP listeners from seperated file to the first component(Home) of my app. |
Hi @franj0 The component in which listeners are set up is unmounted only when the app gets closed. |
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. |
"react-native-iap": "^4.4.6" |
I am not sure if this would help, but when I faced the issue, even if the listener was on App.js it would still trigger an unmount. Try removing the code that removes the listener either way and see if that is the cause... |
Did some digging in native wrapper. Forgot to call RNIap.initConnection() which triggers listener flag. Should add this note on readme as others can get confused. Thanks for the reply :) |
Thanks @saminadhikari , none of the examples mentioned you need to call initConnection. Calling it before the request did the trick 👏 |
Added note about initConnection needed for listeners to work on iOS. Fixes issue: dooboolab-community#756 (comment)
I submitted a pull request with a note added to the readme about this. #1002 |
I'm calling initConnection() in my |
Added note about initConnection needed for listeners to work on iOS. Fixes issue: #756 (comment)
Does this happen if you don't call |
I'm still having this same issue. "react-native-iap": "^4.5.0",
This is not called on |
You'll need to call |
strange things are happening to me, I have added INIT.CONNECTION but now to the event IAP.PURCHASEUPDATELISTENER come in many times. What's going on? `useEffect(() => {
|
I have reproduced this issue recently. However, strangely this only happened in Closes for now. Feel free to update if there is anything new. |
I have just experienced this on a real device through testflight with sandbox.
the
|
The same is happening for me, any update on this one? |
Added note about initConnection needed for listeners to work on iOS. Fixes issue: dooboolab-community/react-native-iap#756 (comment)
I faced the same issue, and updating react-native-iap to the latest version didn't resolve it. Eventually, I refactored my useEffect, where I initialize RNIAP, by lifting it to a higher-level context (possibly a parent component). I stripped away all dependencies to ensure it triggers only once, and then I implemented proper cleanup for all listeners. This modification successfully resolved the issue for me. Here's the modified code:
|
Version of react-native-iap
v3.5.8
Version of react-native
react-native: 0.60.4
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
requestPurchase(string)
methodfinishTransactionIOS()
never calledthis.purchaseUpdateSubscription.remove()
purchaseUpdatedListener()
triggered and automatically call myApi andfinishTransactionIOS()
in callbackActual behavior
Call
requestPurchase(string)
methodUpdate listener triggered with my API to record purchase into my DB
iOS native alert says "You're all set", "Your purchase was successfull" but my API throw error and
finishTransaction()
Unmount component and call method
this.purchaseUpdateSubscription.remove()
Go back to component with products and there is no
purchaseUpdatedListener
logs to retry myApi and callfinishTransactionIOS()
in callback of myApiIf I kill and launch app again, mount component with products
purchaseUpdatedListener
is triggered and if myApi don't throw error everything works fine.On Android I don't have this issue,
purchaseUpdatedListener
is triggered on component mount and there is no need to kill and launch app again.Tested environment (Emulator? Real Device?)
real device - iPhone 8 iOS: 13.1.2
Steps to reproduce the behavior
The text was updated successfully, but these errors were encountered: