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

getSubscriptions returns an empty array on Android #2720

Open
gkpo opened this issue Apr 4, 2024 · 6 comments
Open

getSubscriptions returns an empty array on Android #2720

gkpo opened this issue Apr 4, 2024 · 6 comments

Comments

@gkpo
Copy link

gkpo commented Apr 4, 2024

Environment:

  • react-native-iap: 12.12.0
  • react-native: 0.73.4
  • Platforms: Android simulator

I managed to get the subscriptions list on iOS but now I'm trying to do so on android and the getSubscriptions method is not returning anything.

const {
  connected,
  currentPurchaseError,
  initConnectionError,
  getSubscriptions,
  subscriptions,
} = useIAP();

const SUBSCRIPTIONS_SKUS = Platform.select({
  ios: ["premium_monthly", "premium_yearly"],
  android: ["monthly", "test"], // <-- monthly is a Subscription id, test is a Product id just doing some tests at this point...
});

const handleGetSubscriptions = async () => {
    try {
      await getSubscriptions({ skus: SUBSCRIPTIONS_SKUS as string[] });
    } catch (error) {
      console.log({ message: "handleGetSubscriptions", error });
    }
  };

 // This is executed when getSubscriptions returns
 // ios I have a list of subs. On android, an empty array
 useEffect(() => {
    console.log("subscriptions changed: ", subscriptions);
 }, [subscriptions]);

// In the return function I have:
<Button text="Get subscriptions" onPress={handleGetSubscriptions} />

How does the library even work ?

In fact I'm a bit lost about how it even works. How does react-native-iap know which Google Play project is associated with my mobile app and where to fetch the products and subscriptions from? Unlike other libraries, there is no API key or anything that I had to set in my project.

I have uploaded my .apk (.aab actually) to my play store app, and now the play store project is aware of the bundle ID. Is that how it works ?

Regardless of how it works.. why it doesn't work !!! 😭😭 any help would be much appreciated !!!

@RickYangzz
Copy link

hhhhhhh, I have the same problem. hhhh, God maybe help me.

@gkpo
Copy link
Author

gkpo commented Apr 27, 2024 via email

@RickYangzz
Copy link

Thank you, I will try those steps.

@RickYangzz
Copy link

image I'd like to know if this release's status is ok for me to test react-native-iap?

@RickYangzz
Copy link

Luckily, I have solved this problem finally.

@gkpo
Copy link
Author

gkpo commented May 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants