[React native IAP implementation]
Hello! I’m implementing a redeem code button that will redeem discounted annual products in my app. The way i implemented to check it was add a purchasesListener when he clicks the redeem code button, the problem is I want to remove the listener when he goes from page A ( page with redeem code button ) to another page B ( meaning he did not reclaim the coupon ), or when he enters another specific page C in our app, that is se screen after the paywall if he did not claim any offer codes
I don’t know if I agree with the interface of this purchases listener. Having to pass a function reference when i add and when i remove means i have to keep track of this function reference in some sort of global store or do some workarounds only to keep the exact reference i used to remove…
Couldn’t the sdk accept a function and keep inside the sdk the reference to the function, making it immutable across app’s lifecycle?
I thought it this way
→ add purchasesListener ( callback )
→ Sdk keep it stored inside with it’s reference closed for change ( only overrides maybe )
→ I call remove purchasesListener ( no params )
→ Sdk see if there’s a function ref attached and remove it
I think this would be much cleaner and nicer to whomever is implementing using the sdk
Thanks for the answer in advance!