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 detect expired auto renewable subscriptions?

See original GitHub issue

I’m currently using react-native-iap 4.5.0 and fetching my subscriptions with RNIap.getAvailablePurchases()

Also on my back-end server I’m requesting to https://sandbox.itunes.apple.com/verifyReceipt Apple endpoint for receipts.

That endpoint returns all receipts with this data. With some logic I can handle subscription status of my users at back-end. But it is more complicated in some situations.

{
                "quantity": "1",
                "product_id": "XXX",
                "transaction_id": "1000000694388870",
                "original_transaction_id": "1000000692806652",
                "purchase_date": "2020-07-14 15:06:37 Etc/GMT",
                "purchase_date_ms": "1594739197000",
                "purchase_date_pst": "2020-07-14 08:06:37 America/Los_Angeles",
                "original_purchase_date": "2020-07-17 10:42:15 Etc/GMT",
                "original_purchase_date_ms": "1594982535000",
                "original_purchase_date_pst": "2020-07-17 03:42:15 America/Los_Angeles",
                "expires_date": "2020-07-14 15:11:37 Etc/GMT",
                "expires_date_ms": "1594739497000",
                "expires_date_pst": "2020-07-14 08:11:37 America/Los_Angeles",
                "web_order_line_item_id": "1000000054037348",
                "is_trial_period": "false",
                "is_in_intro_offer_period": "false"
            },

My questions is; How can I use only my app to check subscription’s expire status without back-end service?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
camel113commented, Jul 28, 2020

I guess you could validate a subscription with the following code:

const result = await validateReceiptIos(receiptBody, true);
const lastSubscriptionBasic = result.latest_receipt_info
        .filter(item => item.product_id === "subscription_basic") // keep only the "subscription_basic" subscriptions
        .sort((a, b) => b.expires_date_ms - a.expires_date_ms)[0]; // sort by expiration date and get the first one
const isSubscriptionBasicValid = lastSubscriptionBasic.expires_date_ms > moment() // check if expiration date is before now
0reactions
stale[bot]commented, Jan 19, 2021

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

checking if an auto-rewew subscription expired
1) If the app detect that the subscription has expired it adds a transaction observer and awaits a call to updatedTransactions with a...
Read more >
Checking auto-renewable subscriptions for expiration
According to Apple's Validate App Store Receipt, you should use expires_date . This key is only present for auto-renewable subscription ...
Read more >
The Ultimate Handbook On App-Store Receipt Validation
Indicates whether an auto-renewable subscription will renew at the end of the current subscription period. “1” illustrates that it will and “0” shows...
Read more >
Microsoft 365 Developer Program subscription expiration and ...
You can determine whether you have a renewable or non-renewable subscription by viewing your Microsoft 365 Developer Program dashboard.
Read more >
Swift tutorial: Auto-renewable subscriptions in iOS - Apphud
How often you should validate a receipt to get the latest subscription info? Probably the good way is to call once during the...
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