|
@@ -97,57 +97,81 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
}
|
|
|
|
|
|
@objc func handleGetURLEvent(_ event: NSAppleEventDescriptor, withReplyEvent replyEvent: NSAppleEventDescriptor) {
|
|
|
- if let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue,
|
|
|
- let url = URL(string: urlString) {
|
|
|
- // 在这里处理收到的 URL Scheme
|
|
|
- KMPrint("Received URL Scheme: \(url.scheme ?? "")")
|
|
|
- KMPrint("Path: \(url.path)")
|
|
|
-
|
|
|
- #if VERSION_DMG
|
|
|
- // 执行相应的操作
|
|
|
- if url.scheme == "subscriptiondmgschemes" {
|
|
|
- if urlString.contains("open=expired") {
|
|
|
- KMPrint("刷新用户信息")
|
|
|
- if !KMLightMemberManager.manager.isLogin() && NSApp.mainWindow != nil {
|
|
|
- KMLoginWindowController.show(window: NSApp.mainWindow!)
|
|
|
- } else {
|
|
|
- if NSApp.mainWindow != nil && KMLightMemberManager.manager.isLogin() {
|
|
|
- KMAccountInfoWindowController.show(window: NSApp.mainWindow!)
|
|
|
- }
|
|
|
+ if let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue,
|
|
|
+ let url = URL(string: urlString) {
|
|
|
+ // 在这里处理收到的 URL Scheme
|
|
|
+ KMPrint("Received URL Scheme: \(url.scheme ?? "")")
|
|
|
+ KMPrint("Path: \(url.path)")
|
|
|
+
|
|
|
+ if NSApp.mainWindow == nil {
|
|
|
+ let bundleIdentifier: String = Bundle.main.bundleIdentifier ?? ""
|
|
|
+ launchApp(bundleIdentifier: bundleIdentifier)
|
|
|
+ }
|
|
|
+
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
|
|
|
+ #if VERSION_DMG
|
|
|
+ // 执行相应的操作
|
|
|
+ if url.scheme == "subscriptiondmgschemes" {
|
|
|
+ if urlString.contains("open=expired") {
|
|
|
+ KMPrint("刷新用户信息")
|
|
|
+ if !KMLightMemberManager.manager.isLogin() && NSApp.mainWindow != nil {
|
|
|
+ KMLoginWindowController.show(window: NSApp.mainWindow!)
|
|
|
+ } else {
|
|
|
+ if NSApp.mainWindow != nil && KMLightMemberManager.manager.isLogin() {
|
|
|
+ KMAccountInfoWindowController.show(window: NSApp.mainWindow!)
|
|
|
}
|
|
|
- } else if urlString.contains("open=success") {
|
|
|
- if !KMLightMemberManager.manager.isLogin() && NSApp.mainWindow != nil {
|
|
|
- KMLoginWindowController.show(window: NSApp.mainWindow!)
|
|
|
- } else {
|
|
|
- KMPurchaseManager.manager.restorePurchases { isSuccess, error in
|
|
|
- if isSuccess {
|
|
|
-
|
|
|
- } else {
|
|
|
- KMComparativeTableViewController.purchasefailed(view: NSApp.mainWindow?.contentView, state: error)
|
|
|
- }
|
|
|
+ }
|
|
|
+ } else if urlString.contains("open=success") {
|
|
|
+ if !KMLightMemberManager.manager.isLogin() && NSApp.mainWindow != nil {
|
|
|
+ KMLoginWindowController.show(window: NSApp.mainWindow!)
|
|
|
+ } else {
|
|
|
+ KMPurchaseManager.manager.restorePurchases { isSuccess, error in
|
|
|
+ if isSuccess {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ KMComparativeTableViewController.purchasefailed(view: NSApp.mainWindow?.contentView, state: error)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- #endif
|
|
|
-
|
|
|
- #if VERSION_FREE
|
|
|
- // 执行相应的操作
|
|
|
- if url.scheme == "subscriptionSchemes" {
|
|
|
- //刷新用户信息
|
|
|
- KMRequestServerManager.manager.getUserInfo { [weak self] success, data, error, isLocal in
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #if VERSION_FREE
|
|
|
+ // 执行相应的操作
|
|
|
+ if url.scheme == "subscriptionSchemes" {
|
|
|
+ //刷新用户信息
|
|
|
+ KMRequestServerManager.manager.getUserInfo { [weak self] success, data, error, isLocal in
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- if url.path == "/open" {
|
|
|
- // 执行打开操作
|
|
|
- } else if url.path == "/close" {
|
|
|
- // 执行关闭操作
|
|
|
- }
|
|
|
}
|
|
|
- #endif
|
|
|
+
|
|
|
+ if url.path == "/open" {
|
|
|
+ // 执行打开操作
|
|
|
+ } else if url.path == "/close" {
|
|
|
+ // 执行关闭操作
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endif
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ func launchApp(bundleIdentifier: String) {
|
|
|
+ let workspace = NSWorkspace.shared
|
|
|
+
|
|
|
+ // Launch the application with the specified bundle identifier
|
|
|
+ if let appURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleIdentifier) {
|
|
|
+ do {
|
|
|
+ try workspace.launchApplication(at: appURL, options: .default, configuration: [:])
|
|
|
+ } catch {
|
|
|
+ print("Error launching the application: \(error)")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ print("Application with bundle identifier '\(bundleIdentifier)' not found.")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
|
|