0
  • Currently am working with In App Purchase Auto renewal subscription.
    • Which allow user to full access of app if user subscribe the app whatever choose a plan(monthly or yearly).
      • Its working fine to get expiry date of subscription.
      • But is case of user can turn off auto renewal subscription from device setting.

Then how can we find out the status or expiry date of subscription by code.

Mayur Prajapati
  • 5,454
  • 7
  • 41
  • 70
Ayaz Rafai
  • 15
  • 5

1 Answers1

1

There are no status if subscription is active or no. You should compare subscription expiration with current date to know if subscription active.

For example I have this code in my project:

func isSubscriptionActive() -> Bool
{
    if RMStoreAppReceiptVerificator().verifyAppReceipt()
    {
        let appReceipt = RMAppReceipt.bundleReceipt()
        for object in appReceipt.inAppPurchases
        {
            if let inAppPurchase = object as? RMAppReceiptIAP
            {
                if appReceipt.containsActiveAutoRenewableSubscriptionOfProductIdentifier(inAppPurchase.productIdentifier, forDate: NSDate())
                {
                    return true
                }
            }
        }
    }
    return false
}

I'm using RMStore library.

Borys Verebskyi
  • 4,160
  • 6
  • 28
  • 42
ChikabuZ
  • 10,031
  • 5
  • 63
  • 86
  • But there how we can know auto subscription is still activated... - May user can disable auto renewal subscription by device settings. – Ayaz Rafai Jan 04 '16 at 06:15
  • containsActiveAutoRenewableSubscriptionOfProductIdentifier do it for you. It check subscriptionExpirationDate and cancellationDate. – ChikabuZ Jan 04 '16 at 08:32
  • Above code is enough to check if subscription is active. Also I recommend to read "In-App Purchase Programming Guide" and RMStore readme. – ChikabuZ Jan 04 '16 at 09:23