iOS: Not getting the products and getAvailablePurchases list
See original GitHub issueVersion of react-native-iap
8.0.0-rc.4
Version of react-native
0.62.0
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
I should get the products list.
Actual behavior
I am not getting the products and getAvailablePurchases list as an empty array.
Tested environment (Emulator? Real Device?)
On Real device + Simulator.
Steps to reproduce the behavior
Config
const itemSkus = Platform.select({
ios: [
'org.example.mobile.mobile_jan_2022'
],
android: [
'mobile_jan_2022'
],
});
const itemSubs = Platform.select({
ios: [
'mobile_pass'
],
android: [
'mobile_jan_2022', // subscription
],
});
initConnection
try {
await RNIap.initConnection();
if (Platform.OS === 'android') {
await RNIap.flushFailedPurchasesCachedAsPendingAndroid();
} else {
await RNIap.clearTransactionIOS();
}
} catch (err) {
console.warn(err.code, err.message);
}
getAvailablePurchases = async (): Promise<void> => {
try {
console.info(
'Get available purchases (non-consumable or unconsumed consumable)',
);
const purchases = await RNIap.getAvailablePurchases();
console.info('Available purchases :: ', purchases);
if (purchases && purchases.length > 0) {
this.setState({
availableItemsMessage: `Got ${purchases.length} items.`,
receipt: purchases[0].transactionReceipt,
});
this.validateReceipt(purchases[0].transactionReceipt)
} else {
EventRegister.emit(AppConstants.Events.SubscribedUser, false)
TokenManager.shared().setSubscriptionValid(false)
}
} catch (err) {
console.warn(err.code, err.message);
EventRegister.emit(AppConstants.Events.SubscribedUser, false)
TokenManager.shared().setSubscriptionValid(false)
}
};
I added In-App Purchase in Capability in Xcode.
Issue Analytics
- State:
- Created 2 years ago
- Comments:14
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m having the same issue with non-renewable subscriptions. For now using “react-native-iap-rd”: “^8.0.0-rd” resolves issue. Hope it’ll be fixed soon.
@yasodha-r “react-native-iap-rd”: “^8.0.0-rd”,
I adjusted some code and used it in my code. I am able to get the product in iOS and Android. Tested full subscription flow.