IOS check if autorenewal subscription is still active
See original GitHub issueVersion of react-native-iap
2.2.2
Platforms you faced the error (IOS or Android or both?)
IOS
Expected behavior
Using the RNIAP api we could check if a autorenewal subscription is still active
Actual behavior
On android im doing this to check that:
export const isUserSubscriptionActive = async (subscriptionId) =>{
// Get all the items that the user has
const availablePurchases = await getAvailablePurchases();
if(availablePurchases !== null && availablePurchases.length > 0){
const subscription = availablePurchases.find((element)=>{
return subscriptionId === element.productId;
});
if(subscription){
// check for the autoRenewingAndroid flag. If it is false the sub period is over
return subscription["autoRenewingAndroid"] == true;
}
}else{
return false;
}
}
}
On ios there is no flag to check that, and the getAvailablePurchases method returns all the purchases made, even the subscriptions that are not active at the moment.
Is there a way to check this?
Regards, Marcos
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:61 (15 by maintainers)
Top 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 >Check Subscription Status(IOS Users) | ACTIVE.com Help ...
Please follow the steps below to check if your subscription auto renewal is canceled or not. Go to phone Settings; Click iTunes &...
Read more >Check if an Auto-Renewable Subscription is still valid
Here is several ways to do receipt validation to check is user granted to subscription. Here is two ways of doing it correctly:....
Read more >Swift tutorial: Auto-renewable subscriptions in iOS - Apphud
An auto-renewable app subscription lets you monetize your apps by charging users for features, services, or content on a recurring basis.
Read more >iPhone subscriptions: How to check, cancel, and renew
Open the Settings app on iPhone or iPad · Tap your name at the top · Tap Subscriptions · You'll now see all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is the function I am using that works on both Android and iOS, properly sorting on iOS to ensure we get the latest receipt data:
I’m working on figuring this out as well. I haven’t tested it yet, but from what I’m reading I’m gathering that it’s possible by creating a “shared secret” in iTunes Connect and passing this to validateReceiptIos with the key ‘password’. I believe this will then return a JSON object which will contain a code indicating the validation status of the subscription and the keys latest_receipt, latest_receipt_info, and latest_expired_receipt info, among others, which you can use to determine the subscription status. I am literally just figuring this out so I have yet to test it. It’s what I’m putting together from the issues and Apple’s docs. If this works, it really should be made very clear in the documentation instead of being buried in the issues. I believe the following links are relevant: https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html #203 #237
EDIT: I can confirm that the process I mentioned above works. I think we should work to get a full explanation of this in the docs. I would implement something like this on app launch to determine whether a subscription has expired: