Specifically I need to extract the expires_date information from the latest receipt.
I have auto renewing subscriptions and I want to monitor when the subscription expires.
I have not tested yet because I have not renewed my apple subscription but in theory after call the receipt verification method you receive in Success a ReceiptInfo = [String: AnyObject]
You can access this dico directly with "expitation_date" key
Or you can use ReceiptInfoField.expitation_date.rawValue
all key are described here https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1
I use this function:
func expirationDateFromResponse(jsonResponse: [String: AnyObject]) -> NSDate? {
if let receiptInfo: NSArray = jsonResponse["latest_receipt_info"] as? NSArray {
let lastReceipt = receiptInfo.lastObject as! NSDictionary
let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss VV"
let expirationDate: NSDate =
formatter.dateFromString(lastReceipt["expires_date"] as! String) as NSDate!
return expirationDate
} else {
return nil
}
}
While passing the receipt:
let expirationDate = expirationDateFromResponse(receipt)
@odedharth @Bizzi-Body That's correct. This method should be all you need:
SwiftyStoreKit.verifyReceipt(password: "your_shared_secret")
Most helpful comment
I use this function:
While passing the receipt:
let expirationDate = expirationDateFromResponse(receipt)