I am using the below code for getting expiry date from the receipt validation response and it is failing for some users only (in production) and works fine for others.
Can anyone spot what I am doing wrong here? Any comments will be appreciated.
func getExpirationDateFromResponse(_ jsonResponse: NSDictionary) -> Bool{
if let receiptInfo: NSArray = jsonResponse["latest_receipt_info"] as? NSArray {
var hasActiveSubscription : Bool = false
for receipt in receiptInfo {
let receipt_ = receipt as! NSDictionary
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss VV"
if let date = formatter.date(from: receipt_["expires_date"] as! String) {
if date > Date() {
hasActiveSubscription = true
break;
}
}
}
return hasActiveSubscription
}
else {
return false
}
}