question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS: Not getting the products and getAvailablePurchases list

See original GitHub issue

Version 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:closed
  • Created 2 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
JacquesWhitecommented, Feb 24, 2022

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.

1reaction
rohitatcoffeecommented, Jan 17, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found