"react-native-iap": "^2.0.3",
iOS
Makes a purchase
const purchase = await RNIap.buyProductWithoutFinishTransaction(productId)
const { transactionReceipt, purchaseToken } = purchase
sendToServer(transactionReceipt, {
onSuccess: () => {
RNIap.finishTransaction()
RNIap.consumeAllItems()
}})
Dialog: “This in-app purchase has already been bought”. This is only happening for one SKU, others are working fine. I think the app got in a bad state and I don't see a way to fix it. I tired to call finishTransaction
and consumeAllItems
on initialization but that didn't fix it. Other SKUs I can purchase multiple times without issue. Nothing is returned for getPurchaseHistory
.
Device (sandbox)
I'm not sure.
@siderakis Yeah strange. I've already patched this problem like told in stackoverflow but still occurring in some devices. I am willing to fix this too. Which device are you using?
@siderakis This might solve your app in bad state I guess. Could you try?
I tried it and it didn't work. I also reinstalled the app and that didn't help. It's running on an iPad.
I set a breakpoint and it looks like currentQueue.transactions is empty
From SKPaymentQueue.h
// Array of unfinished SKPaymentTransactions. Only valid while the queue has observers. Updated asynchronously.
@property(nonatomic, readonly) NSArray<SKPaymentTransaction *> *transactions NS_AVAILABLE_IOS(3_0);
@end
Maybe I called it too soon
I called the code later in the programs execution and it fixed the issue.
@siderakis Sorry for bothering. But, what code did you call ?
The transactions
array is a property, not method, which is not in our code.
Did you mean finishTransaction
?
I was calling this native code.
When I called it in didFinishLaunchingWithOptions
currentQueue.transactions was empty, but calling it in applicationDidBecomeActive worked.
This worked:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// take current payment queue
SKPaymentQueue* currentQueue = [SKPaymentQueue defaultQueue];
[currentQueue restoreCompletedTransactions];
// finish ALL transactions in queue
// [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
[currentQueue.transactions enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[currentQueue finishTransaction:(SKPaymentTransaction *)obj];
}];
}
I'm not sure how but maybe we can expose this functionality in the library?
@siderakis Yes. That's what I meant in issue #259 .
I think that action can be anywhere after applicationDidBecomeActive.
So, I will expose that method to JS side, that user can call it any time.
Thank you for your advice.
@JJMoon, I have the same issue, When can we expect a resolution for exposing a method as you mentioned above. Thanks.
@sivrihuseyin Problem is well known now. We will make the patch this weekend. Thank you to all issuers.
We've released the expected solution in 2.2.0
. Could you follow readme and try this line of codes?
Hello Hyo Chan,
Thank you for the information.
I have installed the version 2.2.0 and tried the code. Unfortunately, the
issue is not fixed yet. think that the function, *clearTransaction *has not
been exported. In reactNative environment there is no clearTransaction
function inside RNIap.
I checked the file index.d.ts and I couldn't see the function as
clearTransaction in this. file.
Kind regards,
Huseyin
On Sun, Sep 16, 2018 at 2:25 PM Hyo Chan Jang notifications@github.com
wrote:
Closed #257 https://github.com/dooboolab/react-native-iap/issues/257
via a5f225d
https://github.com/dooboolab/react-native-iap/commit/a5f225d470af0a85417325d24357667e54aa7078
.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/dooboolab/react-native-iap/issues/257#event-1848183078,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiH7bOp96EzsoX82UVxKHK2LkN7PNWVAks5ubjUogaJpZM4WmG_0
.
Hello Hyo Chan,
I am sorry for the wrong information. IT IS FIXED. There is no problem
anymore.
Thank you for your prompt response and great solution.
Kind regards,
Huseyin
On Sun, Sep 16, 2018 at 2:56 PM Huseyin Sivri sivri.huseyin@gmail.com
wrote:
Hello Hyo Chan,
Thank you for the information.
I have installed the version 2.2.0 and tried the code. Unfortunately, the
issue is not fixed yet. think that the function, *clearTransaction *has
not been exported. In reactNative environment there is no clearTransaction
function inside RNIap.I checked the file index.d.ts and I couldn't see the function as
clearTransaction in this. file.Kind regards,
Huseyin
On Sun, Sep 16, 2018 at 2:25 PM Hyo Chan Jang notifications@github.com
wrote:Closed #257 https://github.com/dooboolab/react-native-iap/issues/257
via a5f225d
https://github.com/dooboolab/react-native-iap/commit/a5f225d470af0a85417325d24357667e54aa7078
.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/dooboolab/react-native-iap/issues/257#event-1848183078,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiH7bOp96EzsoX82UVxKHK2LkN7PNWVAks5ubjUogaJpZM4WmG_0
.
It is fixed with the version 2.2.0 by applying clearTransaction function. Thank you
@JJMoon
For future Googlers upgrading from v2 to v3-5, I found this helpful
Most helpful comment
I was calling this native code.
When I called it in
didFinishLaunchingWithOptions
currentQueue.transactions was empty, but calling it in applicationDidBecomeActive worked.This worked:
I'm not sure how but maybe we can expose this functionality in the library?