iOS Setup
For complete iOS setup instructions including App Store Connect configuration, Xcode setup, and testing guidelines, please visit:
👉 iOS Setup Guide - openiap.dev
The guide covers:
- App Store Connect configuration
- Xcode project setup
- Sandbox testing
- Common troubleshooting steps
Code Implementation​
Basic Setup​
import React from 'react';
import {View, TouchableOpacity, Text} from 'react-native';
import {useIAP, ErrorCode} from 'expo-iap';
const productIds = [
'com.yourapp.premium',
'com.yourapp.coins_100',
'com.yourapp.subscription_monthly',
];
function App() {
const {connected, products, fetchProducts, requestPurchase} = useIAP({
onPurchaseSuccess: (purchase) => {
console.log('Purchase successful:', purchase);
// For production apps, verify purchases server-side.
// See verifyPurchaseWithProvider: /blog/3.2.0
},
onPurchaseError: (error) => {
console.error('Purchase failed:', error);
},
});
React.useEffect(() => {
if (connected) {
fetchProducts({skus: productIds, type: 'in-app'});
}
}, [connected]);
return (
<View>
{products.map((product) => (
<TouchableOpacity
key={product.id}
onPress={() =>
requestPurchase({
request: {apple: {sku: product.id}},
})
}
>
<Text>
{product.title} - {product.displayPrice}
</Text>
</TouchableOpacity>
))}
</View>
);
}
💡 Cross-Platform Note: This example shows iOS-specific usage with
sku. For cross-platform compatibility, include bothskuandskusin your request object. See the Core Methods documentation for details.
Common Issues​
Product IDs Not Found​
Problem: Products return empty or undefined
Solutions:
-
Check Prerequisites (Most common cause):
- Verify ALL agreements are signed in App Store Connect > Business
- Ensure ALL banking, legal, and tax information is completed AND approved by Apple
- These are the most commonly overlooked requirements
-
Verify Product Configuration:
- Product IDs match exactly between code and App Store Connect
- Products are in "Ready to Submit" or "Approved" state
- Bundle identifier matches
-
Use Proper Sandbox Testing:
- Sign in via Settings > Developer > Sandbox Apple Account
- NOT through the App Store app
Sandbox Testing Issues​
Problem: "Cannot connect to iTunes Store" error Solution:
- Use a dedicated sandbox test user
- Sign out of regular App Store account
- Verify internet connection
- Try on a real device (simulator may have issues)
Purchase Verification Failures​
Problem: Purchase verification returns invalid Solution:
- Check if app is properly signed
- Verify receipt data is not corrupted
- Ensure proper error handling for network issues
Best Practices​
- Always verify purchases server-side for production apps
- Handle all error cases gracefully
- Test thoroughly with sandbox users
- Provide restore functionality for non-consumable products
