1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 |
- //
- // 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];
- [[KMProductCompareWC shared] setOrientation:NO];
- [[KMProductCompareWC shared] showWindow:nil];
- } 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
|