MKStoreKit icon indicating copy to clipboard operation
MKStoreKit copied to clipboard

expiryDateForProduct triggers an exception when self.purchaseRecord[productId] == null

Open jonlidgard opened this issue 9 years ago • 2 comments

-(NSDate*) expiryDateForProduct:(NSString*) productId {

NSNumber *expiresDateMs = self.purchaseRecord[productId]; ---> return [NSDate dateWithTimeIntervalSince1970:[expiresDateMs doubleValue] / 1000.0f]; }

This line causes an exception if expiresDateMs == [NSNull null]; Exception "NSInvalidArgumentException", "-[NSNull doubleValue]: unrecognized selector sent to instance

jonlidgard avatar Apr 13 '15 15:04 jonlidgard

I have the same issue. @jonlidgard, did you find a solution to check the expiration?

rcilia avatar May 26 '15 20:05 rcilia

I just modded the function to return nil if productId == [NSNull null]:

-(NSDate*) expiryDateForProduct:(NSString*) productId {

  NSNumber *expiresDateMs = self.purchaseRecord[productId];
  NSDate *expiryDate;
  if (expiresDateMs && ![expiresDateMs isKindOfClass:[NSNull class]]) {
    expiryDate = [NSDate dateWithTimeIntervalSince1970:[expiresDateMs doubleValue] / 1000.0f];
  }
  return expiryDate;
}

jonlidgard avatar Jun 08 '15 12:06 jonlidgard