1

Have anyone successfully implemented in app subscriptions with react-native-iap in an app. I have tried to implement it but still very unstable. Can't rely that the subscription payments work every time. Sometimes the pay dialog won't show, sometimes it won't continue, and so on. Its a problem on both android and iOS.

Short explanation on how I have implemented it:

When clicked on pay button after the user has selected the plan, for ex. monthly.

await requestSubscription({
    sku: subscription.productId,
    ...(offerToken && { subscriptionOffers: [{sku: subscription.productId, offerToken}]}),
})

Then I have to listeners, currentPurchaseError and currentPurchase that is returned as a hook from the rniap library.

React.useEffect(() => {
    const onError = async () => {
        // Do something on error from rniap.
    }

    if (currentPurchaseError) {
        onError()
    }
}, [currentPurchaseError])

And

React.useEffect(() => {
    const checkCurrentPurchase = async () => {
        // Do something, this should trigger when a purchase is successful.
    }

    if (currentPurchase) {
        checkCurrentPurchase()
    }
}, [currentPurchase, finishTransaction])

My receipt validation is happening on our own backend and its worth mentioning that everything there is working.

As I asked, has anyone implemented this successfully. If so, how? Or is it worth thinking of changing to like revenue cat? rniap's documentation and example code is really small and right now I need some help.

/Alexander

I have tried to get a successful payment within iOS sandbox but with no luck.

Kirill Novikov
  • 2,576
  • 4
  • 20
  • 33
  • I never use react-native-iap, I'm using revenue cat, it's very easy, it work on Android and IOS, no issue with the payment, all working fine. – bagi2info.com Jan 31 '23 at 09:50
  • @suryadi Thanks for you reply. I have thought of switching to revenue cat, but the problem is that I want to use own backend for the validation etc. But thanks! – Alexander Wassbjer Jan 31 '23 at 14:23

0 Answers0