Swiftystorekit: how to identify trial period is over in auto-renewable subscription

Created on 14 Nov 2016  Â·  3Comments  Â·  Source: bizz84/SwiftyStoreKit

@bizz84 Please help asap.

Platform

  • [x] iOS

In app purchase type

  • [x] Auto-Renewable Subscription

Environment

  • [x] Sandbox
  • [x] Production

Version

ℹ 0.5.0

Issue summary

In SwiftyStorekit framework, is there any way i can identify that trial period is over in sandbox/production environment for auto-renewable subscription. also is there any need that i should store receipt at my side. i just want to show to user in my application that your trial period is over & it is renewed. how can i check that user cancel subscription in auto-renewable? subscription.

What did you expect to happen

1.Please share solution to all my question , i am completely confused.

question

All 3 comments

@cwinUser apologies for the very late reply, this has not been fixed until recently.

Trial Period

Starting from version 0.9.0, you can now verify if a subscription is within the trial period or not.

The result returned when you call verifySubscription will tell you if the subscription is purchased or expired:

// Verify subscription result
public enum VerifySubscriptionResult {
    case purchased(expiryDate: Date, items: [ReceiptItem])
    case expired(expiryDate: Date, items: [ReceiptItem])
    case notPurchased
}

You can read the latest subscription period like this:

switch result {
case .purchased(let expiryDate, let items): 
  if let mostRecent = items.first {
     print("Active, isTrial: \(mostRecent.isTrialPeriod)")
  }
case .expired(let expiryDate, let items):
  if let mostRecent = items.first {
     print("Expired, isTrial: \(mostRecent.isTrialPeriod)")
  }
case .notPurchased:
}

Storing receipt

You don't need to store the receipt yourself, it is already done automatically by StoreKit.

Cancellation

SwiftyStoreKit treats a cancelled product as if the product was never purchased (see https://github.com/bizz84/SwiftyStoreKit/pull/164). This is in accord with Apple guidelines:

Treat a canceled receipt the same as if no purchase had ever been made.

Hope this answers your questions.

I'm going to close this for now, however feel free to reopen if you need more clarifications.

Hi, How does it handle multiple subscription options? What does "VerifySubscriptionResult" represent exactly?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rdforte picture rdforte  Â·  3Comments

designedbyadam picture designedbyadam  Â·  4Comments

AdieOlami picture AdieOlami  Â·  9Comments

Sam-Spencer picture Sam-Spencer  Â·  5Comments

jlaws picture jlaws  Â·  6Comments