ソースを参照

【订阅】URL Schemes 添加

lizhe 1 年間 前
コミット
6f7a372d8b

+ 25 - 1
PDF Office/PDF Master/AppDelegate.swift

@@ -98,7 +98,31 @@ class AppDelegate: NSObject, NSApplicationDelegate {
         
         
         reopenDocument(forPaths: [])
         reopenDocument(forPaths: [])
         KMPreference.shared.initDataForAppLaunch()
         KMPreference.shared.initDataForAppLaunch()
-    }
+        
+        let appleEventManager = NSAppleEventManager.shared()
+        appleEventManager.setEventHandler(self,
+                                          andSelector: #selector(handleGetURLEvent(_:withReplyEvent:)),
+                                          forEventClass: AEEventClass(kInternetEventClass),
+                                          andEventID: AEEventID(kAEGetURL))
+    }
+    
+    @objc func handleGetURLEvent(_ event: NSAppleEventDescriptor, withReplyEvent replyEvent: NSAppleEventDescriptor) {
+            if let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue,
+               let url = URL(string: urlString) {
+                // 在这里处理收到的 URL Scheme
+                print("Received URL Scheme: \(url.scheme ?? "")")
+                print("Path: \(url.path)")
+                
+                // 执行相应的操作
+                if url.scheme == "myapp" {
+                    if url.path == "/open" {
+                        // 执行打开操作
+                    } else if url.path == "/close" {
+                        // 执行关闭操作
+                    }
+                }
+            }
+        }
     
     
     func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
     func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
         
         

+ 28 - 18
PDF Office/PDF Master/Info.plist

@@ -2,24 +2,6 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <plist version="1.0">
 <dict>
 <dict>
-	<key>Fabric</key>
-	<dict>
-		<key>APIKey</key>
-		<string>AIzaSyDex9auPUJBSvPMMu4UhIAtpwwzKutdmiQ</string>
-		<key>Kits</key>
-		<array>
-			<dict>
-				<key>KitInfo</key>
-				<dict/>
-				<key>KitName</key>
-				<string>Crashlytics</string>
-			</dict>
-		</array>
-	</dict>
-	<key>FirebaseAppDelegateProxyEnabled</key>
-	<false/>
-	<key>SUFeedURL</key>
-	<string></string>
 	<key>ATSApplicationFontsPath</key>
 	<key>ATSApplicationFontsPath</key>
 	<string>Fonts</string>
 	<string>Fonts</string>
 	<key>CFBundleDocumentTypes</key>
 	<key>CFBundleDocumentTypes</key>
@@ -312,12 +294,40 @@
 				<string>db-jxjlqfm1cfp2mjj</string>
 				<string>db-jxjlqfm1cfp2mjj</string>
 			</array>
 			</array>
 		</dict>
 		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Editor</string>
+			<key>CFBundleURLName</key>
+			<string>com.pdftechnologies.pdfreader.mac</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>subscriptionSchemes</string>
+			</array>
+		</dict>
 	</array>
 	</array>
+	<key>Fabric</key>
+	<dict>
+		<key>APIKey</key>
+		<string>AIzaSyDex9auPUJBSvPMMu4UhIAtpwwzKutdmiQ</string>
+		<key>Kits</key>
+		<array>
+			<dict>
+				<key>KitInfo</key>
+				<dict/>
+				<key>KitName</key>
+				<string>Crashlytics</string>
+			</dict>
+		</array>
+	</dict>
+	<key>FirebaseAppDelegateProxyEnabled</key>
+	<false/>
 	<key>NSAppTransportSecurity</key>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>
 		<key>NSAllowsArbitraryLoads</key>
 		<true/>
 		<true/>
 	</dict>
 	</dict>
+	<key>SUFeedURL</key>
+	<string></string>
 	<key>UIAppFonts</key>
 	<key>UIAppFonts</key>
 	<array>
 	<array>
 		<string>SF-Pro-Text-Regular.otf</string>
 		<string>SF-Pro-Text-Regular.otf</string>

+ 35 - 22
PDF Office/PDF-Master-DMG-Info.plist

@@ -2,28 +2,6 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <plist version="1.0">
 <dict>
 <dict>
-	<key>Fabric</key>
-	<dict>
-		<key>APIKey</key>
-		<string>AIzaSyDex9auPUJBSvPMMu4UhIAtpwwzKutdmiQ</string>
-		<key>Kits</key>
-		<array>
-			<dict>
-				<key>KitInfo</key>
-				<dict/>
-				<key>KitName</key>
-				<string>Crashlytics</string>
-			</dict>
-		</array>
-	</dict>
-	<key>FirebaseAppDelegateProxyEnabled</key>
-	<false/>
-	<key>SUFeedURL</key>
-	<string></string>
-	<key>SUPublicDSAKeyFile</key>
-	<string>dsa_pub.pem</string>
-	<key>SUScheduledCheckInterval</key>
-	<integer>86400</integer>
 	<key>ATSApplicationFontsPath</key>
 	<key>ATSApplicationFontsPath</key>
 	<string>Fonts</string>
 	<string>Fonts</string>
 	<key>CFBundleDocumentTypes</key>
 	<key>CFBundleDocumentTypes</key>
@@ -306,11 +284,46 @@
 			<string>KMImageDocument</string>
 			<string>KMImageDocument</string>
 		</dict>
 		</dict>
 	</array>
 	</array>
+	<key>CFBundleURLTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Editor</string>
+			<key>CFBundleURLName</key>
+			<string>com.pdftechnologies.pdfreader.dmg</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>subscriptionSchemes</string>
+			</array>
+		</dict>
+	</array>
+	<key>Fabric</key>
+	<dict>
+		<key>APIKey</key>
+		<string>AIzaSyDex9auPUJBSvPMMu4UhIAtpwwzKutdmiQ</string>
+		<key>Kits</key>
+		<array>
+			<dict>
+				<key>KitInfo</key>
+				<dict/>
+				<key>KitName</key>
+				<string>Crashlytics</string>
+			</dict>
+		</array>
+	</dict>
+	<key>FirebaseAppDelegateProxyEnabled</key>
+	<false/>
 	<key>NSAppTransportSecurity</key>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>
 		<key>NSAllowsArbitraryLoads</key>
 		<true/>
 		<true/>
 	</dict>
 	</dict>
+	<key>SUFeedURL</key>
+	<string></string>
+	<key>SUPublicDSAKeyFile</key>
+	<string>dsa_pub.pem</string>
+	<key>SUScheduledCheckInterval</key>
+	<integer>86400</integer>
 	<key>UIAppFonts</key>
 	<key>UIAppFonts</key>
 	<array>
 	<array>
 		<string>SF-Pro-Text-Regular.otf</string>
 		<string>SF-Pro-Text-Regular.otf</string>