RevenueCat / react-native-purchases

React Native in-app purchases and subscriptions made easy. Support for iOS and Android.
https://www.revenuecat.com
MIT License
773 stars 84 forks source link

Purchases.getOfferings() returning missing object on Android (it is different from what I got on the ios device). #1069

Closed geoffcfchen closed 3 months ago

geoffcfchen commented 3 months ago

When fetching offerings using the Purchases.getOfferings() method, the "Standard" offering appears as expected on iOS but is missing from the Android offerings. This inconsistency between platforms suggests that the offering is not available on Android, even though it should be configured similarly to iOS.

  1. Environment
    1. Platform: iOS and Android
    2. SDK version: "react-native-purchases": "8.0.1", "react-native-purchases-ui": "8.0.1",
    3. OS version: iOS 16.1, Android 11
    4. Xcode/Android Studio version: I use Expo EAS service.
    5. React Native version: 0.72.4

when I use the following code to print out offerings.all

  useEffect(() => {
    setLoading(true);
    const fetchOfferings = async () => {
      // console.log("test");
      try {
        const offerings = await Purchases.getOfferings();
        if (Platform.OS === "android") {
          console.log("android offerings", offerings.all);
        }
        if (Platform.OS === "ios") {
          console.log("ios offerings", offerings.all);
        }

        if (offerings) {
          // console.log("offering", offerings.all["onboarding"]);
          if (Platform.OS === "ios") {
            setOffering(offerings.all["Standard"]);
          } else {
            setOffering(offerings.all["Standard"]);
          }
        }
      } catch (e) {
        console.error(e);
      } finally {
        setLoading(false);
      }
    };

    fetchOfferings();
  }, []);

for ios, I got

  {
  "Default": {
    "annual": { "identifier": "$rc_annual", "offeringIdentifier": "Default", "packageType": "ANNUAL", "presentedOfferingContext": [Object], "product": [Object] },
    "availablePackages": [[Object], [Object]],
    "identifier": "Default",
    "metadata": {},
    "monthly": { "identifier": "$rc_monthly", "offeringIdentifier": "Default", "packageType": "MONTHLY", "presentedOfferingContext": [Object], "product": [Object] },
    "serverDescription": "The standard set of products"
  },
  "Standard": {
    "availablePackages": [[Object], [Object], [Object], [Object]],
    "identifier": "Standard",
    "metadata": {},
    "serverDescription": "Standard package"
  },
  "onboarding": {
    "annual": { "identifier": "$rc_annual", "offeringIdentifier": "onboarding", "packageType": "ANNUAL", "presentedOfferingContext": [Object], "product": [Object] },
    "availablePackages": [[Object]],
    "identifier": "onboarding",
    "metadata": {},
    "serverDescription": "Offering for the onboarding flow"
  }
}

But for android, I got

{
  "Default": {
    "annual": { "identifier": "$rc_annual", "offeringIdentifier": "Default", "packageType": "ANNUAL", "presentedOfferingContext": [Object], "product": [Object] },
    "availablePackages": [[Object], [Object]],
    "identifier": "Default",
    "lifetime": null,
    "metadata": {},
    "monthly": { "identifier": "$rc_monthly", "offeringIdentifier": "Default", "packageType": "MONTHLY", "presentedOfferingContext": [Object], "product": [Object] },
    "serverDescription": "The standard set of products",
    "sixMonth": null,
    "threeMonth": null,
    "twoMonth": null,
    "weekly": null
  },
  "onboarding": {
    "annual": { "identifier": "$rc_annual", "offeringIdentifier": "onboarding", "packageType": "ANNUAL", "presentedOfferingContext": [Object], "product": [Object] },
    "availablePackages": [[Object]],
    "identifier": "onboarding",
    "lifetime": null,
    "metadata": {},
    "monthly": null,
    "serverDescription": "Offering for the onboarding flow",
    "sixMonth": null,
    "threeMonth": null,
    "twoMonth": null,
    "weekly": null
  }
}

You can see obviously "Standard" is missing in Android, which I use for template 7.

RCGitBot commented 3 months ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

rglanz-rc commented 3 months ago

Hi, I left you a message on your community post. I'll close this issue and we can troubleshoot in that thread.