chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
890 stars 185 forks source link

SKPaymentTransactionStatePurchased on launch are discarded #113

Closed vafada closed 3 years ago

vafada commented 7 years ago

I'm doing Auto-Renew Subscription and in sandbox, Apple auto renew every 5 minutes for 6 times. when i close my app and reopen within that 30 minute window. i get a warning No callback registered for transaction with state purchased. (https://github.com/chirag04/react-native-in-app-utils/blob/master/InAppUtils/InAppUtils.m#L59) which make sense because there is no callback tied to that product id since this was invoked in the background.

The app shouldn't be discarding these transactions. Maybe put them in some cache and export a method to retrieve and flush this cache.

chirag04 commented 7 years ago

i have not done auto renewable subscriptions but this is one more example of why the callback api is not the right way to go.

ideally we should have an event driven api like something like:

inapputils.addListener('purchased', function cb(productId) {
 // unlock store etc here.
});

This is going to be a major breaking change but i think that's the way forward.

superandrew213 commented 6 years ago

@chirag04 we can keep the callback api and add event api too.

I think the issue is with calling addTransactionObserver in objective c init. User should call this in js code as early as possible. This is needed for both callback & event api.