MKStoreKit
MKStoreKit copied to clipboard
expiryDateForProduct triggers an exception when self.purchaseRecord[productId] == null
-(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
I have the same issue. @jonlidgard, did you find a solution to check the expiration?
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;
}