-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
fix: set connected false in endConnection #2807
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great investigation. However, ideally, I think the solution could go somewhere in https://github.com/dooboolab-community/react-native-iap/blob/887623698ce7b58615685745a0a7a39d518db160/src/hooks/useIAP.ts#L121-L126
Could you try setting setConnected(false)
in the return
statement in useEffect
? Also, I think ending the connection there could be added as well. We only need the billing connection in the component where we actually need it.
I thought so too. |
Hello, As we discussed before, I have moved /* withIAPContext.tsx */
useEffect(() => {
// here is false after setConnected(false)
if (!connected) {
return;
}
...
}, [connected]); I've tested both If there are no problems, this update may help with many issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very promising! Thanks a lot 👍
Hello.
I faced one problem using this.
Though a first purchase after the in-app connection is successful, the store purchase will be completed, but the
currentPurchase
status is not updating inside the library. I would have to repeat the purchase process by killing the app.In my opinion, the purchaseListener is connected by the change of the
connected
value insideuseEffect
, which changes fromfalse
totrue
only when the app is first connected and not after that, so I decided that I can't subscribe to the status of the current order.So I added a code inside the
endConnection
method to makeconnected
false.This allows you to update every subscription correctly by changing
connected
totrue
when you access the order page andfalse
when you accessendConnection
.Both iOS and Android work as expected.
I think this issue is related to the issue below.
#2700
I hope that this PR will be reflected so that it can help everyone.