budd
budd

Reputation: 135

Expires-date in auto renewable subscription less than current date

In MKStoreKit I buy auto renewable subscription. If you buy for a year then the method checks whether the subscription is valid isSubscriptionActive returns 1. But if we assume a month, expires-date once it is less than the current date. What could be the problem?

2014-06-22 16:11:45.160 ForTraderApp[3035:60b] expiresDate = 1402747114000.000000
2014-06-22 16:11:45.161 ForTraderApp[3035:60b] currentDate = 1403439105.161849

MKStoreKit v.5 ios7.1

- (BOOL) isSubscriptionActive:(NSString*) featureId
{
   MKSKSubscriptionProduct *subscriptionProduct = [self.subscriptionProducts   objectForKey:featureId];
   if(!subscriptionProduct.receipt) return NO;

   id jsonObject = [NSJSONSerialization JSONObjectWithData:subscriptionProduct.receipt options:NSJSONReadingAllowFragments error:nil];
   NSData *receiptData = [NSData dataFromBase64String:[jsonObject objectForKey:@"latest_receipt"]];

   NSPropertyListFormat plistFormat;
   NSDictionary *payloadDict = [NSPropertyListSerialization propertyListWithData:receiptData
                                                                    options:NSPropertyListImmutable
                                                                     format:&plistFormat
                                                                      error:nil];

    receiptData = [NSData dataFromBase64String:[payloadDict objectForKey:@"purchase-info"]];

    NSDictionary *receiptDict = [NSPropertyListSerialization propertyListWithData:receiptData
                                                                    options:NSPropertyListImmutable
                                                                     format:&plistFormat
                                                                      error:nil];

    NSTimeInterval expiresDate = [[receiptDict objectForKey:@"expires-date"] doubleValue]/1000.0f;

    NSLog(@"expiresDate = %f", [[receiptDict objectForKey:@"expires-date"] doubleValue]);
    NSLog(@"date = %f", [[NSDate date] timeIntervalSince1970]);

    return expiresDate > [[NSDate date] timeIntervalSince1970];
}

Upvotes: 0

Views: 416

Answers (0)

Related Questions