Question

Revenuecat API fetches data in local development builds (and Expo Go) but does not fetch any data with Test Flight

  • 28 October 2023
  • 2 replies
  • 51 views

Userlevel 1
Badge +1

I build local development builds and the Revenuecat API works fine. Even with Expo Go, Revenuecat works fine, but it does not load data from Revenuecat when submitted to Test Flight and installed on my iPhone. Basically my offers are not shown at all. 

 

Here is the data loading component: 

const SubscribePackages = () => {

const [packages, setPackages] = useState([]);
const navigation = useNavigation();

const fetch_prices = async() => {
const result = await Purchases.getOfferings()
setPackages(result.current.availablePackages)
}

const subscribe = async(item) => {
try {
const {purchaserInfo} = await Purchases.purchasePackage(item)
const purchase = await Purchases.getCustomerInfo()
console.log('purchase: ', purchase)
if(typeof purchase.entitlements.active['pro'] !== 'undefined') {
await navigation.navigate('Account')
}
} catch (error) {
console.log(error)
}
}

useEffect(() => {
fetch_prices()
}, [])

return (
<View>
{packages.length > 0 ? packages.map((item) => {
return <View key={item.identifier}>
<ProductCard
name={item.packageType}
price={item.product.priceString}
currency={item.product.currencyCode}
subscribe={() => subscribe(item)}
/>
</View>
}) : <Text className="p-2 flex text-center font-bold text-gray-700">Data not loaded</Text>}
</View>
)
}

export default SubscribePackages



 


2 replies

Userlevel 3
Badge +8

Hi,

Happy to help here. Can you send full debug logs? They can be enabled like this.

Userlevel 1
Badge +1

Hi @ryan I’m new to mobile development. The mistake was I thought the environment variables would be exported into the Test Flight environment. I mean the keys inside `.env` file, but they were not exported at all. That caused a lot of confusion for me. I fixed it simply by exposing the public keys where the calls were made as I have no better solution for now. But I’ll check how to fix that.

Best. 

Reply