2.3.0
Android
let sub = await RNIApp.buySubscription("some");
should wait for the user to press buy on the modal of in app payments
i cant check if the user accepted the subscription, because when doing:
let sub = await RNIApp.buySubscription("some");
if(sub){
do some things..
}
the if(sub) block executes inmediatly after the popup opens, but the user still not accept the subscription
Real device
Any ideas?
There are other methods like getAvailablePurchases that also returns a promise and works fine
The problem is that buySubscription should return the callback of the user input and it isnt
Im using RN 57, also, the subscription gets done, i can check on the playstore that the purchase is ok but the buySubscription promise is returning undefined
any help?
Well, i downgrade to 2.2.2 and works.. so i think you guys missed something in your new release
@marcosmartinez7 Sorry for the breaking could you try 2.3.1
?
Hi, thanks!
I dont have time right now but i will
@marcosmartinez7 Thanks please come back.
@dooboolab Issue is present on iOS too. Tried both 2.3.1
as well as 2.3.2
. As mentioned by @marcosmartinez7 2.2.2
works fine
I think it is fixed in 2.3.3
. Please reopen when this is still occurring.
@dooboolab I'm sorry, just installed and relinked 2.3.5
. await RNIap.buySubscription(iapProductId)
still immediately returns undefined
on iOS
@Gaia-Nutrition I think your issue is different because ios
code hasn't changed. Could you try unlinking and linking again?
@dooboolab I tried linking and unlinking. Whenever I switch back to 2.2.2
it starts working again. But I'll check again tomorrow. Maybe I'll try to manually install the native component
@dooboolab Ok, I now manually linked the new 2.3.6
version. Still getting undefined
. I'd love to help solve this issue. Let me know what I can do to help!
Can somebody confirm this? This shouldn't happen especially in ios.
@dooboolab I can confirm that on iOS version 2.3.6 doesn't execute the promises but version 2.2.2 does (using an iPhone 5 device, React Native 0.56)
I am also experiencing this issue on 2.3.7. When i try to use await
the next line is called right away instead of waiting for the promise, and when i use RNIap.buySubscription(subId).then(purchase => {})
it crashes with error cannot read property then of undefined
We're currently working on this. Also, anyone who is facing this, did you call getSubscriptions
before actually calling buySubscription
?
I just tested purchase in RNExample app. I purchased subscription with buyProductWithoutFinishTransaction() method.
I suggest to test just like RNExample. And update Xcode, build setting to 'legacy'.. I guess build process in Xcode changed this update.
And use newly made sandbox tester.
@JJMoon very interesting. The combination of buyProductWithoutFinishTransaction()
and finishTransaction()
works on 2.3.7
while buySubscription()
directly still fails!
@Gaia-Nutrition OK. Then use buyProductWithoutFinishTransaction
and finishTransaction
instead of buySubscription
. The purchasing action is exactly the same.
@Gaia-Nutrition Can you try 2.3.8
? Also, did you call getSubscriptions
before buySubscription
?
@dooboolab 2.3.8
still fails using buySubscription
and again: Yes, I did call getSubscriptions
before. I don't think buyProductWithoutFinishTransaction()
would work otherwise.
I tested buySubscription in iOS device in sandbox mode.
It managed to success, but it shows some error message.
And Auto renewable subscription doesn't issue receipt.
I suggest to use buyProductWithoutFinishTransaction and finishTransaction instead of buySubscription.
Currently I have no device for test, I will track this issue later.
Feels like this is only issue in iOS
currently. Am I right?
@dooboolab No, also occuring on Android. The function returns undefined even before the first line in buyItemByType is called.
@dooboolab The problem is caused in the index.js:105. You should change the lines to something like
export const buySubscription = (sku, oldSku, prorationMode) => Platform.select({
ios: () => RNIapIos.buyProduct(sku),
android: () => RNIapModule.buyItemByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, sku, oldSku, -1),
})();
(I know this ignores prorationMode)
However after successfully subscribing there is an issue:
E/UncaughtException: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.List.get(int)' on a null object reference
at com.dooboolab.RNIap.RNIapModule$11.onPurchasesUpdated(RNIapModule.java:427)
at com.android.billingclient.api.BillingClientImpl$1.onReceive(BillingClientImpl.java:136)
at com.android.billingclient.api.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:303)
at com.android.billingclient.api.LocalBroadcastManager.access$000(LocalBroadcastManager.java:44)
at com.android.billingclient.api.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:114)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
@mfentross Which version of react-native-iap
are you at? There is empty line in RNIapModule.java:427
. Please try again for the recent one.
My fault: I edited a few lines. But the fix for the main problem is to edit the buySubscription function to
`
export const buySubscription = (sku, oldSku, prorationMode) =>
Platform.select({
ios: () => RNIapIos.buyProduct(sku),
android: () => {
if (!prorationMode) prorationMode = -1;
return RNIapModule.buyItemByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, sku, oldSku, prorationMode);
},
})();
`
There were some unnecessary brackets.
@mfentross my bad. I missed the return
statement. I've just published to 2.3.11
. So now the android is working?
@dooboolab Thanks, it works now 👍
@mfentross @JJMoon Ok! So we have iOS issue left only.
@JJMoon He says if wrap method with async
and await
, it works. However, I am not quite sure how this could be possible. Wrapping with async
and await
is redundant in return value isn't it?
I've published to 2.3.13
. Hope you all to try this out.
Please reopen when this is still occurring. Thank you for all helps.
Most helpful comment
We're currently working on this. Also, anyone who is facing this, did you call
getSubscriptions
before actually callingbuySubscription
?