robotmedia / RMStore

A lightweight iOS library for In-App Purchases
Apache License 2.0
2.42k stars 450 forks source link

Overly constrained date gating in active autorenewal check results in false negatives #199

Open lzell opened 7 years ago

lzell commented 7 years ago

Greetings,

The date constraint found here: https://github.com/robotmedia/RMStore/blob/master/RMStore/Optional/RMAppReceipt.m#L389 outputs false if the purchase date of a renewable IAP lies after the date we are checking against. This seems like a reasonable assumption to make, but per the guidance here (which is good advice because I have seen this lapse in production):

@warning Auto-renewable subscription lapses are possible. If you are checking against the current date, you might want to deduct some time as tolerance.

we are subtracting a day from the current time and passing the resulting date into containsActiveAutoRenewableSubscription. The result is that the check is returning false on what should be an active subscription if the check is performed within 1 day (or whatever grace period is set) of purchasing.

I can submit a PR easily to fix this by dropping the first condition of the date comparison, but want to make sure there are no adverse effects that I am not considering. My proposed fix is to change this:

return [self.purchaseDate compare:date] != NSOrderedDescending && [date compare:self.subscriptionExpirationDate] != NSOrderedDescending; to this:

return [date compare:self.subscriptionExpirationDate] != NSOrderedDescending;

Thanks for the hard work on RMStore!

Lou