Ver código fonte

【综合】评分弹窗优化

niehaoyu 6 meses atrás
pai
commit
73045b2058

+ 14 - 7
PDF Office/PDF Master/AppDelegate.swift

@@ -10,6 +10,9 @@ import UserNotifications
 
 @main
 class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
+    
+    var rateWindowVC: KMRateWindowController!
+    
     func applicationWillFinishLaunching(_ notification: Notification) {
 #if VERSION_FREE
 #if VERSION_DMG
@@ -202,8 +205,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
     
     //MARK: iRateDelegate
     func iRateUserDidDeclineToRateApp() {
-        
+        KMVerificationWindowController.verificationFeedback()
     }
+    
     func iRateShouldPromptForRating() -> Bool {
         let notShow: Bool = UserDefaults.standard.bool(forKey: "kUserHaveClickRateUsKey")
         if !notShow {
@@ -211,13 +215,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
             UserDefaults.standard.synchronize()
             NotificationCenter.default.post(name: Notification.Name(rawValue: "kUserHaveClickRateUsNotification"), object: self)
         }
-        let rate = KMRateWindowController()
-        let window = NSWindow.currentWindow()
-//        window.km_beginSheet(windowC: rate)
-        rate.closeBlock = { wc in
-            window.km_quick_endSheet()
+        
+        self.rateWindowVC = KMRateWindowController.init(windowNibName: "KMRateWindowController")
+        
+        self.rateWindowVC.closeBlock = { wc in
+
+        }
+        self.rateWindowVC.closeBlock = { wc in
+            
         }
-        rate.showWindow(nil)
+        self.rateWindowVC.showWindow(nil)
         return false
     }
     

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/Rate/KMRateWindowController.swift

@@ -78,6 +78,7 @@ class KMRateWindowController: NSWindowController, NSWindowDelegate{
     }
     
     override func close() {
+        super.close()
         if (self.closeBlock != nil) {
             closeBlock!(self)
         }

+ 2 - 0
PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.h

@@ -38,4 +38,6 @@ typedef NS_ENUM(NSInteger, KMVerificationType) {
 
 + (BOOL)allowRepeatTrialExpireShow;//是否允许弹出二次试用过期弹窗
 
++ (void)verificationFeedback;
+
 @end

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

@@ -947,4 +947,111 @@ fail:
     });
 }
 
++ (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