123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074 |
- //
- // KMVerificationWindowController.m
- // PDF Reader Pro Edition
- //
- // Created by 王帅 on 2018/5/8.
- //
- #import "KMVerificationWindowController.h"
- #import "KMVerificationViewController.h"
- #import "KMVerificationActivateViewController.h"
- #import "KMVerificationExpiredViewController.h"
- #import "KMVerificationTrialViewController.h"
- #import "KMVerificationAlertViewController.h"
- #import "KMActivityALertViewController.h"
- #import "KMVerificationInfoViewController.h"
- #import "VerificationManager.h"
- //#import "KMMailHelper.h"
- #import "GBDeviceInfo.h"
- #import "Reachability.h"
- //#import "SKInspectPublicTool.h"
- //#import "FMTrackEventManager.h"
- #import "KMRepeatTrialAlertController.h"
- #import "KMRepeatVerifyExpireController.h"
- #import <PDF_Reader_Pro-Swift.h>
- @interface KMVerificationWindowController ()
- @property (nonatomic, assign) KMVerificationType type;
- @property (nonatomic, assign) IBOutlet NSBox *box;
- @property (nonatomic, assign) IBOutlet NSProgressIndicator *progressIndicator;
- @property (nonatomic, retain) KMVerificationViewController *normalViewController;
- @property (nonatomic, retain) KMVerificationActivateViewController *activateViewController;
- @property (nonatomic, retain) KMVerificationExpiredViewController *expiredViewController;
- @property (nonatomic, retain) KMVerificationTrialViewController *trialViewController;
- @property (nonatomic, retain) KMVerificationAlertViewController *alertViewController;
- @property (nonatomic, retain) KMActivityALertViewController *activityAlertViewController;
- @property (nonatomic, retain) KMVerificationInfoViewController *infoViewController;
- @property (nonatomic, retain) KMRepeatTrialAlertController *repeatTrialAlertController;//二次试用提示弹窗
- @property (nonatomic, retain) KMRepeatVerifyExpireController *repeatTrialExpireController;//二次试用过期弹窗
- @property (nonatomic, retain) KMTrialSuccessController *trialSuccessController;
- @property (nonatomic, retain) KMUnbindAlertViewController *unbindAlertController;
- @end
- @implementation KMVerificationWindowController
- + (void)launching {
- [VerificationManager manager];
- }
- + (BOOL)allowsShowExpired {
- #if VERSION_DMG
- if ([VerificationManager manager].status == ActivityStatusTrialExpire &&
- [VerificationManager manager].secondTrialEnabled == NO) {
- if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowTrialExpireShowKeyDMG"]) {
- [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowTrialExpireShowKeyDMG"];
- return YES;
- }
- }
- return NO;
- #else
- NSDate *lastTimeDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"kVerificationExpiredShowLastTimeDateKay"];
- if (lastTimeDate) {
- NSDate *date = [NSDate date];
- NSTimeInterval time = [date timeIntervalSinceDate:lastTimeDate];
- int days = ((int)time)/(3600*24);
- if (days < 15) {
- return NO;
- }
- }
- #endif
- return YES;
- }
- + (void)showExpiredInfo {
- if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
- if ([KMVerificationWindowController allowsShowExpired]) {
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeTrialExpired];
- [vc showWindow:nil];
-
- [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"kVerificationExpiredShowLastTimeDateKay"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- } else if (ActivityStatusVerifExpire == [VerificationManager manager].status) {
- if ([KMVerificationWindowController allowsShowExpired]) {
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivateExpired];
- [vc showWindow:nil];
-
- [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"kVerificationExpiredShowLastTimeDateKay"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- }
- }
- + (BOOL)allowRepeatTrialAlertShow {
- //是否在开启APP时弹出二次试用弹窗提示框
- if ([VerificationManager manager].secondTrialEnabled) {
- if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowRepeatTrialAlertShowKey"]) {
- return YES;
- }
- }
- return NO;
- }
- + (BOOL)allowRepeatTrialExpireShow {
- if ([VerificationManager manager].status == ActivityStatusTrialExpire &&
- [VerificationManager manager].trialTimes == 2) {
- if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowRepeatTrialExpireShowKey"]) {
- return YES;
- }
- }
- return NO;
- }
- static KMVerificationWindowController *_currentWindowController = nil;
- + (KMVerificationWindowController *)verificationWithType:(KMVerificationType)type {
- if (_currentWindowController) {
- if (type != _currentWindowController.type) {
- [_currentWindowController close];
- } else {
- return _currentWindowController;
- }
- }
- KMVerificationWindowController *vc = [[KMVerificationWindowController alloc] initWithType:type];
- return vc;
- }
- #pragma mark Init Methods
- - (instancetype)initWithType:(KMVerificationType)type {
- if (self = [super initWithWindowNibName:@"KMVerificationWindowController"]) {
- _type = type;
- }
- return self;
- }
- - (void)dealloc {
- [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
-
- }
- #pragma mark - Getter Methods
- - (KMVerificationViewController *)normalViewController {
- if (!_normalViewController) {
- __block __typeof(self) blockSelf = self;
- _normalViewController = [[KMVerificationViewController alloc] init];
- _normalViewController.callback = ^(NSInteger index) {
- if (index == 0) {
- [blockSelf setContentView:blockSelf.activateViewController.view];
- } else if (index == 1) {
- if (KMVerificationTypeActivateExpired == self.type) {
- [blockSelf verificationFeedback];
- } else {
- [blockSelf close];
- }
- } else {
- [blockSelf verificationBuy];
- }
- };
- if (KMVerificationTypeTrialExpired == self.type) {
- _normalViewController.titleText = NSLocalizedString(@"Thank you for trying PDF Reader Pro", nil);
- _normalViewController.messageText = NSLocalizedString(@"Your trial has expired. Buy Full version to annotate and edit PDF files.", nil);
- } else {
- _normalViewController.titleText = NSLocalizedString(@"PDF Reader Pro Activation", nil);
- _normalViewController.messageText = NSLocalizedString(@"Buy Full Version to annotate and edit your PDF documents.", nil);
- }
- }
- return _normalViewController;
- }
- - (KMVerificationActivateViewController *)activateViewController {
- if (!_activateViewController) {
- __block __typeof(self) blockSelf = self;
- _activateViewController = [[KMVerificationActivateViewController alloc] init];
- _activateViewController.callback = ^(NSInteger index, NSString *string) {
- if (index == 0) {
- // if (blockSelf.callback) {
- // blockSelf.callback();
- // blockSelf.callback = nil;
- // [blockSelf close];
- // } else {
- // if (KMVerificationTypeTrial == blockSelf.type) {
- // [blockSelf setContentView:blockSelf.trialViewController.view];
- // } else if (KMVerificationTypeActivateExpired == blockSelf.type) {
- // [blockSelf setContentView:blockSelf.expiredViewController.view];
- // } else {
- // [blockSelf setContentView:blockSelf.normalViewController.view];
- // }
- // }
- [blockSelf close];
- } else {
- if (blockSelf.type == KMVerificationTypeActivateAIInfo) {
- [blockSelf verificationActivateAIInfo:string];
- } else {
- [blockSelf verificationActivate:string];
- }
- }
- };
- if (self.type == KMVerificationTypeActivateAIInfo) {
- _activateViewController.type = self.type;
- }
- }
- return _activateViewController;
- }
- - (KMVerificationExpiredViewController *)expiredViewController {
- if (!_expiredViewController) {
- __block __typeof(self) blockSelf = self;
- _expiredViewController = [[KMVerificationExpiredViewController alloc] init];
- _expiredViewController.callback = ^(NSInteger index) {
- if (index == 0) {
- [blockSelf setContentView:blockSelf.activateViewController.view];
- } else {
- [blockSelf verificationFeedback];
- }
- };
- }
- return _expiredViewController;
- }
- - (KMVerificationTrialViewController *)trialViewController {
- if (!_trialViewController) {
- __block __typeof(self) blockSelf = self;
- _trialViewController = [[KMVerificationTrialViewController alloc] init];
- _trialViewController.callback = ^(NSInteger index, NSString *email, NSString *name) {
- if (index == 0) {
- [blockSelf setContentView:blockSelf.activateViewController.view];
- } else {
- [blockSelf verificationTrialForEmail:email name:name];
- }
- };
- }
- return _trialViewController;
- }
- - (KMVerificationAlertViewController *)alertViewController {
- if (!_alertViewController) {
- __block __typeof(self) blockSelf = self;
- _alertViewController = [[KMVerificationAlertViewController alloc] init];
- _alertViewController.callback = ^{
- [blockSelf close];
- };
- _alertViewController.buyActionHandle = ^{
- #if VERSION_DMG
- NSURL *url = [NSURL URLWithString:Swift_oc_Tool.Store_Link_OC];
- [[NSWorkspace sharedWorkspace] openURL:url];
- #endif
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_BuyNow-Trial"}];
- [blockSelf close];
- };
- }
- return _alertViewController;
- }
- - (KMActivityALertViewController *)activityAlertViewController {
- if (!_activityAlertViewController) {
- __block __typeof(self) blockSelf = self;
- _activityAlertViewController = [[KMActivityALertViewController alloc] init];
- _activityAlertViewController.callback = ^{
- [blockSelf close];
- };
- }
- return _activityAlertViewController;
- }
- - (KMVerificationInfoViewController *)infoViewController {
- if (!_infoViewController) {
- __weak __typeof(self) blockSelf = self;
- _infoViewController = [[KMVerificationInfoViewController alloc] init];
- _infoViewController.callback = ^{
- [blockSelf close];
- };
- _infoViewController.unbindAction = ^{
- dispatch_async(dispatch_get_main_queue(), ^{
- //输入序列码
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeUnbindAlert];
- vc.callback = ^{
- };
- [vc showWindow:nil];
- });
- };
- }
- return _infoViewController;
- }
- - (KMRepeatTrialAlertController *)repeatTrialAlertController {
- if (!_repeatTrialAlertController) {
- __block __typeof(self) blockSelf = self;
- _repeatTrialAlertController = [[KMRepeatTrialAlertController alloc] init];
- _repeatTrialAlertController.callback = ^(NSInteger clickIndex, KMRepeatTrialAlertController * _Nonnull tRController) {
- if (clickIndex == 0) {
- //免费试用
- [blockSelf verificationTrialForEmail:[VerificationManager manager].email
- name:[VerificationManager manager].accountName] ;
- } else if (clickIndex == 1) {
- //了解更多
- // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_sec_free_trial", Swift_oc_Tool.Store_Link_OC]];
- // [[NSWorkspace sharedWorkspace] openURL:url];
- // [blockSelf close];
- [[KMMemberInfo shared] advancedFunctionUsage];
- } else if (clickIndex == 2) {
- //输入序列码
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
- vc.callback = ^{
- };
- [vc showWindow:nil];
- }
- };
- }
- return _repeatTrialAlertController;
- }
- - (KMRepeatVerifyExpireController *)repeatTrialExpireController {
- if (!_repeatTrialExpireController) {
- __block __typeof(self) blockSelf = self;
- _repeatTrialExpireController = [[KMRepeatVerifyExpireController alloc] init];
- _repeatTrialExpireController.callback = ^(NSInteger clickIndex, KMRepeatVerifyExpireController * _Nonnull tRController) {
- if (clickIndex == 0) {
- [blockSelf setContentView:blockSelf.activateViewController.view];
- } else if (clickIndex == 1) {
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_SecondTrialExpire_Later"}];
- [blockSelf close];
- } else if (clickIndex == 2) {
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_SecondTrialExpire_Buy"}];
- [blockSelf verificationBuy];
- }
- };
- }
- return _repeatTrialExpireController;
- }
- - (KMTrialSuccessController *)trialSuccessController {
- if (!_trialSuccessController) {
- __block __typeof(self) blockSelf = self;
- _trialSuccessController = [[KMTrialSuccessController alloc] init];
- _trialSuccessController.clickHandle = ^(KMTrialSuccessController * _Nonnull controller) {
- [blockSelf close];
- };
- }
- return _trialSuccessController;
- }
- - (KMUnbindAlertViewController *)unbindAlertController {
- if (!_unbindAlertController) {
- __weak typeof(self) weakSelf = self;
- _unbindAlertController = [[KMUnbindAlertViewController alloc] init];
- _unbindAlertController.unbundHandle = ^(KMUnbindAlertViewController * _Nonnull controller) {
- [weakSelf unbindAction];
- [weakSelf close];
- };
- }
- return _unbindAlertController;
- }
- #pragma mark - Window Methods
- - (void)windowDidLoad {
- [super windowDidLoad];
-
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
- self.window.title = @"";
-
- [[self.window standardWindowButton:NSWindowZoomButton] setHidden:YES];
- [[self.window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
-
- [self updateViewInfo];
-
- [self updateViewColor];
- [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
- }
- - (void)updateViewInfo {
- if (KMVerificationTypeNormal == self.type) {
- [self setContentView:self.normalViewController.view];
- } else if (KMVerificationTypeActivate == self.type) {
- [self setContentView:self.activateViewController.view];
- } else if (KMVerificationTypeTrial == self.type) {
- [self setContentView:self.trialViewController.view];
- } else if (KMVerificationTypeActivateExpired == self.type) {
- [self setContentView:self.expiredViewController.view];
- } else if (KMVerificationTypeTrialExpired == self.type) {
- [self setContentView:self.normalViewController.view];
- } else if (KMVerificationTypeInfo == self.type) {
- [self setContentView:self.infoViewController.view];
- } else if (KMVerificationTypeRepeatTrialGuide == self.type) {
- self.window.title = @"";
- [self setContentView:self.repeatTrialAlertController.view];
- [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowRepeatTrialAlertShowKey"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- } else if (KMVerificationTypeRepeatTrialExpire == self.type) {
- [self setContentView:self.repeatTrialExpireController.view];
- [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowRepeatTrialExpireShowKey"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- } else if (self.type == KMVerificationTypeTrialSuccess ||
- self.type == KMVerificationTypeRepeatTrialSuccess) {
- [self setContentView:self.trialSuccessController.view];
- } else if (KMVerificationTypeActivateAIInfo == self.type) {
- [self setContentView:self.activateViewController.view];
- self.activateViewController.type = self.type;
- } else if (KMVerificationTypeUnbindAlert == self.type) {
- [self setContentView:self.unbindAlertController.view];
- }
- }
- - (void)updateViewColor {
- if (KMVerificationTypeNormal == self.type) {
-
- } else if (KMVerificationTypeActivate == self.type) {
-
- } else if (KMVerificationTypeTrial == self.type) {
-
- } else if (KMVerificationTypeActivateExpired == self.type) {
-
- } else if (KMVerificationTypeTrialExpired == self.type) {
-
- } else if (KMVerificationTypeInfo == self.type) {
-
- } else if (KMVerificationTypeRepeatTrialGuide == self.type) {
- [self.repeatTrialAlertController updateViewColor];
- } else if (KMVerificationTypeRepeatTrialExpire == self.type) {
- [self.repeatTrialExpireController updateViewColor];
- } else if (KMVerificationTypeTrialSuccess == self.type ||
- KMVerificationTypeRepeatTrialSuccess == self.type) {
- [self.trialSuccessController updateViewColor];
- } else if (KMVerificationTypeUnbindAlert == self.type) {
- [self.unbindAlertController updateViewColor];
- }
- }
- - (void)showWindow:(id)sender {
- if (!_currentWindowController) {
- _currentWindowController = self;
- }
-
- [super showWindow:sender];
- }
- - (void)windowWillClose:(NSNotification *)notification {
- if (_currentWindowController) {
- _currentWindowController = nil;
- }
-
- }
- #pragma mark - Setter
- - (void)setContentView:(NSView *)view {
- NSRect frame = self.window.frame;
- frame.origin.y -= view.frame.size.height-frame.size.height;
- frame.origin.x -= (view.frame.size.width-frame.size.width)/2.0;
- frame.size.width = view.frame.size.width;
- frame.size.height = view.frame.size.height;
- [self.box setContentView:view];
- [self.window setFrame:frame display:YES animate:YES];
- }
- #pragma mark - Private Methods
- - (void)verificationTrialForEmail:(NSString *)email name:(NSString *)name {
- if (email.length <= 0) {
- return;
- }
- if (![self isConnectionAvailable]) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
- defaultButton:NSLocalizedString(@"OK", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:NSLocalizedString(@"Please make sure your internet connection is available.", nil), nil];
- [alert runModal];
- return;
- }
- __block __typeof(self) blockSelf = self;
- self.progressIndicator.hidden = NO;
- [self.progressIndicator startAnimation:nil];
- [self.trialViewController setEnabled:NO];
- [[VerificationManager manager] trialForDays:7 email:email name:name complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
- blockSelf.progressIndicator.hidden = YES;
- [blockSelf.progressIndicator stopAnimation:nil];
- [blockSelf.trialViewController setEnabled:YES];
- if (error ||
- status != ActivityStatusTrial) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- defaultButton:NSLocalizedString(@"Try Again", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
- [alert runModal];
- } else {
- blockSelf.type = KMVerificationTypeTrialSuccess;
- [blockSelf updateViewInfo];
- }
- }];
- }
- - (void)verificationActivateAIInfo:(NSString *)license {
- if (license.length <= 0) {
- return;
- }
- if (![self isConnectionAvailable]) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
- defaultButton:NSLocalizedString(@"OK", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:@"", nil];
-
- NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
- accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
- accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
- accessryBtn.bordered = NO;
- accessryBtn.target = self;
- accessryBtn.action = @selector(accessryBtnClicked:);
- NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
- [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
-
- accessryBtn.attributedTitle = mutAttrString;
-
- NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
- CGRect frame = accessryBtn.frame;
- frame.size.height = rect.size.height;
- accessryBtn.frame = frame;
- alert.accessoryView = accessryBtn;
-
- [alert runModal];
- return;
- }
- __block __typeof(self) blockSelf = self;
- self.progressIndicator.hidden = NO;
- [self.progressIndicator startAnimation:nil];
- [self.activateViewController setEnabled:NO];
- NSDictionary *infoDic = @{@"cdkey":license};
- [[AIInfoManager defaultManager] activateAIWithInfo:infoDic complention:^(NSDictionary *info, NSError *error) {
- blockSelf.progressIndicator.hidden = YES;
- [blockSelf.progressIndicator stopAnimation:nil];
- [blockSelf.activateViewController setEnabled:YES];
- if (error) {
- NSString *tTitle0 = NSLocalizedString(@"The license you have entered is not correct. Please enter valid license.", nil);
- NSString *tTitle1 = NSLocalizedString(@"Please confirm your PDF Reader Pro AI license code through the email you provided when purchasing.", nil);
- NSString *message = [NSString stringWithFormat:@"%@\n\n%@", tTitle0, tTitle1];
- if (ActivityErrorTypeCDKeyEmpty == error.code) {
- message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number can not be empty.", nil), @""];
- } else if (ActivityErrorTypeCDKeyNotExist == error.code) {
- message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number does not exist.", nil), @""];
- } else if (ActivityErrorTypeOutNumber == error.code) {
- NSString *tMsg0 = NSLocalizedString(@"The devices connected to the license number has outnumbered.", nil);
- NSString *tMsg1 = NSLocalizedString(@"Please deactivate license on one of them, to use PDF Reader Pro on this computer", nil);
- message = [NSString stringWithFormat:@"%@\n\n%@", tMsg0, tMsg1];
- } else if (ActivityErrorTypeNetworkDisable == error.code) {
- message = NSLocalizedString(@"The network is unavailable.", nil);
- } else if (ActivityErrorTypeCDKeyExpire == error.code) {
- message = NSLocalizedString(@"The license number expired.", nil);
- } else if (ActivityErrorTypeInvalidInfo == error.code) {
- message = NSLocalizedString(@"Activation error. Please try to input correct license, or contact us.", nil);
- } else if (ActivityErrorTypeNotMatchProduct == error.code) {
- message = NSLocalizedString(@"The license number is wrong, please input right license which is for this app.", nil);
- } else if (ActivityErrorTypeFormatError == error.code) {
- message = NSLocalizedString(@"Error license. Please enter an AI license.", nil);
- }
- if ((ActivityErrorTypeUnknow == error.code) || (ActivityErrorTypeOutNumber == error.code) || (ActivityErrorTypeInvalidInfo == error.code)) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- defaultButton:NSLocalizedString(@"Contact Us", nil)
- alternateButton:NSLocalizedString(@"Try Again", nil)
- otherButton:nil
- informativeTextWithFormat:message, nil];
- if ([alert runModal]) {
- [blockSelf verificationFeedback];
- }
- } else {
- if (ActivityErrorTypeNetworkDisable == error.code) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
- defaultButton:NSLocalizedString(@"OK", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:@"", nil];
-
- NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
- accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
- accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
- accessryBtn.bordered = NO;
- accessryBtn.target = self;
- accessryBtn.action = @selector(accessryBtnClicked:);
- NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
- [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
-
- accessryBtn.attributedTitle = mutAttrString;
- NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
- CGRect frame = accessryBtn.frame;
- frame.size.height = rect.size.height;
- accessryBtn.frame = frame;
- alert.accessoryView = accessryBtn;
-
- [alert runModal];
- } else {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- defaultButton:NSLocalizedString(@"Try Again", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:message, nil];
- [alert runModal];
- }
- }
- } else {
- blockSelf.activityAlertViewController.alertTitle = NSLocalizedString(@"Successful Activation!", nil);
- blockSelf.activityAlertViewController.alertMessage = NSLocalizedString(@"Congratulations! You can start using PDF Reader Pro AI features.", nil);
- [blockSelf setContentView:blockSelf.activityAlertViewController.view];
- }
- }];
- }
- - (void)verificationActivate:(NSString *)license {
- if (license.length <= 0) {
- return;
- }
- if ([license hasPrefix:@"AI-"]) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- defaultButton:NSLocalizedString(@"Try Again", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:NSLocalizedString(@"To activate the AI license code, click “AI Tools” on the toolbar, then tap “My AI Credit” from the right panel.", nil), nil];
- [alert runModal];
- return;
- }
- if (![self isConnectionAvailable]) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
- defaultButton:NSLocalizedString(@"OK", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:@"", nil];
-
- NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
- accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
- accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
- accessryBtn.bordered = NO;
- accessryBtn.target = self;
- accessryBtn.action = @selector(accessryBtnClicked:);
- NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
- [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
-
- accessryBtn.attributedTitle = mutAttrString;
-
- NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
- CGRect frame = accessryBtn.frame;
- frame.size.height = rect.size.height;
- accessryBtn.frame = frame;
- alert.accessoryView = accessryBtn;
-
- [alert runModal];
- return;
- }
- __block __typeof(self) blockSelf = self;
- self.progressIndicator.hidden = NO;
- [self.progressIndicator startAnimation:nil];
- [self.activateViewController setEnabled:NO];
- NSDictionary *infoDic = @{@"cdkey":license};
- [[VerificationManager manager] activateDeviceWithInfo:infoDic complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
- blockSelf.progressIndicator.hidden = YES;
- [blockSelf.progressIndicator stopAnimation:nil];
- [blockSelf.activateViewController setEnabled:YES];
- if (error) {
- NSString *tTitle0 = NSLocalizedString(@"The license you have entered is not correct. Please enter valid license.", nil);
- NSString *tTitle1 = NSLocalizedString(@"If you have already purchased PDF Reader Pro for Mac, you should find your license in an email confirmation.", nil);
- NSString *message = [NSString stringWithFormat:@"%@\n\n%@", tTitle0, tTitle1];
- if (ActivityErrorTypeCDKeyEmpty == error.code) {
- message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number can not be empty.", nil), @""];
- } else if (ActivityErrorTypeCDKeyNotExist == error.code) {
- message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number does not exist.", nil), @""];
- } else if (ActivityErrorTypeOutNumber == error.code) {
- NSString *tMsg0 = NSLocalizedString(@"The devices connected to the license number has outnumbered.", nil);
- NSString *tMsg1 = NSLocalizedString(@"Please deactivate license on one of them, to use PDF Reader Pro on this computer", nil);
- message = [NSString stringWithFormat:@"%@\n\n%@", tMsg0, tMsg1];
- } else if (ActivityErrorTypeNetworkDisable == error.code) {
- message = NSLocalizedString(@"The network is unavailable.", nil);
- } else if (ActivityErrorTypeCDKeyExpire == error.code) {
- message = NSLocalizedString(@"The license number expired.", nil);
- } else if (ActivityErrorTypeInvalidInfo == error.code) {
- message = NSLocalizedString(@"Activation error. Please try to input correct license, or contact us.", nil);
- } else if (ActivityErrorTypeNotMatchProduct == error.code) {
- message = NSLocalizedString(@"The license number is wrong, please input right license which is for this app.", nil);
- } else if (ActivityErrorTypeFormatError == error.code) {
- message = NSLocalizedString(@"The license format is wrong. Please input correct license.", nil);
- }
- if ((ActivityErrorTypeUnknow == error.code) || (ActivityErrorTypeOutNumber == error.code) || (ActivityErrorTypeInvalidInfo == error.code)) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- defaultButton:NSLocalizedString(@"Contact Us", nil)
- alternateButton:NSLocalizedString(@"Try Again", nil)
- otherButton:nil
- informativeTextWithFormat:message, nil];
- if ([alert runModal]) {
- [blockSelf verificationFeedback];
- }
- } else {
- if (ActivityErrorTypeNetworkDisable == error.code) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
- defaultButton:NSLocalizedString(@"OK", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:@"", nil];
-
- NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
- accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
- accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
- accessryBtn.bordered = NO;
- accessryBtn.target = self;
- accessryBtn.action = @selector(accessryBtnClicked:);
- NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
- [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
- [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
-
- accessryBtn.attributedTitle = mutAttrString;
- NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
- CGRect frame = accessryBtn.frame;
- frame.size.height = rect.size.height;
- accessryBtn.frame = frame;
- alert.accessoryView = accessryBtn;
-
- [alert runModal];
- } else {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- defaultButton:NSLocalizedString(@"Try Again", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:message, nil];
- [alert runModal];
- }
- }
- } else {
- blockSelf.activityAlertViewController.alertTitle = NSLocalizedString(@"Successful Activation!", nil);
- blockSelf.activityAlertViewController.alertMessage = NSLocalizedString(@"Congrats! You are eligible to enjoy all advanced features (excluding AI) in PDF Reader Pro.", nil);
- [blockSelf setContentView:blockSelf.activityAlertViewController.view];
- }
- }];
-
- }
- - (void)verificationBuy {
- #if VERSION_DMG
- // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=MacAppDmg&utm_campaign=StoreLink&utm_medium=PdfStore", Swift_oc_Tool.Store_Link_OC]];
- // [[NSWorkspace sharedWorkspace] openURL:url];
- [[KMProductCompareWC shared] setOrientation:NO];
- [[KMProductCompareWC shared] showWindow:nil];
- #endif
-
- }
- #pragma - 验证错误时反馈信息
- - (void)verificationFeedback {
- unsigned major, minor, bugFix;
- [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
- NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
-
- //application version (use short version preferentially)
- NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
- if ([tAppVersion length] < 1) {
- tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
- }
-
- NSString* subjects = [[self getAppNameForSupportEmail] stringByAppendingFormat:NSLocalizedString(@" - %@;Verification Feedback;%@", nil) ,tAppVersion,versionString];
- [KMMailHelper newEmailWithContacts:@"support@pdfreaderpro.com" andSubjects:subjects];
- }
- - (void)unbindAction {
- unsigned major, minor, bugFix;
- [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
- NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
-
- //application version (use short version preferentially)
- NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
- if ([tAppVersion length] < 1) {
- tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
- }
-
- NSString *subjects = [[self getAppNameForEmail] stringByAppendingString:[NSString stringWithFormat:@" %@",@"Verification:"]];
- subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@"%@;",tAppVersion]];
- subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@" %@;",versionString]];
- subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@" %@",NSLocalizedString(@"Unbind License Code:", nil)]];
- subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@"%@",[VerificationManager manager].detailInfo[@"device"][@"unique_sn"]?:@""]];
-
- NSString *mailtoAddress = [NSString stringWithFormat:@"mailto:%@?Subject=%@&body=%@",@"support@pdfreaderpro.com",[self URLEncodedString:subjects],[self URLEncodedString:NSLocalizedString(@"Hi PDF Reader Pro Team, I need to unbind my license code, thanks!\nNotice: Please do not modify the subtitle content", nil)]];
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:mailtoAddress]];
- }
- - (void)accessryBtnClicked:(NSButton *)btn {
-
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/mac/help/activate-license-code-mac"]];
- }
- - (NSString *)URLEncodedString:(NSString *)string {
- CFStringRef stringRef = CFBridgingRetain(string);
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
- CFStringRef encoded = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
- stringRef,
- NULL,
- CFSTR("!*'\"();:@&=+$,/?%#[]% "),
- kCFStringEncodingUTF8);
- #pragma clang diagnostic pop
- CFRelease(stringRef);
- return CFBridgingRelease(encoded);
- }
- - (void)getSystemVersionMajor:(unsigned *)major
- minor:(unsigned *)minor
- bugFix:(unsigned *)bugFix {
- OSErr err;
- SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
-
- if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
- NSOperatingSystemVersion osSystemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
-
- *major = (unsigned)osSystemVersion.majorVersion;
- *minor = (unsigned)osSystemVersion.minorVersion;
- *bugFix = (unsigned)osSystemVersion.patchVersion;
-
- return;
- } else {
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
- if (systemVersion < 0x1040)
- {
- if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
- ((systemVersion & 0x0F00) >> 8);
- if (minor) *minor = (systemVersion & 0x00F0) >> 4;
- if (bugFix) *bugFix = (systemVersion & 0x000F);
- }
- else
- {
- if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
- if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
- if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
- if (major) *major = versionMajor;
- if (minor) *minor = versionMinor;
- if (bugFix) *bugFix = versionBugFix;
- }
-
- return;
- #pragma clang diagnostic pop
- }
-
- fail:
- NSLog(@"Unable to obtain system version: %ld", (long)err);
- if (major) *major = 10;
- if (minor) *minor = 0;
- if (bugFix) *bugFix = 0;
- }
- - (NSString *)getAppNameForEmail {
- NSString *tAppName = @"PDF Reader Pro Mac";
-
- #if VERSION_FREE
-
- #if VERSION_DMG
-
- #else
-
- // AppStore 免费版本
- tAppName = @"PDF Reader Pro Lite";
- #endif
-
- #else
-
- // AppStore 付费版
- tAppName = @"PDF Reader Pro Edition";
- #endif
-
- return tAppName;
- }
- - (NSString *)getAppNameForSupportEmail {
- NSString *tAppName = @"PDF Reader Pro";
-
- #if VERSION_FREE
-
- #if VERSION_DMG
- // 桌机版
- VerificationManager *tManager = [VerificationManager manager];
- switch ([tManager status]) {
- case ActivityStatusTrial:
- tAppName = @"PDF Reader Pro Trial";
- break;
-
- case ActivityStatusVerification:
- tAppName = @"PDF Reader Pro Verification";
- break;
-
- case ActivityStatusTrialExpire:
- tAppName = @"PDF Reader Pro TrialExpire";
- break;
-
- case ActivityStatusVerifExpire:
- tAppName = @"PDF Reader Pro VerifExpire";
- break;
-
- default:
- break;
- }
-
- #else
-
- // AppStore 免费版本
- tAppName = @"PDF Reader Pro Lite";
- #endif
-
- #else
-
- // AppStore 付费版
- tAppName = @"PDF Reader Pro Edition";
- #endif
-
- return tAppName;
- }
- - (BOOL)isConnectionAvailable {
- BOOL isExistenceNetwork = YES;
- Reachability *reach = [Reachability reachabilityWithHostname:@"www.apple.com"];
- switch ([reach currentReachabilityStatus]) {
- case NotReachable:
- isExistenceNetwork = NO;
- //NSLog(@"notReachable");
- break;
- case ReachableViaWiFi:
- isExistenceNetwork = YES;
- //NSLog(@"WIFI");
- break;
- case ReachableViaWWAN:
- isExistenceNetwork = YES;
- //NSLog(@"3G");
- break;
- }
- if (NotReachable == [[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
- return NO;
- }
- return YES;
- }
- #pragma mark - NSNotification
- - (void)themeChanged:(NSNotification *)notification {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self updateViewColor];
- });
- }
- + (void)verificationFeedback {
- unsigned major, minor, bugFix;
- [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
- NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
-
- NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
- if ([tAppVersion length] < 1)
- {
- tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
- }
-
- NSString* subjects = [[self getAppNameForSupportEmail] stringByAppendingFormat:NSLocalizedString(@" - %@;Verification Feedback;%@", nil) ,tAppVersion,versionString];
- [KMMailHelper newEmailWithContacts:@"support@pdfreaderpro.com" andSubjects:subjects];
- }
- + (void)getSystemVersionMajor:(unsigned *)major
- minor:(unsigned *)minor
- bugFix:(unsigned *)bugFix;
- {
- OSErr err;
- SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
-
- if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
- NSOperatingSystemVersion osSystemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
-
- *major = (unsigned)osSystemVersion.majorVersion;
- *minor = (unsigned)osSystemVersion.minorVersion;
- *bugFix = (unsigned)osSystemVersion.patchVersion;
-
- return;
- } else {
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
- if (systemVersion < 0x1040)
- {
- if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
- ((systemVersion & 0x0F00) >> 8);
- if (minor) *minor = (systemVersion & 0x00F0) >> 4;
- if (bugFix) *bugFix = (systemVersion & 0x000F);
- }
- else
- {
- if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
- if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
- if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
- if (major) *major = versionMajor;
- if (minor) *minor = versionMinor;
- if (bugFix) *bugFix = versionBugFix;
- }
-
- return;
- #pragma clang diagnostic pop
- }
-
- fail:
- NSLog(@"Unable to obtain system version: %ld", (long)err);
- if (major) *major = 10;
- if (minor) *minor = 0;
- if (bugFix) *bugFix = 0;
- }
- + (NSString *)getAppNameForSupportEmail
- {
- NSString *tAppName = @"PDF Reader Pro";
-
- #if VERSION_FREE
-
- #if VERSION_DMG
- // 桌机版
- VerificationManager *tManager = [VerificationManager manager];
- switch ([tManager status]) {
- case ActivityStatusTrial:
- tAppName = @"PDF Reader Pro Trial";
- break;
-
- case ActivityStatusVerification:
- tAppName = @"PDF Reader Pro Verification";
- break;
-
- case ActivityStatusTrialExpire:
- tAppName = @"PDF Reader Pro TrialExpire";
- break;
-
- case ActivityStatusVerifExpire:
- tAppName = @"PDF Reader Pro VerifExpire";
- break;
-
- default:
- break;
- }
-
- #else
-
- // AppStore 免费版本
- tAppName = @"PDF Reader Pro Lite";
- #endif
-
- #else
-
- // AppStore 付费版
- tAppName = @"PDF Reader Pro Edition";
- #endif
-
- return tAppName;
- }
- @end
|