|
@@ -7,9 +7,11 @@
|
|
|
|
|
|
import Cocoa
|
|
|
import KMAdvertisement
|
|
|
+#if VERSION_DMG
|
|
|
import AppCenter
|
|
|
import AppCenterAnalytics
|
|
|
import AppCenterCrashes
|
|
|
+#endif
|
|
|
|
|
|
@main
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
@@ -50,16 +52,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
// Insert code here to initialize your application
|
|
|
|
|
|
var appSecret = "416b8e45-69bd-4a16-8fec-b5206e913c4a"
|
|
|
- let appTarget = KMTools_OC.getAppTarget()
|
|
|
- if (appTarget == .DMG) {
|
|
|
- appSecret = "416b8e45-69bd-4a16-8fec-b5206e913c4a"
|
|
|
- }
|
|
|
#if VERSION_DMG
|
|
|
+ print("11111")
|
|
|
let updater = SUUpdater.shared()
|
|
|
updater!.delegate = self
|
|
|
updater!.automaticallyChecksForUpdates = true
|
|
|
-#endif
|
|
|
|
|
|
+ appSecret = "416b8e45-69bd-4a16-8fec-b5206e913c4a"
|
|
|
+#endif
|
|
|
+
|
|
|
// MARK: 广告数据初始化
|
|
|
KMAdvertisementManager.manager.initConfig(appName: .PDFReaderProMac,
|
|
|
subscribeType: .unsubscribed,
|
|
@@ -70,10 +71,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
// 初版不支持暗黑模式
|
|
|
NSApp.appearance = NSAppearance(named: .aqua)
|
|
|
|
|
|
- if (appTarget == .DMG) {
|
|
|
- AppCenter.start(withAppSecret: appSecret, services: [Analytics.self, Crashes.self])
|
|
|
- }
|
|
|
-
|
|
|
+#if VERSION_DMG
|
|
|
+ AppCenter.start(withAppSecret: appSecret, services: [Analytics.self, Crashes.self])
|
|
|
+#endif
|
|
|
+
|
|
|
//第一次开启app
|
|
|
var info = UserDefaults.standard.value(forKey: "kFirstOpenAppCount")
|
|
|
var count = 0
|
|
@@ -339,33 +340,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
SUUpdater.shared().checkForUpdates(sender)
|
|
|
#endif
|
|
|
}
|
|
|
-
|
|
|
-#if VERSION_DMG
|
|
|
- func updaterWillRelaunchApplication(_ updater: SUUpdater) {
|
|
|
- }
|
|
|
-
|
|
|
- func feedURLStringForUpdater(_ updater: SUUpdater) -> String {
|
|
|
-#if DEBUG
|
|
|
- return "http://test-pdf-pro.kdan.cn:3021/downloads/pdfmasterprocast.xml"
|
|
|
-#else
|
|
|
- return "https://www.pdfreaderpro.com/downloads/pdfmasterprocast.xml"
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- func updaterShouldPromptForPermissionToCheckForUpdates(_ updater: SUUpdater) -> Bool {
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- func upgradeAPPWithUpdater(_ updater: SUUpdater) {
|
|
|
- let string = "macappstore://apps.apple.com/cn/app/pdf-master-ai-pdf/id6446781258?mt=12"
|
|
|
- let url: URL = URL(string: string)
|
|
|
- NSWorkspace.shared.open(url)
|
|
|
- }
|
|
|
-
|
|
|
- func upgradeButtonStringForUpdater(_ updater: SUUpdater) -> String {
|
|
|
- return NSLocalizedString("PDF Master", comment: "")
|
|
|
- }
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
extension AppDelegate : NSMenuDelegate,NSMenuItemValidation {
|
|
@@ -469,3 +443,33 @@ extension AppDelegate : NSMenuDelegate,NSMenuItemValidation {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#if VERSION_DMG
|
|
|
+extension AppDelegate : SUUpdaterDelegate {
|
|
|
+ func updaterWillRelaunchApplication(_ updater: SUUpdater) {
|
|
|
+ print("33333333333333333333333")
|
|
|
+ }
|
|
|
+
|
|
|
+ func feedURLString(for updater: SUUpdater) -> String? {
|
|
|
+#if DEBUG
|
|
|
+ return "http://test-pdf-pro.kdan.cn:3021/downloads/pdfmasterprocast.xml"
|
|
|
+#else
|
|
|
+ return "https://www.pdfreaderpro.com/downloads/pdfmasterprocast.xml"
|
|
|
+#endif
|
|
|
+ }
|
|
|
+
|
|
|
+ func updaterShouldPromptForPermissionToCheck(forUpdates updater: SUUpdater) -> Bool {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ func upgradeAPP(with updater: SUUpdater) {
|
|
|
+ let string = "macappstore://apps.apple.com/cn/app/pdf-master-ai-pdf/id6446781258?mt=12"
|
|
|
+ let url: URL = URL(string: string)!
|
|
|
+ NSWorkspace.shared.open(url)
|
|
|
+ }
|
|
|
+
|
|
|
+ func upgradeButtonString(for updater: SUUpdater) -> String {
|
|
|
+ return NSLocalizedString("PDF Master", comment: "")
|
|
|
+ }
|
|
|
+}
|
|
|
+#endif
|