-
-
Notifications
You must be signed in to change notification settings - Fork 656
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
Better StoreKit
flow.
#423
Comments
@Edgpaez I think I can just remove Would this be enough? |
@Edgpaez Actually you were right. Today, I just reviewed |
Hi guys, thanks for this great discussion? any update on this, we are experiencing the same issue mentioned in #307 pretty bad user experience, I would contribute but have no experience in ios native language whatsoever :( |
@cayasso Currently, this discussion is about |
Hi @hyochan, I'll be happy to take a look. I think your proposal: RNIap.buyProduct('com.example.coins100');
RNIap.buyProduct('com.example.coins200');
// receiving events
const subs = RNIap.purchaseStatusListener(purchase => {
...
}); might be easier to reason about without prior experience in Rx. So I'll try to implement it. AFAICT, we only need JS changes since @cayasso: you can use the flow described here. No need to wait for the change in the API |
I see we are trying to move away from finishTransaction and clearTransaction, which is fine, we could simplify that logic, but we need to be more strict when we finish transactions. In my opinion, we can only finish a successful purchase transaction when client side (JS) has acknownledged that it received & processed it. This flow is incorrect:
There could be multiple scenarios where this code can miss successful purchases and not credit user account. Having addAdditionalSuccessPurchaseListenerIOS there for sure minimizes that chance, but you still need to "re-play" the transaction queue when a new listener is added. The correct flow would be:
Of course you don't need to leak StoreKit concepts in to this, you can always simplify it further, but the point is, a client is going to be the one who will decide if we de-queue the transactions or not, otherwise there will be scenarios where we will miss the successful purchase transactions. For example, this could be a idea:
Note; all the transaction queue has to be "re-played" against RNIap.addAdditionalSuccessPurchaseListenerIOS when someone actually subscribes to it, so he wouldn't miss old successful transactions.
So essentially these are the changes I propose (I Have no Swift experience, but can stitch something together if it makes sense):
and
The transaction queue should be accessible for all the consumers, especially since it is possible to for example, downgrade or upgrade the subscription plan. (In which case I believe transaction queue will have more events in it?) |
The suggestion in the README: try {
// Will return a purchase object with a receipt which can be used to validate on your server.
const purchase = await RNIap.buyProduct('com.example.coins100');
this.setState({
receipt: purchase.transactionReceipt, // save the receipt if you need it, whether locally, or to your server.
});
} catch(err) {
// standardized err.code and err.message available
console.warn(err.code, err.message);
const subscription = RNIap.addAdditionalSuccessPurchaseListenerIOS(async (purchase) => {
this.setState({ receipt: purchase.transactionReceipt }, () => this.goToNext());
subscription.remove();
});
} doesn't look right. When the user cancels the purchase (user decided not to buy), StoreKit throws a paymentCancelled error In this scenario, the flow will enter the Here are more details about this StoreKit flow: chirag04/react-native-in-app-utils#202 (comment) Maybe we can get an idea how to solve this issue from @superandrew213 fork: |
@vafada Wow that is a good point we should handle this. Actually, I'm really thinking of redesigning |
Based on @ChrisEelmaa's comment, I realized the I'm not sure I follow @vafada's comment. Is it a problem that can be prevented by clients of this library? if so, maybe we can write JS code that handles this completely and integrate it with the current native implementation? |
Moving discussion from #307 (comment).
We are willing to handle better store kit flow.
The text was updated successfully, but these errors were encountered: