Please provide the following:
- SDK Version: 40
- Platforms(Android/iOS/web/all): Android and iOS
I have an App in Expo (SDK 40) migrated from SDK 36, in Bare worflow, because I’m using a library for InAppPurchases (InAppPurchases - Expo Documentation). For navigation I’m using react-navigation.
In SDK36 the library for InApp Purchases was very simple to implement. Just a function to purchase, with a callback to do the transaction functions and enable the things that user just bought.
in SDK40, the library InApp Purchases is a little bit more complicated. I have to define a setPurchaseListener defined in the global scope (for me works defined in App.js), so, in the screen when the purchase is made, we do:
- PurchaseScreen: we call purchaseItemAsync(sku). if is done, will call setPurchaseListener
- App.js: is defined setPurchaseListener(responseCode, results, errorCode), so if purchase is done this will be called, and all things to unlock is declared here (previously in SDK36 this was on PurchaseScreen) / I tried def the function in purchaseItemAsync too but not work.
- App.js → PurchaseScreen: I need to call a function defined in PurchaseScreen to unlock the things user’s purchased, but from App.js
I think I can solve using Mobx, I created a store shared for both, but, how can I execute the function in PurchaseScreen?
Thanks very much for your help