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.

How to handle auto renewable subscriptions?

See original GitHub issue

Version of react-native-iap

4.4.9

Version of react-native

0.61.5

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

Actual behavior

Tested environment (Emulator? Real Device?)

Sandbox environment

Steps to reproduce the behavior

I have the below code snippet to handle subscription purchase

// On button press
requestPurchase(sku);

// Purchase updated listener
this.purchaseUpdateSubscription = purchaseUpdatedListener((purchase) => {
      console.log('purchaseUpdatedListener', purchase);
      const receipt = purchase.transactionReceipt;
      await finishTransaction(purchase);
      await Firebase.updateUser({
        'subscription.ios': purchase
      })
    });

So far I was able to perform purchase and store the receipt onto Firebase. But my question is do I need to call getAvailablePurchases on every app launch to store the latest purchase receipt? Or do I only need to store the receipt when the user purchases the subscription for the first time? Also, how do I validate if the subscription has expired?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
ziyoshamscommented, Aug 6, 2020

This is usually done using webhooks. For Apple you can enable server-to-server notifications that will communicate with your server. Google has something similar, but setting it up is much more complicated and there is no docs on that. Android Developers has a basic doc here, but what you want is a Pub/Sub system that google has.

Also this StackOverflow question has some good information

UPDATE I actually found a good source that will help you to set up server-to-server notifications. RevenueCat Docs has a lot of useful information. Here is the link for Apple and Google Pub/Sub

0reactions
stale[bot]commented, Dec 5, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto-renewable Subscriptions - App Store - Apple Developer
Auto -renewable subscriptions provide access to content, services, or premium features in your app on an ongoing basis. They automatically renew at the...
Read more >
In-App Purchase Tutorial: Auto-Renewable Subscriptions
Auto -renewable subscriptions provide a way of offering your users continuous access to your app's renewing content – providing them with a ...
Read more >
Guide to Auto-Renewable Subscriptions in Swift - AccuWeather
So let's dive into implementing auto-renewable subscriptions and make some money. Configure the Subscription Product. Step 1: Set up a ...
Read more >
Swift tutorial: Auto-renewable subscriptions in iOS - Apphud
Let's talk about auto-renewable subscriptions on iOS. I will show how to create, manage, purchase and validate auto-renewable subscriptions.
Read more >
Swift How to handle Auto-renewable Subscription receipt and ...
User can purchase either one month, one year auto renewable subscription or permanent permission · App should check if the subscription is still ......
Read more >

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