How to use the react-native-iap.initConnection function in react-native-iap

To help you get started, we’ve selected a few react-native-iap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github guardian / editions / projects / Mallard / src / hooks / use-subscribe.ts View on Github external
useEffect(() => {
        RNIAP.initConnection().then(() =>
            RNIAP.getAvailablePurchases()
                .then(findCurrentSubInfoFromPurchases)
                .then(setCurrentSubscriptionInfo),
        )
        return () => {
            // https://github.com/dooboolab/react-native-iap#end-billing-connection
            RNIAP.endConnectionAndroid()
        }
    }, [])
github raindropio / mobile / src / screens / settings / pro / buy / module.js View on Github external
export const init = async (userId)=>{
    if (await RNIap.initConnection() == false)
        throw new Error('This device is not allowed to make purchases. Please check restrictions on device')

    //Old not finished puchases (restore like)
    const purchases = await RNIap.getAvailablePurchases()
    for(const purchase of purchases)
        try{
            await validatePurchase(purchase, userId)
        } catch (e) {
            console.log(e, purchase)
        }
}