Skip to content
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

The sku was not found. Please fetch products first by calling getItems #1051

Closed
Ilario17 opened this issue Jul 21, 2020 · 14 comments
Closed
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed

Comments

@Ilario17
Copy link

Ilario17 commented Jul 21, 2020

Version of react-native-iap

6.0.6

Version of react-native

0.64.1

Platforms you faced the error

Android

Actual behavior

Some users cannot make in-app purchases, the error they encountered is "the sku was not found. Please fetch products first by calling getItems"

The first thing i do in the app after initConnection() is to take the list of in-app purchases.

I don't know how to reproduce the error, it does not seem related to a particular version of android or to a particular device

The error that some users receive:

java.lang.NullPointerException: Attempt to invoke virtual method 'com.android.billingclient.api.Purchase$PurchasesResult com.android.billingclient.api.BillingClient.queryPurchases(java.lang.String)' on a null object reference
        at com.dooboolab.RNIap.RNIapModule$13.run(RNIapModule.java:631)
        at com.dooboolab.RNIap.RNIapModule.ensureConnection(RNIapModule.java:91)
        at com.dooboolab.RNIap.RNIapModule.sendUnconsumedPurchases(RNIapModule.java:625)
        at com.dooboolab.RNIap.RNIapModule.startListening(RNIapModule.java:652)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
        at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java:-2)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:228)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
        at java.lang.Thread.run(Thread.java:919)

I know that getProducts definitely returns the products, because users can see the price of the purchase and I don't save it in the app but I get it from getProducts

@hyochan hyochan added 🤖 android Related to android 🙏 help wanted Extra attention is needed labels Sep 14, 2020
@hyochan
Copy link
Member

hyochan commented Sep 14, 2020

Have you called getProducts?

@TheHuns
Copy link

TheHuns commented Oct 16, 2020

@Ilario17 Having the same issue on android only, did you find a solution?

@pandya293
Copy link

Yes, having same issue. Please post solution.

@pandya293
Copy link

It take long to approve product from Google Play store. Don't know why. And not update any kind of status on product. But after two days wait. Products are automatic fetching with same source code. So wait for approve products.

@EndLess728
Copy link

I have approved my in app purchase products from play store even getting the response but sometime it returns sku not found for some users , don't know why me too faced this issues sometimes while testing and thought it was the issue because play store takes time to approve products but it is still occurring sometimes

@SebastianMieszczanczyk
Copy link

Please check if you have properly configured your products/subscriptions skus in the play store (you need to add them there). You can check if you have them by using: getProducts or getSubscriptions. If it will return non-empty array it means that you have products/subscriptions with that sku (please remember that sku must be a string and when you want to get products/subscriptions you must provide array of strings). For me, that solved the issue.

@Ilario17
Copy link
Author

Ilario17 commented Jun 19, 2021

This error is still present in version 6.0.6

I still couldn't figure out why it only happens with some (and fortunately few) users

@hyochan

@Ilario17
Copy link
Author

@SebastianMieszczanczyk this error happens randomly in production, many people buy without problems but some instead encounter this error.

@Ilario17
Copy link
Author

@hyochan I updated the post with new info

@andresesfm
Copy link
Collaborator

#1388 Fixes the race condition by ensuring billing client is not null while calling internal methods

@MariusCatanoiu
Copy link

I still have this issue on v12.4.14

@andresesfm
Copy link
Collaborator

@MariusCatanoiu if this still happens, please create a ticket with the details and I'll take a look

@Mykyta-Chernenko
Copy link

I experience this issue when getSubscriptions first throws E_SERVICE_ERROR Billing is unavailable.

So the users have no Play Market or no user logged in there ->
when the app tries to fetch the products, it gets nothing ->
when the user tries to buy a product sku is not found

@usmanabid94
Copy link

usmanabid94 commented Mar 27, 2024

@pandya293 @andresesfm @EndLess728 @MariusCatanoiu @hyochan
I am having the same issue when I call get products in the RNIAP.requestPurchase here is my code :
Error:The sku was not found. Please fetch products first by calling getItems
Code :
RNIap.getProducts(skus)
.then(async (products) => {
//handle success of fetch product list
console.log("products", products);
if (Platform.OS === 'ios') {
await this.requestPurchase({ sku });
} else if (Platform.OS === 'android') {
await RNIap.requestPurchase({ skus: [sku] }).then((purchase) => {
console.log("purchase", purchase);
}).catch((error) => {
console.log("error", error.message);
});;
}

})
.catch((error) => {
  console.log("err", error);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants