Because the title states, I am in search of the right format of the Apple auto-renewable subscription “expires_date”.
The “expires_date” subject comes from App Retailer receipt json knowledge.
for instance:
[{
"quantity": "1",
"product_id": "test2",
"transaction_id": "1000000472106082",
"original_transaction_id": "1000000472106082",
"purchase_date": "2018-11-13 16:46:31 Etc/GMT",
"purchase_date_ms": "1542127591000",
"purchase_date_pst": "2018-11-13 08:46:31 America/Los_Angeles",
"original_purchase_date": "2018-11-13 16:46:31 Etc/GMT",
"original_purchase_date_ms": "1542127591000",
"original_purchase_date_pst": "2018-11-13 08:46:31 America/Los_Angeles",
"is_trial_period": "false",
"expires_date" : "2023-05-24 18:01:31 Etc/GMT"
}]
I am utilizing:
@"yyyy-MM-dd HH:mm:ss VV"
I see usually see dates like:
2023-05-24 18:01:31 And so on/GMT
This seems to work more often than not. Nonetheless, there are instances the place it seems to be failing, usually, however not all the time I see extra failures from iOS units within the UK. I do not know what the date string seems to be like in these instances, sadly, as this code is being carried out on the gadget.
There is no such thing as a info on the apple developer web site as to the right format. There’s a deprecated doc that states its RFC3339 date format. Nonetheless, this isn’t right. Additionally it is not ISO8601 format.
BTW, this is principally the code I am utilizing.
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss VV";
formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
NSDate* expireDate = [formatter dateFromString:expireDate];
I then evaluate it to now with a date created like:
NSDate* nowDate = [NSDate date];
if(([nowDate compare:expireDate] == NSOrderedDescending) ||
([nowDate compare:bufferDate] == NSOrderedSame))
{
//the subscription has expired
retVal = true;
}
Like I stated a overwhelming majority of the time the format I offered works, however sometimes it doesn’t. So I believe a difficulty with the format of the expires_date subject.