0

I simply wants to fetch subscriptions i created in App Store Connect and Google Play Console.

I use react-native-iap v14.4. The code below works correctly on Android and return what it should :

[{"currency": "EUR", "debugDescription": null, "description": "", "displayName": "default", "displayPrice": "€8.49", "id": "default", "nameAndroid": "default", "oneTimePurchaseOfferDetailsAndroid": null, "platform": "android", "price": 8.49, "subscriptionOfferDetailsAndroid": [[Object], [Object]], "title": "default (StreakGG)", "type": "subs"}]

but in IOS i get : []

What i already checked :

  • That the state of my subscriptions are "Ready to submit" (and apparently it should be enough)
  • Everything in the Business section is accepted and active
  • My subs are referenced in the "Distribution section" of the app.
  • They have been created like 10 hours ago so it should be deployed now right ?
  • I made the subs available in my country (in all countries basically)

I really don't get why it is not working.

Here is the very simple code.

import { StyleSheet, Text, View, } from 'react-native';
import { useContext, useEffect, useState } from 'react';

import { colors } from '../utils/theme';
import { useIAP, ErrorCode } from 'react-native-iap';
import { useNavigation } from '@react-navigation/core';
import { SafeAreaView } from 'react-native-safe-area-context';

export default function SubscriptionScreen() {


  const navigation = useNavigation()

  const productIds = ['default']

  const { connected, subscriptions, fetchProducts, requestPurchase } =
    useIAP({
      onPurchaseSuccess: (purchase) => {
        console.log('Purchase successful:', purchase);
        // Handle successful purchase
        // validatePurchase(purchase);
      },
      onPurchaseError: (error) => {
        console.error('Purchase failed:', error);
        // Handle purchase error
      },
    });

  useEffect(() => {
    if (connected) {
      fetchProducts({ skus: productIds, type: 'subs' });
    }
  }, [connected]);


  return (<SafeAreaView>
    {console.log(subscriptions)}
    <View>
      <Text>{JSON.stringify(subscriptions)}</Text>
      <Text >Votre repas</Text>
    </View>

  </SafeAreaView>)

}``` 

1 Answer 1

1

So I never managed to get rid of this empty array for IOS subscriptions. So i uninstalled react-native-iap and created an i'm now using react-antive-purchases (RevenueCat instead). Now everything works fine and subscriptions are loaded correctly.

Follow this guide and everything should be fine if you have the same issue as me https://www.youtube.com/watch?v=R3fLKC-2Qh0

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.