Skip to main content

when I try my following code to see if I can get Standard offer,

 

useEffect(() => {

setLoading(true);

const fetchOfferings = async () => {

// console.log("test");

try {

const offerings = await Purchases.getOfferings();

if (Platform.OS === "android") {

console.log(

"android offerings",

JSON.stringify(offerings.all.Standard, null, 2)

);

}

if (Platform.OS === "ios") {

console.log(

"ios offerings",

JSON.stringify(offerings.all.Standard, null, 2)

);

}

 

if (offerings) {

// console.log("offering", offerings.alll"onboarding"]);

if (Platform.OS === "ios") {

setOffering(offerings.alll"Default"]);

} else {

setOffering(offerings.alll"Default"]);

}

}

} catch (e) {

console.error(e);

} finally {

setLoading(false);

}

};

 

fetchOfferings();

}, }]);





I got 

 LOG  ios offerings {
  "availablePackages": a
    {
      "offeringIdentifier": "Standard",
      "product": {
        "priceString": "$4.00",
        "pricePerMonth": 4,
        "pricePerYear": 48,
        "productCategory": "SUBSCRIPTION",
        "subscriptionPeriod": "P1M",
        "pricePerWeekString": "$0.92",
        "price": 4,
        "title": "Vetcation Basic Monthly",
        "pricePerMonthString": "$4.00",
        "pricePerYearString": "$48.00",
        "description": "Get expert advice, post queries",
        "currencyCode": "USD",
        "introPrice": null,
        "pricePerWeek": 0.9199999999999999,
        "identifier": "rc_basic_400_1m",
        "productType": "AUTO_RENEWABLE_SUBSCRIPTION",
        "discounts": ]
      },
      "presentedOfferingContext": {
        "offeringIdentifier": "Standard",
        "targetingContext": null,
        "placementIdentifier": null
      },
      "identifier": "Basic Monthly",
      "packageType": "CUSTOM"
    },
    {
      "packageType": "CUSTOM",
      "product": {
        "productType": "AUTO_RENEWABLE_SUBSCRIPTION",
        "discounts": U],
        "pricePerYearString": "$108.00",
        "description": "Get expert advice, earn a badge, post queries",
        "title": "Vetcation Premium Monthly",
        "pricePerMonthString": "$9.00",
        "productCategory": "SUBSCRIPTION",
        "introPrice": null,
        "pricePerWeek": 2.07,
        "currencyCode": "USD",
        "pricePerWeekString": "$2.07",
        "subscriptionPeriod": "P1M",
        "pricePerYear": 108,
        "identifier": "rc_premium_900_1m",
        "price": 9,
        "priceString": "$9.00",
        "pricePerMonth": 9
      },
      "offeringIdentifier": "Standard",
      "presentedOfferingContext": {
        "placementIdentifier": null,
        "offeringIdentifier": "Standard",
        "targetingContext": null
      },
      "identifier": "Premium Monthly"
    },
    {
      "product": {
        "productCategory": "SUBSCRIPTION",
        "subscriptionPeriod": "P1Y",
        "pricePerWeekString": "$0.80",
        "priceString": "$42.00",
        "pricePerMonth": 3.5,
        "discounts": ],
        "pricePerMonthString": "$3.50",
        "title": "Vetcation Basic Yearly",
        "description": "Get expert advice, post queries",
        "pricePerYearString": "$42.00",
        "pricePerWeek": 0.8,
        "introPrice": null,
        "currencyCode": "USD",
        "price": 42,
        "pricePerYear": 42,
        "productType": "AUTO_RENEWABLE_SUBSCRIPTION",
        "identifier": "rc_basic_4200_1y"
      },
      "packageType": "CUSTOM",
      "presentedOfferingContext": {
        "offeringIdentifier": "Standard",
        "targetingContext": null,
        "placementIdentifier": null
      },
      "identifier": "Basic Yearly",
      "offeringIdentifier": "Standard"
    },
    {
      "packageType": "CUSTOM",
      "product": {
        "productType": "AUTO_RENEWABLE_SUBSCRIPTION",
        "discounts": r],
        "price": 93.99,
        "productCategory": "SUBSCRIPTION",
        "pricePerWeekString": "$1.80",
        "subscriptionPeriod": "P1Y",
        "pricePerYearString": "$93.99",
        "description": "Get expert advice, earn a badge, post queries",
        "priceString": "$93.99",
        "pricePerMonth": 7.83,
        "pricePerWeek": 1.8,
        "introPrice": null,
        "currencyCode": "USD",
        "title": "Vetcation Premium Yearly",
        "pricePerMonthString": "$7.83",
        "identifier": "rc_premium_9399_1y",
        "pricePerYear": 93.99
      },
      "offeringIdentifier": "Standard",
      "presentedOfferingContext": {
        "targetingContext": null,
        "offeringIdentifier": "Standard",
        "placementIdentifier": null
      },
      "identifier": "Premium Yearly"
    }
  ],
  "identifier": "Standard",
  "serverDescription": "Standard package",
  "metadata": {}
}
 LOG  android offerings undefined


you can see that only ios can see the offer but not in the android device. why?

Hi, I’d check the debug logs to see if you’re getting an empty offerings error on Android, which usually happens when the credentials aren’t configured correctly. We have some suggested steps to fix that issue here.