I’m experiencing an issue with React Native IAP where I can’t detect a subscription that was created in Apple Store Connect for my application. I need expert assistance to resolve this problem.
Here are the details:
- I’ve set up a subscription product in App Store Connect for my React Native app.
- I’m using the
react-native-iap
library to handle in-app purchases. - The subscription appears to be configured correctly in App Store Connect.
- When trying to retrieve the subscription details in my app, it’s not being detected.
Here’s a simplified version of my code:
import React, {useCallback, useEffect, useState} from 'react';
import {View, Text, ScrollView, TouchableOpacity, Alert} from 'react-native';
import {custom} from '../custom';
import {theme} from '../constants';
import {components} from '../components';
import {utils} from '../utils';
import {hooks} from '../hooks';
import { endConnection, getSubscriptions, initConnection } from 'react-native-iap';
const SUBSCRIPTION_SKU = 'com.sub.test';
const Prenium: React.FC = () => {
const [loading, setLoading] = useState(false);
const [subscriptionInfo, setSubscriptionInfo] = useState<any>(null);
const navigation = hooks.useAppNavigation();
useEffect(() => {
const init = async () => {
try {
console.log("Début de l'initialisation");
await initConnection();
console.log("Connexion initialisée");
const subscriptions = await getSubscriptions({skus: [SUBSCRIPTION_SKU]})
console.log("Subscriptions récupérées:", subscriptions);
if (subscriptions.length === 0) {
console.log("Aucun abonnement trouvé pour le SKU:", SUBSCRIPTION_SKU);
}
} catch (error) {
console.error('Erreur complète:', error);
const errorMessage = (error as Error).message;
Alert.alert('Erreur', `Une erreur est survenue: ${errorMessage}`);
}
};
init();
return () => {
endConnection();
}
}, [])
}
I’ve already tried the following:
- Double-checking the subscription ID in App Store Connect
- Verifying that my app’s bundle ID matches the one in App Store Connect
- Ensuring that my Apple developer account has the necessary agreements signed
- Waiting for 24 hours after creating the subscription in case of any delay
Questions:
- What could be causing the subscription not to be detected?
- Are there any specific configuration steps I might have missed?
- How can I troubleshoot this issue further?
Any help or guidance would be greatly appreciated. Thank you!
New contributor
Steeven Jackson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.