-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
[Android] Fixed promise never returned from requestSubscription() #806
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.
Let's see how it works! 👍
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.
@hyochan FYI
@@ -522,8 +522,8 @@ public void onPurchasesUpdated(BillingResult billingResult, @Nullable List<Purch | |||
item.putBoolean("isAcknowledgedAndroid", purchase.isAcknowledged()); | |||
item.putInt("purchaseStateAndroid", purchase.getPurchaseState()); | |||
|
|||
promiseItem = item.copy(); |
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.
the copy
method is only added in RN 0..61. Should probably bump up the major version and update doc to reflect that.
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.
@mars-lan Hey! Thank you for the detail. Um... I should have to think about it since I feel kind of reluctant to separate the major version. @rewieer How do you think?
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.
The copy method basically calls merge, so we can create a public WriteableMap copy(WritableMap original)
inside DoobooUtils.java
.
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.
@rewieer Sounds great! Would you like to give a PR
for your idea?
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.
@hyochan sorry for the long delay, I was about to do it but it seems someone did it before me
Calling
requestSubscription()
on Android result in the purchase being made but the promise is never called. This is due to an exception being thrown when trying to resolve the promise, specificallymethod threw 'com.facebook.react.bridge.objectalreadyconsumedexception' exception
because the WriteableMap is already consumed whensendEvent
is called.By making a copy before calling it, we get a fresh WriteableMap that we can send to our promise without error.