|
@@ -112,9 +112,9 @@
|
|
|
for (IAPReceiptInfoModel *model in self.latestReceiptInfoModels) {
|
|
|
if ([model.product_id isEqualToString:@"com.pdfreaderpro.mac_free.member.all_access_pack_new_12months.001"]) {
|
|
|
trail = model.is_trial_period;
|
|
|
-
|
|
|
+
|
|
|
NSString *expires_date_ms = model.expires_date_ms;
|
|
|
-
|
|
|
+
|
|
|
long long expiresDate = [expires_date_ms longLongValue]/1000;
|
|
|
long long currentDate = [[NSDate date] timeIntervalSince1970];
|
|
|
BOOL _isActive = (expiresDate > currentDate) ? YES : NO;
|
|
@@ -124,7 +124,7 @@
|
|
|
count += 1;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (trail && isActive == false && count == 1) {
|
|
|
return YES;
|
|
|
}
|
|
@@ -132,3 +132,68 @@
|
|
|
}
|
|
|
|
|
|
@end
|
|
|
+
|
|
|
+@implementation IAPReceiptTool
|
|
|
+
|
|
|
++ (BOOL)isNewUserWithModel:(IAPReceiptModel *)model withGroupIdentifier:(NSString *)groupIdentifier {
|
|
|
+ if ([self hasTrialWithModel:model withGroupIdentifier:groupIdentifier]) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ([self hasIntroOfferWithModel:model withGroupIdentifier:groupIdentifier]) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
++ (BOOL)hasTrialWithModel:(IAPReceiptModel *)model withGroupIdentifier:(NSString *)groupIdentifier {
|
|
|
+ for (IAPReceiptInfoModel *m in [self fetchReceiptsWithModel:model withGroupIdentifier:groupIdentifier]) {
|
|
|
+ if (m.is_trial_period) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
++ (BOOL)hasIntroOfferWithModel:(IAPReceiptModel *)model withGroupIdentifier:(NSString *)groupIdentifier {
|
|
|
+ for (IAPReceiptInfoModel *m in [self fetchReceiptsWithModel:model withGroupIdentifier:groupIdentifier]) {
|
|
|
+ if (m.is_in_intro_offer_period) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSArray<IAPReceiptInfoModel *> *)fetchReceiptsWithModel:(IAPReceiptModel *)model withGroupIdentifier:(NSString *)groupIdentifier {
|
|
|
+ NSMutableArray *results = [NSMutableArray arrayWithCapacity:4];
|
|
|
+ for (IAPReceiptInfoModel *m in [self fetchReceiptsWithModel:model]) {
|
|
|
+ if ([m.subscription_group_identifier isEqualToString:groupIdentifier] == false) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ [results addObject:m];
|
|
|
+ }
|
|
|
+ return [results copy];
|
|
|
+}
|
|
|
+
|
|
|
++ (NSArray<IAPReceiptInfoModel *> *)fetchProductReceiptsWithModel:(IAPReceiptModel *)model withProductCode:(NSString *)productCode {
|
|
|
+ NSMutableArray *results = [NSMutableArray arrayWithCapacity:4];
|
|
|
+ for (IAPReceiptInfoModel *m in [self fetchReceiptsWithModel:model]) {
|
|
|
+ if ([m.product_id isEqualToString:productCode] == false) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ [results addObject:m];
|
|
|
+ }
|
|
|
+ return [results copy];
|
|
|
+}
|
|
|
+
|
|
|
++ (NSArray<IAPReceiptInfoModel *> *)fetchReceiptsWithModel:(IAPReceiptModel *)model {
|
|
|
+ NSMutableArray *results = [NSMutableArray arrayWithCapacity:4];
|
|
|
+ for (IAPReceiptInfoModel *m in model.latestReceiptInfoModels) {
|
|
|
+ [results addObject:m];
|
|
|
+ }
|
|
|
+ for (IAPReceiptInfoModel *m in model.receiptModel.inAppModels) {
|
|
|
+ [results addObject:m];
|
|
|
+ }
|
|
|
+ return [results copy];
|
|
|
+}
|
|
|
+
|
|
|
+@end
|