Browse Source

【综合】导入文件完善

niehaoyu 1 year ago
parent
commit
3d558e2857

+ 10 - 0
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -2673,6 +2673,9 @@
 		BB1AEF3529F937A50048D179 /* PDF Master User Guide.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BB1AEF3429F937A50048D179 /* PDF Master User Guide.pdf */; };
 		BB1AEF3629F937A50048D179 /* PDF Master User Guide.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BB1AEF3429F937A50048D179 /* PDF Master User Guide.pdf */; };
 		BB1AEF3729F937A60048D179 /* PDF Master User Guide.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BB1AEF3429F937A50048D179 /* PDF Master User Guide.pdf */; };
+		BB1B0A9D2B4FB88100889528 /* IAPProductsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BB1B0A9B2B4FB88000889528 /* IAPProductsManager.m */; };
+		BB1B0A9E2B4FB88100889528 /* IAPProductsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BB1B0A9B2B4FB88000889528 /* IAPProductsManager.m */; };
+		BB1B0A9F2B4FB88100889528 /* IAPProductsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BB1B0A9B2B4FB88000889528 /* IAPProductsManager.m */; };
 		BB1BFF5D2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF5C2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift */; };
 		BB1BFF5E2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF5C2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift */; };
 		BB1BFF5F2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF5C2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift */; };
@@ -5664,6 +5667,8 @@
 		BB1A916D2AFB7871005E5FD8 /* KMConvertWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMConvertWindowController.xib; sourceTree = "<group>"; };
 		BB1A91722AFB8D95005E5FD8 /* KMBookletMaskView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBookletMaskView.swift; sourceTree = "<group>"; };
 		BB1AEF3429F937A50048D179 /* PDF Master User Guide.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "PDF Master User Guide.pdf"; sourceTree = "<group>"; };
+		BB1B0A9B2B4FB88000889528 /* IAPProductsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IAPProductsManager.m; sourceTree = "<group>"; };
+		BB1B0A9C2B4FB88000889528 /* IAPProductsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IAPProductsManager.h; sourceTree = "<group>"; };
 		BB1BFF5C2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchOperateBaseWindowController.swift; sourceTree = "<group>"; };
 		BB1BFF602AE9FA6C003EB179 /* KMBatchOperateBaseWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMBatchOperateBaseWindowController.xib; sourceTree = "<group>"; };
 		BB1BFF642AE9FBA7003EB179 /* KMBatchOperateWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMBatchOperateWindowController.xib; sourceTree = "<group>"; };
@@ -10948,6 +10953,8 @@
 		BBA9220F2B4E77BA0061057A /* Purchase */ = {
 			isa = PBXGroup;
 			children = (
+				BB1B0A9C2B4FB88000889528 /* IAPProductsManager.h */,
+				BB1B0A9B2B4FB88000889528 /* IAPProductsManager.m */,
 				BBA922112B4E77D10061057A /* Appstore */,
 				BBA922102B4E77CA0061057A /* DMG */,
 				BBA9221B2B4E7AF50061057A /* Category */,
@@ -13949,6 +13956,7 @@
 				AD0FA4F029A8580D00EDEB50 /* KMComparativeTableView.swift in Sources */,
 				89D2D2DE294C451400BFF5FE /* KMThumbnailViewController.swift in Sources */,
 				ADB2D6ED2947415E0029D2B3 /* KMPrintPaperSetView.swift in Sources */,
+				BB1B0A9D2B4FB88100889528 /* IAPProductsManager.m in Sources */,
 				BB147026299DC0D100784A6A /* OIDTokenRequest.m in Sources */,
 				BB3EAEAD293E3D6000D92407 /* KMConvertBaseWindowController.swift in Sources */,
 				BB2F61582966B69D001CB369 /* KMWatermarkPropertyHomeController.swift in Sources */,
@@ -14606,6 +14614,7 @@
 				BB74DA7C2AC41DE9006EDFE7 /* NSString+KMExtension.swift in Sources */,
 				ADDEEA972AD7A0F300EF675D /* TextFieldFormatter.swift in Sources */,
 				BB3198172AC55E6D00107371 /* CPDFDocument+KMExtension.swift in Sources */,
+				BB1B0A9E2B4FB88100889528 /* IAPProductsManager.m in Sources */,
 				BBA00ACA2B1604D30043D903 /* KMBotaTableRowView.swift in Sources */,
 				BBEC00C8295C319400A26C98 /* KMBatesManager.swift in Sources */,
 				ADA9102B2A272CE2003352F0 /* KMEditPDFTextManager.swift in Sources */,
@@ -15619,6 +15628,7 @@
 				BB3D97182B3023C5007094C8 /* KMCustomButton.swift in Sources */,
 				BBFEF71D2B3A784200C28AC0 /* KMSystemEditMenu.swift in Sources */,
 				BB6B4C0A292F53CE0071CA06 /* KMMergeFileModel.swift in Sources */,
+				BB1B0A9F2B4FB88100889528 /* IAPProductsManager.m in Sources */,
 				9F0CB4B72977BC1000007028 /* KMPropertiesPanelPreviewSubVC.swift in Sources */,
 				BB3A81B72AC2C0F4006FC66C /* NSObject+KMExtension.swift in Sources */,
 				BB88106F2B4F771D00AFA63E /* KMVerificationInfoViewController.m in Sources */,

+ 3 - 3
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseLimitWindowController.swift

@@ -172,9 +172,9 @@ class KMPurchaseLimitWindowController: NSWindowController {
             }
             self.removeWaitingView(self.contendView)
             
-//            if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
-//                self.close()
-//            }
+            if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
+                self.close()
+            }
         }
         self.addWaingView(self.contendView)
     }

+ 3 - 3
PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.m

@@ -238,9 +238,9 @@ static KMVerificationWindowController *_currentWindowController = nil;
         _alertViewController.buyActionHandle = ^{
 #if VERSION_DMG
             NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/store"];
-            if([SKInspectPublicTool currentisLanguageHans]) {
-                url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store"];
-            }
+//            if([SKInspectPublicTool currentisLanguageHans]) {
+//                url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store"];
+//            }
             [[NSWorkspace sharedWorkspace] openURL:url];
 #endif
 //            [[FMTrackEventManager manager] trackEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_BuyNow-Trial"}];

+ 6 - 6
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.h

@@ -9,12 +9,12 @@
 //
 
 #import <Foundation/Foundation.h>
-#import "PDF_Master-Bridging-Header.h"
-#if VERSION_DMG
-#import <PDF_Master-Swift.h>
-#else
-#import <PDF_Master-Swift.h>
-#endif
+//#import "PDF_Master-Bridging-Header.h"
+//#if VERSION_DMG
+//#import <PDF_Master-Swift.h>
+//#else
+//#import <PDF_Master-Swift.h>
+//#endif
 
 
 #define kTestMode   0

+ 66 - 0
PDF Office/PDF Master/Class/Purchase/IAPProductsManager.h

@@ -0,0 +1,66 @@
+//
+//  IAPProductsManager.h
+//  PDF Reader Pro Edition
+//
+//  Created by 王帅 on 2017/7/10.
+//
+//
+
+#import <Foundation/Foundation.h>
+
+extern NSString * const KMIAPProductLoadedNotification;
+extern NSString * const KMIAPProductFailedNotification;
+extern NSString * const KMIAPProductPurchasedNotification;
+extern NSString * const KMIAPProductRestoreFailedNotification;
+extern NSString * const KMIAPProductRestoreFinishedNotification;
+extern NSString * const KMIAPSubscriptionLoadedNotification;
+
+@class SKProduct;
+
+@interface IAPProduct : NSObject
+
+@property (nonatomic,readonly) BOOL isSubscribed;
+
+@property (nonatomic,readonly) BOOL isOffers;
+@property (nonatomic,readonly) CGFloat offers;
+
+@property (nonatomic,readonly) BOOL originalPurchased;//针对订阅套餐,表示当前ID是否购买过,判断是否过期。
+
+@property (nonatomic, readonly) BOOL isTrialPeriod;//判断当前套餐是否试用过
+
+#if !VERSION_DMG
+@property (nonatomic,retain) SKProduct *product;
+#endif
+
+- (NSString *)price;
+- (NSString *)averagePrice;
+
+- (NSString *)offersPrice;
+- (NSString *)offersAveragePrice;
+
+@end
+
+@interface IAPProductsManager : NSObject
+
+@property (nonatomic,readonly) IAPProduct *monthProduct;
+@property (nonatomic,readonly) IAPProduct *newlyMonthProduct;
+@property (nonatomic,readonly) IAPProduct *allAccessProduct;
+@property (nonatomic,readonly) IAPProduct *PDFToOfficeProduct;
+
+@property (nonatomic,readonly) IAPProduct *DMGAllAccessProduct;
+@property (nonatomic,readonly) IAPProduct *DMGPDFToOfficeProduct;
+
++ (IAPProductsManager *)defaultManager;
+
+- (void)initIAP;
+
+- (void)loadAllProducts;
+
+- (void)loadProducts;
+- (void)makeProduct:(IAPProduct *)iapProduct;
+- (void)restoreSubscriptions;
+
+- (BOOL)isAvailableAllFunction;
+- (BOOL)isAvailableAdvancedPDFToOffice;
+
+@end

+ 829 - 0
PDF Office/PDF Master/Class/Purchase/IAPProductsManager.m

@@ -0,0 +1,829 @@
+//
+//  IAPProductsManager.m
+//  PDF Reader Pro Edition
+//
+//  Created by 王帅 on 2017/7/10.
+//
+//
+
+#import "IAPProductsManager.h"
+#if !VERSION_DMG
+#import <StoreKit/StoreKit.h>
+#endif
+
+#import "VerificationManager.h"
+#import "NSNULL+Filtration.h"
+
+NSString *const KMStoreLiteKitSecret = @"d8286a8909884e64b84d522305f07463";
+NSString *const KMStoreKitSecret = @"b88b5d687d1547c2ad3c4dd882dec9db";
+//NSString *const KMSandboxServer = @"https://sandbox.itunes.apple.com/verifyReceipt";
+//NSString *const KMItunesServer = @"https://buy.itunes.apple.com/verifyReceipt";
+
+NSString *const KMSandboxServer = @"http://test-store.kdan.cn:3019/api/subscriptions/verify_itunes";
+NSString *const KMItunesServer = @"https://store.filmagepro.com:3018/api/subscriptions/verify_itunes";
+NSString *const KMStoreReceipt = @"KMStoreReceiptKey";
+
+NSString * const KMMonthLicenseProductIdentifier = @"com.pdfreaderpro.mac_free.member.all_access_pack_6months.001";
+NSString * const KMNewMonthLicenseProductIdentifier = @"com.pdfreaderpro.mac_free.member.all_access_pack_new_6months.001";
+//NSString * const KMNewMonthLicenseProductIdentifier = @"com.pdftechnologies.pdfreader.mac.yearly.002.Test";
+NSString * const KMAllLicenseProductIdentifier = @"com.pdfreaderpro.mac_free.member.all_access_pack_permanent_license.001";
+NSString * const KMPDFToOfficeLicenseProductIdentifier = @"com.pdfreaderpro.mac.member.pdf_to_office_pack_permanent_license.001";
+
+NSString * const KMIAPProductLoadedNotification = @"KMIAPProductLoadedNotification";
+NSString * const KMIAPProductFailedNotification = @"KMIAPProductFailedNotification";
+NSString * const KMIAPProductPurchasedNotification = @"KMIAPProductPurchasedNotification";
+NSString * const KMIAPProductRestoreFailedNotification = @"KMIAPProductRestoreFailedNotification";
+NSString * const KMIAPProductRestoreFinishedNotification = @"KMIAPProductRestoreFinishedNotification";
+NSString * const KMIAPSubscriptionLoadedNotification = @"KMIAPSubscriptionLoadedNotification";
+
+@interface IAPProduct ()
+
+@property (nonatomic,assign) BOOL isSubscribed;
+
+@property (nonatomic,retain) NSNumber *priceNumber;
+
+@property (nonatomic,assign) BOOL isOffers;
+@property (nonatomic,assign) CGFloat offers;
+@property (nonatomic,retain) NSNumber *offersPriceNumber;
+
+@property (nonatomic,retain) NSString *productIdentifier;
+
+@property (nonatomic,assign) BOOL originalPurchased;//针对订阅套餐,表示当前ID是否购买过,判断是否过期。
+
+@property (nonatomic, assign) BOOL isTrialPeriod;//判断当前套餐是否试用过
+
+@end
+
+@implementation IAPProduct
+
+#pragma mark - Init Methods
+
+- (void)dealloc {
+    
+}
+
+#pragma mark - Public Methods
+
+- (NSString *)price {
+    NSString *price = nil;
+#if !VERSION_DMG
+    if (self.product.price) {
+        price = [self formattedPrice:NO];
+    } else {
+        price = [NSString stringWithFormat:@"USD $%0.2f", [self.priceNumber doubleValue]];
+#ifndef VERSION_DMG
+        // 获取产品价格信息
+        [[IAPProductsManager defaultManager] loadAllProducts];
+#endif
+    }
+#endif
+    price = price ? : @"";
+    return price;
+}
+
+- (NSString *)averagePrice {
+    NSString *price = nil;
+#if !VERSION_DMG
+    if (self.product.price) {
+        price = [self formattedPrice:YES];
+    } else {
+        if (self.priceNumber) {
+            price = [NSString stringWithFormat:@"USD $%0.2f", [self.priceNumber doubleValue]/6.0];
+        }
+#ifndef VERSION_DMG
+        // 获取产品价格信息
+        [[IAPProductsManager defaultManager] loadAllProducts];
+#endif
+    }
+#endif
+    price = price ? : @"";
+    return price;
+}
+
+- (NSString *)offersPrice {
+    NSString *price = nil;
+    if (self.offersPriceNumber) {
+        price = [NSString stringWithFormat:@"USD $%0.2f", [self.offersPriceNumber doubleValue]];
+    }
+    price = price ? : @"";
+    return price;
+}
+
+- (NSString *)offersAveragePrice {
+    NSString *price = nil;
+    if (self.offersPriceNumber) {
+        price = [NSString stringWithFormat:@"USD $%0.2f", [self.offersPriceNumber doubleValue]/6.0];
+    }
+    price = price ? : @"";
+    return price;
+}
+
+- (CGFloat)offers {
+    return [self.offersPriceNumber doubleValue]/[self.priceNumber doubleValue];
+}
+
+#pragma mark - Private Methods
+
+- (NSString *)formattedPrice:(BOOL)isAverage {
+    NSString *formattedString = nil;
+#if !VERSION_DMG
+    SKProduct *product = self.product;
+    if (product && [product.productIdentifier isEqualToString:self.productIdentifier]) {
+        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
+        [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
+        [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
+        [numberFormatter setLocale:product.priceLocale];
+        if (isAverage) {
+            NSNumber *number = [NSNumber numberWithDouble:[product.price doubleValue]/6.0];
+            formattedString = [numberFormatter stringFromNumber:number];
+        } else {
+            formattedString = [numberFormatter stringFromNumber:product.price];
+        }
+    }
+#endif
+    return formattedString;
+}
+
+@end
+
+@interface IAPProductsManager ()
+#if !VERSION_DMG
+<SKProductsRequestDelegate,SKPaymentTransactionObserver>
+#endif
+
+@property (nonatomic,retain) IAPProduct *monthProduct;
+@property (nonatomic,retain) IAPProduct *newlyMonthProduct;
+@property (nonatomic,retain) IAPProduct *allAccessProduct;
+@property (nonatomic,retain) IAPProduct *PDFToOfficeProduct;
+
+@property (nonatomic,retain) IAPProduct *DMGAllAccessProduct;
+@property (nonatomic,retain) IAPProduct *DMGPDFToOfficeProduct;
+
+@property (nonatomic,retain) NSArray *productIdentifiers;
+
+@property (nonatomic,assign) BOOL isPurchasing;
+
+@end
+
+@implementation IAPProductsManager
+
+#pragma mark - Init Methods
+
+- (id)init {
+    if (self = [super init]) {
+        BOOL isOffers = NO;
+        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+        dateFormatter.dateFormat = @"yyyy-MM-dd";
+        NSDate *offersDate = [dateFormatter dateFromString:@"2019-07-20"];
+        NSDate *date = [NSDate date];
+        if (NSOrderedDescending == [offersDate compare:date]) {
+            isOffers = YES;
+        }
+#if VERSION_DMG
+        // 桌机版
+        self.DMGAllAccessProduct = [[IAPProduct alloc] init];
+        self.DMGAllAccessProduct.priceNumber = @(79.99);
+        self.DMGAllAccessProduct.offersPriceNumber = @(59.99);
+        self.DMGAllAccessProduct.isOffers = isOffers;
+        
+        self.DMGPDFToOfficeProduct = [[IAPProduct alloc] init];
+        self.DMGPDFToOfficeProduct.priceNumber = @(19.99);
+        self.DMGPDFToOfficeProduct.offersPriceNumber = @(9.99);
+        self.DMGPDFToOfficeProduct.isOffers = isOffers;
+#else
+        
+#if VERSION_FREE
+        // 免费版
+        self.monthProduct = [[IAPProduct alloc] init];
+        self.monthProduct.productIdentifier = KMMonthLicenseProductIdentifier;
+        self.monthProduct.priceNumber = @(29.99);
+        
+        self.newlyMonthProduct = [[IAPProduct alloc] init];
+        self.newlyMonthProduct.productIdentifier = KMNewMonthLicenseProductIdentifier;
+        self.newlyMonthProduct.priceNumber = @(39.99);
+        self.newlyMonthProduct.offersPriceNumber = @(29.99);
+        self.newlyMonthProduct.isOffers = isOffers;
+        
+        self.allAccessProduct = [[IAPProduct alloc] init];
+        self.allAccessProduct.productIdentifier = KMAllLicenseProductIdentifier;
+        self.allAccessProduct.priceNumber = @(79.99);
+        self.allAccessProduct.offersPriceNumber = @(59.99);
+        self.allAccessProduct.isOffers = isOffers;
+        
+        if ([[NSUserDefaults standardUserDefaults] objectForKey:@"allAccessProduct.isSubscribed"]) {
+            self.allAccessProduct.isSubscribed = [[[NSUserDefaults standardUserDefaults] objectForKey:@"allAccessProduct.isSubscribed"] boolValue];
+        }
+        
+        self.productIdentifiers = @[KMMonthLicenseProductIdentifier,
+                                    KMNewMonthLicenseProductIdentifier,
+                                    KMAllLicenseProductIdentifier];
+#else
+        // 付费版
+        self.PDFToOfficeProduct = [[IAPProduct alloc] init];
+        self.PDFToOfficeProduct.productIdentifier = KMPDFToOfficeLicenseProductIdentifier;
+        self.PDFToOfficeProduct.priceNumber = @(19.99);
+        self.PDFToOfficeProduct.offersPriceNumber = @(9.99);
+        self.PDFToOfficeProduct.isOffers = isOffers;
+        
+        if ([[NSUserDefaults standardUserDefaults] objectForKey:@"PDFToOfficeProduct.isSubscribed"]) {
+            self.PDFToOfficeProduct.isSubscribed = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PDFToOfficeProduct.isSubscribed"] boolValue];
+        }
+        
+        self.productIdentifiers = @[KMPDFToOfficeLicenseProductIdentifier];
+#endif
+        
+#endif
+    }
+    return self;
+}
+
+- (void)dealloc {
+#if !VERSION_DMG
+    [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
+#endif
+
+}
+
+#pragma mark - Public Methods
+
++ (IAPProductsManager *)defaultManager {
+    static IAPProductsManager *singleton = nil;
+    static dispatch_once_t pred;
+    dispatch_once(&pred, ^{
+        singleton = [[IAPProductsManager alloc] init];
+    });
+    return singleton;
+}
+
+- (void)initIAP {
+#if !VERSION_DMG
+    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
+#endif
+    [self loadAllProducts];
+    [self loadProducts];
+}
+
+- (void)loadProducts {
+#if !VERSION_DMG
+    if ([[NSUserDefaults standardUserDefaults] objectForKey:KMStoreReceipt]) {
+        NSDictionary *jsonResponse = [[NSUserDefaults standardUserDefaults] objectForKey:KMStoreReceipt];
+        [self fetchReceipt:jsonResponse];
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPSubscriptionLoadedNotification
+                                                            object:nil];
+    }
+    [self loadReceipt:^(NSError *error) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPSubscriptionLoadedNotification
+                                                            object:nil];
+    }];
+#endif
+}
+
+- (void)makeProduct:(IAPProduct *)iapProduct {
+#if !VERSION_DMG
+    if (![SKPaymentQueue canMakePayments]) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductFailedNotification
+                                                            object:iapProduct.productIdentifier];
+        return;
+    } else if (!iapProduct.product) {
+        [self loadAllProducts];
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductFailedNotification
+                                                            object:iapProduct.productIdentifier];
+        return;
+    }
+    SKPayment *payment = [SKPayment paymentWithProduct:iapProduct.product];
+    [[SKPaymentQueue defaultQueue] addPayment:payment];
+#endif
+}
+
+- (void)restoreSubscriptions {
+#if !VERSION_DMG
+    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
+#endif
+}
+
+- (BOOL)isAvailableAllFunction {
+#if VERSION_DMG
+    // 桌机版
+    VerificationManager *tManager = [VerificationManager manager];
+    BOOL tLicenseOK = NO;
+    switch ([tManager status]) {
+        case ActivityStatusTrial:
+        case ActivityStatusVerification:
+        {
+            tLicenseOK = YES;
+        }
+            break;
+        default:
+            break;
+    }
+    return tLicenseOK;
+#else
+    
+#if VERSION_FREE
+    // 免费版
+    if (self.monthProduct.isSubscribed ||
+        self.newlyMonthProduct.isSubscribed ||
+        self.allAccessProduct.isSubscribed) {
+        return YES;
+    }
+    return NO;
+#else
+    // 付费版
+    return YES;
+#endif
+    
+#endif
+}
+
+- (BOOL)isAvailableAdvancedPDFToOffice {
+#if VERSION_DMG
+    // 桌机版
+    VerificationManager *tManager = [VerificationManager manager];
+    BOOL tLicenseOK = NO;
+    switch ([tManager status]) {
+        case ActivityStatusTrial:
+        case ActivityStatusVerification:
+        {
+            NSString *product_code = [VerificationManager manager].detailInfo[@"device"][@"product_code"];
+            if ([product_code isEqualToString:@"com.brother.pdfreaderpro.mac.product_2"] ||
+                [product_code isEqualToString:@"com.brother.pdfreaderpro.mac.product_3"] ||
+                [product_code isEqualToString:@"com.brother.pdfreaderpro.cross.platform.product_3"] ||
+                [product_code isEqualToString:@"com.brother.pdfreaderpro.windows.product_3+com.brother.pdfreaderpro.mac.product_3"])
+            {
+                tLicenseOK = YES;
+            }
+        }
+            break;
+        default:
+            break;
+    }
+    return tLicenseOK;
+#else
+    
+#if VERSION_FREE
+    // 免费版
+    if (self.monthProduct.isSubscribed ||
+        self.newlyMonthProduct.isSubscribed ||
+        self.allAccessProduct.isSubscribed) {
+        return YES;
+    }
+    return NO;
+#else
+    // 付费版
+    if (self.PDFToOfficeProduct.isSubscribed) {
+        return YES;
+    }
+    return NO;
+#endif
+    
+#endif
+}
+
+#if !VERSION_DMG
+#pragma mark - Private Methods
+
+- (void)loadReceipt:(void (^)(NSError *error))handler {
+    NSURL *receiptURL  = [[NSBundle mainBundle] appStoreReceiptURL];
+    BOOL isPresent = [receiptURL checkResourceIsReachableAndReturnError:nil];
+    if (!isPresent) {
+        SKReceiptRefreshRequest *refreshRequest = [[SKReceiptRefreshRequest alloc] init];
+        [refreshRequest start];
+        if (handler) {
+            handler([NSError errorWithDomain:@"" code:0 userInfo:nil]);
+        }
+        return;
+    }
+    NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL];
+    if (!receiptData) {
+        if (handler) {
+            handler([NSError errorWithDomain:@"" code:0 userInfo:nil]);
+        }
+        return;
+    }
+    NSString *bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]?:@"";
+    NSString *temptransactioReceipt = [self encode:((uint8_t*)[receiptData bytes]) length:receiptData.length];//编码
+
+    temptransactioReceipt = [temptransactioReceipt stringByReplacingOccurrencesOfString:@"\n" withString:@""];
+    temptransactioReceipt = [temptransactioReceipt stringByReplacingOccurrencesOfString:@" " withString:@""];
+    
+    NSMutableDictionary *payLoad = [NSMutableDictionary dictionary];
+    [payLoad setObject:temptransactioReceipt forKey:@"receipt_data"];
+    [payLoad setObject:bundleID forKey:@"app_code"];
+    [payLoad setObject:@(0) forKey:@"sandbox"];
+    
+#if DEBUG
+    NSURL *url = [NSURL URLWithString:KMSandboxServer];
+#else
+    NSURL *url = [NSURL URLWithString:KMItunesServer];
+#endif
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//        ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
+//        request.defaultResponseEncoding = NSUTF8StringEncoding;
+//        request.timeOutSeconds = 20;
+//        request.numberOfTimesToRetryOnTimeout = 3;
+//        [request setRequestMethod:@"POST"];
+//        [request setRequestHeaders:[NSMutableDictionary dictionaryWithObject:@"application/json" forKey:@"Content-Type"]];
+//        [request setPostBody:[IAPProductsManager mutableDataWithDic:payLoad]];
+//        [request startSynchronous];
+//        NSError *error = request.error;
+//        BOOL isSuccessful = NO;
+//        if (!error) {
+//            NSDictionary *jsonResponse = [[request.responseString objectFromJSONString] filterNullObject];
+//            isSuccessful = [self fetchReceipt:jsonResponse[@"data"]];
+//            if (isSuccessful) {
+//                [[NSUserDefaults standardUserDefaults] setObject:jsonResponse[@"data"] forKey:KMStoreReceipt];
+//                [[NSUserDefaults standardUserDefaults] synchronize];
+//            } else {
+//                error = [[[NSError alloc] init] autorelease];
+//            }
+//        }
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            if (handler) {
+//                handler(error);
+//            }
+//        });
+//    });
+}
+
+- (BOOL)fetchReceipt:(NSDictionary *)jsonResponse
+{
+    if (![jsonResponse objectForKey:@"latest_receipt_info"] &&
+        ![[jsonResponse objectForKey:@"receipt"] objectForKey:@"in_app"]) {
+        return NO;
+    }
+
+    if ([jsonResponse objectForKey:@"latest_receipt_info"]) {
+        NSArray *receipts = [jsonResponse objectForKey:@"latest_receipt_info"];
+        for (NSDictionary *receipt in receipts) {
+            NSString *product_id = receipt[@"product_id"];
+            NSString *expires_date_ms = receipt[@"expires_date_ms"];
+            NSInteger quantity = [receipt[@"quantity"] integerValue];
+            
+            long long expiresDate = [expires_date_ms longLongValue]/1000;
+            long long currentDate = [[NSDate date] timeIntervalSince1970];
+            BOOL isActive = (expiresDate > currentDate) ? YES : NO;
+            
+            if ([product_id isEqualToString:self.monthProduct.productIdentifier]) {
+                if (!self.monthProduct.isSubscribed) {
+                    self.monthProduct.isSubscribed = isActive;
+                }
+                self.monthProduct.originalPurchased = YES;
+            } else if ([product_id isEqualToString:self.newlyMonthProduct.productIdentifier]) {
+                if (!self.newlyMonthProduct.isSubscribed) {
+                    self.newlyMonthProduct.isSubscribed = isActive;
+                }
+                if ([receipt[@"is_trial_period"] boolValue]) {
+                    self.newlyMonthProduct.isTrialPeriod = YES;
+                }
+                self.newlyMonthProduct.originalPurchased = YES;
+                
+            } else if ([product_id isEqualToString:self.allAccessProduct.productIdentifier]) {
+                if (!self.allAccessProduct.isSubscribed) {
+                    self.allAccessProduct.isSubscribed = quantity > 0 ? YES : NO;
+                }
+                self.allAccessProduct.originalPurchased = YES;
+            } else if ([product_id isEqualToString:self.PDFToOfficeProduct.productIdentifier]) {
+                if (!self.PDFToOfficeProduct.isSubscribed) {
+                    self.PDFToOfficeProduct.isSubscribed = quantity > 0 ? YES : NO;
+                }
+                self.PDFToOfficeProduct.originalPurchased = YES;
+            }
+        }
+    }
+    if ([[jsonResponse objectForKey:@"receipt"] objectForKey:@"in_app"]) {
+        NSArray *receipts = [[jsonResponse objectForKey:@"receipt"] objectForKey:@"in_app"];
+        for (NSDictionary *receipt in receipts) {
+            NSString *product_id = receipt[@"product_id"];
+            NSString *expires_date_ms = receipt[@"expires_date_ms"];
+            NSInteger quantity = [receipt[@"quantity"] integerValue];
+            
+            long long expiresDate = [expires_date_ms longLongValue]/1000;
+            long long currentDate = [[NSDate date] timeIntervalSince1970];
+            BOOL isActive = (expiresDate > currentDate) ? YES : NO;
+            
+            if ([product_id isEqualToString:self.monthProduct.productIdentifier]) {
+                if (!self.monthProduct.isSubscribed) {
+                    self.monthProduct.isSubscribed = isActive;
+                }
+                self.monthProduct.originalPurchased = YES;
+            } else if ([product_id isEqualToString:self.newlyMonthProduct.productIdentifier]) {
+                if (!self.newlyMonthProduct.isSubscribed) {
+                    self.newlyMonthProduct.isSubscribed = isActive;
+                }
+                if ([receipt[@"is_trial_period"] boolValue]) {
+                    self.newlyMonthProduct.isTrialPeriod = YES;
+                }
+                self.newlyMonthProduct.originalPurchased = YES;
+            } else if ([product_id isEqualToString:self.allAccessProduct.productIdentifier]) {
+                if (!self.allAccessProduct.isSubscribed) {
+                    self.allAccessProduct.isSubscribed = quantity > 0 ? YES : NO;
+                }
+                self.allAccessProduct.originalPurchased = YES;
+            } else if ([product_id isEqualToString:self.PDFToOfficeProduct.productIdentifier]) {
+                if (!self.PDFToOfficeProduct.isSubscribed) {
+                    self.PDFToOfficeProduct.isSubscribed = quantity > 0 ? YES : NO;
+                }
+                self.PDFToOfficeProduct.originalPurchased = YES;
+            }
+        }
+    }
+    
+    [[NSUserDefaults standardUserDefaults] setObject:self.allAccessProduct.isSubscribed ? @"YES":@"NO" forKey:@"allAccessProduct.isSubscribed"];    
+    [[NSUserDefaults standardUserDefaults] setObject:self.PDFToOfficeProduct.isSubscribed ? @"YES":@"NO" forKey:@"PDFToOfficeProduct.isSubscribed"];
+    [[NSUserDefaults standardUserDefaults] synchronize];
+    
+    return YES;
+}
+
+- (void)loadAllProducts {
+    NSSet *identifiers = [NSSet setWithArray:self.productIdentifiers];
+    SKProductsRequest *productRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers];
+    productRequest.delegate = self;
+    [productRequest start];
+}
+
+- (void)productDidFailed:(SKPaymentTransaction *)transaction {
+    if (!self.isPurchasing) {
+        return;
+    }
+    dispatch_async(dispatch_get_main_queue(), ^{
+        NSString *productIdentifier = transaction.payment.productIdentifier;
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductFailedNotification
+                                                            object:productIdentifier];
+        
+        NSString *informative = [NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n\n",
+                                 NSLocalizedString(@"Purchase failed. Please check your settings and try again.", nil),
+                                 NSLocalizedString(@"—》If you already completed the payment, simply click the \"Restore Previous Purchase\" button directly from the upgrade page to enable all the advanced features at no cost to you.", nil),
+                                 NSLocalizedString(@"—》Due to Apple needs to confirm your purchase info, you may be required to sign in with your Apple ID. When you restore your purchase, make sure you use the same Apple ID that you previously used.", nil)];
+        NSAlert *alert = [[NSAlert alloc] init];
+        [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
+        [alert setAlertStyle:NSAlertStyleWarning];
+        [alert setMessageText:@""];
+        [alert setInformativeText:informative];
+        [alert runModal];
+    });
+}
+
+- (void)productDidPurchased:(SKPaymentTransaction *)transaction {
+    NSString *productIdentifier = transaction.payment.productIdentifier;
+    if ([productIdentifier isEqualToString:self.monthProduct.productIdentifier]) {
+        self.monthProduct.isSubscribed = YES;
+    } else if ([productIdentifier isEqualToString:self.newlyMonthProduct.productIdentifier]) {
+        self.newlyMonthProduct.isSubscribed = YES;
+    } else if ([productIdentifier isEqualToString:self.allAccessProduct.productIdentifier]) {
+        self.allAccessProduct.isSubscribed = YES;
+        [[NSUserDefaults standardUserDefaults] setObject:self.allAccessProduct.isSubscribed ? @"YES":@"NO" forKey:@"allAccessProduct.isSubscribed"];
+        [[NSUserDefaults standardUserDefaults] synchronize];
+    } else if ([productIdentifier isEqualToString:self.PDFToOfficeProduct.productIdentifier]) {
+        self.PDFToOfficeProduct.isSubscribed = YES;
+        [[NSUserDefaults standardUserDefaults] setObject:self.PDFToOfficeProduct.isSubscribed ? @"YES":@"NO" forKey:@"PDFToOfficeProduct.isSubscribed"];
+        [[NSUserDefaults standardUserDefaults] synchronize];
+    }
+    if (!self.isPurchasing) {
+        return;
+    }
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductPurchasedNotification
+                                                            object:productIdentifier];
+        
+        NSString *informative = nil;
+        NSAlert *alert = [[NSAlert alloc] init];
+        [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
+        [alert setAlertStyle:NSAlertStyleWarning];
+        [alert setMessageText:@""];
+#if VERSION_FREE
+        informative = NSLocalizedString(@"Purchase completed. You can start using the advanced tools, including PDF to Office, PDF Watermark, Page Editor, and more.", nil);
+#else
+        informative = NSLocalizedString(@"Purchase Completed", nil);
+#endif
+        [alert setInformativeText:informative];
+        if ([alert runModal]) {
+            NSString *message = [NSString stringWithFormat:@"%@\n%@",
+                                 NSLocalizedString(@"In-App Purchase FAQ:", nil),
+                                 NSLocalizedString(@"I bought the in-app purchase, but the app doesn't recognize that automatically. How to recover my purchase?", nil)];
+            
+            NSString *informative = [NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n\n",
+                                     NSLocalizedString(@"—》If you already completed the payment, simply click the \"Restore Previous Purchase\" button directly from the upgrade page to enable all the advanced features at no cost to you.", nil),
+                                     NSLocalizedString(@"—》Due to Apple needs to confirm your purchase info, you may be required to sign in with your Apple ID. When you restore your purchase, make sure you use the same Apple ID that you previously used.", nil),
+                                     NSLocalizedString(@"—》Once you see the \"Restore Successfully\" message, you will be able to access the advanced features, including PDF to Office, PDF Watermark, Page Editor, and more.", nil)];
+            
+            NSAlert *alert = [[NSAlert alloc] init];
+            [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
+            [alert setAlertStyle:NSAlertStyleWarning];
+            [alert setMessageText:message];
+            [alert setInformativeText:informative];
+            [alert runModal];
+        }
+    });
+}
+
+- (void)restoreDidFailed {
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductRestoreFailedNotification
+                                                            object:nil];
+        
+        NSString *informative = [NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n\n",
+                                 NSLocalizedString(@"Failed to restore previous purchases. Please make sure you've made a valid purchase or try again later.", nil),
+                                 NSLocalizedString(@"—》If you already completed the payment, simply click the \"Restore Previous Purchase\" button directly from the upgrade page to enable all the advanced features at no cost to you.", nil),
+                                 NSLocalizedString(@"—》Due to Apple needs to confirm your purchase info, you may be required to sign in with your Apple ID. When you restore your purchase, make sure you use the same Apple ID that you previously used.", nil)];
+        NSAlert *alert = [[NSAlert alloc] init];
+        [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
+        [alert setAlertStyle:NSAlertStyleWarning];
+        [alert setMessageText:@""];
+        [alert setInformativeText:informative];
+        [alert runModal];
+    });
+}
+
+- (void)restoreDidFinished {
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductRestoreFinishedNotification
+                                                            object:nil];
+        
+        NSString *informative = nil;
+        NSAlert *alert = [[NSAlert alloc] init];
+        [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
+        [alert setAlertStyle:NSAlertStyleWarning];
+        [alert setMessageText:@""];
+#if VERSION_FREE
+        if (self.monthProduct.isSubscribed ||
+            self.newlyMonthProduct.isSubscribed) {
+            informative = NSLocalizedString(@"Restore successfully", nil);
+        } else if (self.allAccessProduct.isSubscribed) {
+            informative = NSLocalizedString(@"Restore successfully. You can start using the advanced tools, including PDF to Office, PDF Watermark, Page Editor, and more.", nil);
+        } else if (self.monthProduct.originalPurchased ||
+                   self.newlyMonthProduct.originalPurchased) {
+            informative = [NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n\n",
+                           NSLocalizedString(@"Your subscription has expired, please repurchase", nil),
+                           NSLocalizedString(@"—》If you already completed the payment, simply click the \"Restore Previous Purchase\" button directly from the upgrade page to enable all the advanced features at no cost to you.", nil),
+                           NSLocalizedString(@"—》Due to Apple needs to confirm your purchase info, you may be required to sign in with your Apple ID. When you restore your purchase, make sure you use the same Apple ID that you previously used.", nil)];
+        } else {
+            informative = [NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n\n",
+                           NSLocalizedString(@"Failed to restore previous purchases. Please make sure you've made a valid purchase or try again later.", nil),
+                           NSLocalizedString(@"—》If you already completed the payment, simply click the \"Restore Previous Purchase\" button directly from the upgrade page to enable all the advanced features at no cost to you.", nil),
+                           NSLocalizedString(@"—》Due to Apple needs to confirm your purchase info, you may be required to sign in with your Apple ID. When you restore your purchase, make sure you use the same Apple ID that you previously used.", nil)];
+        }
+#else
+        if (self.PDFToOfficeProduct.isSubscribed) {
+            informative = NSLocalizedString(@"Restore successfully", nil);
+        } else {
+            informative = [NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n\n",
+                           NSLocalizedString(@"Failed to restore previous purchases. Please make sure you've made a valid purchase or try again later.", nil),
+                           NSLocalizedString(@"—》If you already completed the payment, simply click the \"Restore Previous Purchase\" button directly from the upgrade page to enable all the advanced features at no cost to you.", nil),
+                           NSLocalizedString(@"—》Due to Apple needs to confirm your purchase info, you may be required to sign in with your Apple ID. When you restore your purchase, make sure you use the same Apple ID that you previously used.", nil)];
+        }
+#endif
+        [alert setInformativeText:informative];
+        [alert runModal];
+    });
+}
+
+
+//编码
+- (NSString *)encode:(const uint8_t *)input length:(NSInteger)length {
+    static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+    
+    NSMutableData *data = [NSMutableData dataWithLength:((length + 2) / 3) * 4];
+    uint8_t *output = (uint8_t *)data.mutableBytes;
+    
+    for (NSInteger i = 0; i < length; i += 3) {
+        NSInteger value = 0;
+        for (NSInteger j = i; j < (i + 3); j++) {
+            value <<= 8;
+            
+            if (j < length) {
+                value |= (0xFF & input[j]);
+            }
+        }
+        
+        NSInteger index = (i / 3) * 4;
+        output[index + 0] =                    table[(value >> 18) & 0x3F];
+        output[index + 1] =                    table[(value >> 12) & 0x3F];
+        output[index + 2] = (i + 1) < length ? table[(value >> 6)  & 0x3F] : '=';
+        output[index + 3] = (i + 2) < length ? table[(value >> 0)  & 0x3F] : '=';
+    }
+    
+    return [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+}
+
++ (NSMutableData*)mutableDataWithDic:(NSDictionary*)dic {
+    NSString *json = [IAPProductsManager postStringWithDic:dic];
+    json = [json stringByReplacingOccurrencesOfString:@"\n" withString:@""];
+    json = [json stringByReplacingOccurrencesOfString:@"\r\0" withString:@""];
+    json = [json stringByReplacingOccurrencesOfString:@"\0" withString:@""];
+    NSData *postData = [json dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
+    return [postData mutableCopy];
+}
+
++ (NSString*)postStringWithDic:(NSDictionary*)dic {
+    return [IAPProductsManager postStringWithObject:dic];
+}
+
++ (NSString*)postStringWithObject:(id)value {
+    NSString *string;
+    
+    if ([value isKindOfClass:[NSArray class]]) {
+        string = @"[";
+        BOOL isFirst = YES;
+        
+        for (id object in value) {
+            if (isFirst) {
+                isFirst = NO;
+            }else {
+                string = [string stringByAppendingString:@","];
+            }
+            string = [string stringByAppendingString:[IAPProductsManager postStringWithObject:object]];
+        }
+        
+        string = [string stringByAppendingString:@"]"];
+    }else if ([value isKindOfClass:[NSDictionary class]]) {
+        string = @"{";
+        BOOL isFirst = YES;
+        
+        for (NSString *key in [value allKeys]) {
+            if (isFirst) {
+                isFirst = NO;
+            }else {
+                string = [string stringByAppendingString:@","];
+            }
+            string = [string stringByAppendingFormat:@"\"%@\"", key];
+            string = [string stringByAppendingString:@":"];
+            string = [string stringByAppendingString:[IAPProductsManager postStringWithObject:[value valueForKey:key]]];
+        }
+        string = [string stringByAppendingString:@"}"];
+    }else {
+        string = [NSString stringWithFormat:@"\"%@\"", value];
+    }
+    
+    return string;
+}
+
+
+#pragma mark - SKProductsRequestDelegate
+
+- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
+    for (SKProduct *product in response.products) {
+        if ([product.productIdentifier isEqualToString:self.monthProduct.productIdentifier]) {
+            self.monthProduct.product = product;
+        } else if ([product.productIdentifier isEqualToString:self.newlyMonthProduct.productIdentifier]) {
+            self.newlyMonthProduct.product = product;
+        } else if ([product.productIdentifier isEqualToString:self.allAccessProduct.productIdentifier]) {
+            self.allAccessProduct.product = product;
+        } else if ([product.productIdentifier isEqualToString:self.PDFToOfficeProduct.productIdentifier]) {
+            self.PDFToOfficeProduct.product = product;
+        }
+    }
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductLoadedNotification
+                                                            object:nil];
+    });
+}
+
+#pragma mark - SKPaymentTransactionObserver
+
+- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {
+    for (SKPaymentTransaction *transaction in transactions) {
+        switch (transaction.transactionState) {
+            case SKPaymentTransactionStatePurchasing:
+                self.isPurchasing = YES;
+                break;
+            case SKPaymentTransactionStateDeferred:
+                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+                break;
+            case SKPaymentTransactionStateFailed:
+                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+                [self productDidFailed:transaction];
+                self.isPurchasing = NO;
+                break;
+            case SKPaymentTransactionStatePurchased:
+                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+                [self productDidPurchased:transaction];
+                self.isPurchasing = NO;
+                break;
+            case SKPaymentTransactionStateRestored:
+                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+                break;
+        }
+    }
+}
+
+- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error {
+    [self restoreDidFailed];
+}
+
+- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
+    [self loadReceipt:^(NSError *error) {
+        if (error) {
+            [self restoreDidFailed];
+        } else {
+            [self restoreDidFinished];
+            [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductLoadedNotification
+                                                                object:nil];
+            [[NSNotificationCenter defaultCenter] postNotificationName:KMIAPProductRestoreFinishedNotification
+                                                                object:nil];
+        }
+    }];
+}
+#endif
+@end

+ 1 - 0
PDF Office/PDF Master/PDF_Master DMG-Bridging-Header.h

@@ -78,5 +78,6 @@
 //文件权限
 #import "AppSandboxFileAccess.h"
 
+#import "IAPProductsManager.h"
 #import "VerificationManager.h"
 #import "KMPurchaseCompareWindowController.h"

+ 1 - 0
PDF Office/PDF Master/PDF_Master Pro-Bridging-Header.h

@@ -62,5 +62,6 @@
 //文件权限
 #import "AppSandboxFileAccess.h"
 
+#import "IAPProductsManager.h"
 #import "VerificationManager.h"
 #import "KMPurchaseCompareWindowController.h"

+ 1 - 0
PDF Office/PDF Master/PDF_Master-Bridging-Header.h

@@ -74,5 +74,6 @@
 //文件权限
 #import "AppSandboxFileAccess.h"
 
+#import "IAPProductsManager.h"
 #import "VerificationManager.h"
 #import "KMPurchaseCompareWindowController.h"