react-native-iap: purchaseUpdatedListener called only once on app start, and never calls after requestSubscription call
Version of react-native-iap
4.4.6
Version of react-native
0.61.5
Platforms you faced the error (IOS or Android or both?)
ios
Expected behavior
purchaseUpdatedListener called on each time, after requestSubscription call
Actual behavior
purchaseUpdatedListener called only once on app start, and never calls after requestSubscription call
Tested environment (Emulator? Real Device?)
Real Device
Steps to reproduce the behavior
Just follow readme and try to request subscription
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 25 (4 by maintainers)
Had the same issue as I didn’t add the
initConnection()call. The README seems to be just updated with the bold part here:I think this part “On iOS, it will simply call canMakePayments” should be removed, also
initConnection()should be added to the basic exampleI was really convinced it was optional because it wasn’t in the example
Adding the
initConnection()before registering the purchase listener/s fixed this for me, so this is probably related to #1002 and #756I had the same issue for a few days with RN 0.62.2 and react-native-iap 4.4.8 I somehow missed the
initConnection()probably because it is missing from the example in the READMEIf I may add,
4.3.4through4.4.3work fine, the problem begins in4.4.4Glad it helped. We have this in production since June. It did change from Observable to this at some point (we’re not using typescript)
@Sophrinix I’ve just tried
requestPurchasein my side and everything seems to be working. Could you please share some of your code?Also, please check again if you’ve called
initConnection. This is critical changes in a recent update that it is now necessary to be called iniOSas inandroid.I’m on 4.4.9 and the issue described by this ticket is happening to me as well. The listener is only invoked when started, but if I set it and then perform the purchase, it is not called. I solved it by subscribing to the native event directly, after looking at
react-native-iap/index.tsand figuring out that’s what happens internally. This can be done at any time and will persist. (Just make sure it’s done only once)I confirm that reverting to 4.3.0 works. I was going nuts with the latest version, I’ve been debugging for over 1h trying to find the issue.