iOS SDK Auto Renewable subscription with RMStore - how to validate active subscription or not?

2.1k views Asked by At

I am using RMStore library to work with auto-renewable subscriptions in my iOS app. It works well for purchasing, but I can't find any documentation how to check with RMStore that current subscription is still active?

Code for checking purchased products does not worked here:

 if([persistence isPurchasedProductOfIdentifier:SUBSCRIPTION_1]) { ... }

This code is always show that Subscription was purchased (because it was) but does not check that this subscription already passed by date.

I see method "isActiveAutoRenewableSubscriptionForDate" in RMAppReceipe.h file, but I does not find any documentation how to retrive subscription receipe in my app with RMStore and how to check this receipe with isActiveAutoRenewableSubscriptionForDate method. Please help.

Summary: I just need to check that subscription @"com.fanfun.apptestsubscription1" is still active for TODAY (current date) or not. Please provide sample code for this simple check.

2

There are 2 answers

4
Denis On

I don't know if that library that you use. But if you have access to the receipt itself, You can base64 decode the receipt to get the duration of the receipt in the field "expires-date".

Check those links as well:

https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW2

and

https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html

UPDATE

[RMAppReceipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:identifier forDate:date]

should do the trick

3
Dmitry On

I think I found a solution and it work:

RMAppReceipt* appReceipt = [RMAppReceipt bundleReceipt];

NSLog(@"Is subscription 1 active: %d", [appReceipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:SUBSCRIPTION_1 forDate:[NSDate date]]);