diff --git a/Coder-Desktop/Coder-Desktop/Coder_DesktopApp.swift b/Coder-Desktop/Coder-Desktop/Coder_DesktopApp.swift index d9cd649..4d78735 100644 --- a/Coder-Desktop/Coder-Desktop/Coder_DesktopApp.swift +++ b/Coder-Desktop/Coder-Desktop/Coder_DesktopApp.swift @@ -17,8 +17,8 @@ struct DesktopApp: App { Window("Sign In", id: Windows.login.rawValue) { LoginForm() .environmentObject(appDelegate.state) - } - .windowResizability(.contentSize) + }.handlesExternalEvents(matching: Set()) // Don't handle deep links + .windowResizability(.contentSize) SwiftUI.Settings { SettingsView() .environmentObject(appDelegate.vpn) @@ -30,7 +30,7 @@ struct DesktopApp: App { .environmentObject(appDelegate.state) .environmentObject(appDelegate.fileSyncDaemon) .environmentObject(appDelegate.vpn) - } + }.handlesExternalEvents(matching: Set()) // Don't handle deep links } } @@ -40,6 +40,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let vpn: CoderVPNService let state: AppState let fileSyncDaemon: MutagenDaemon + let urlHandler: URLHandler override init() { vpn = CoderVPNService() @@ -65,6 +66,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { await fileSyncDaemon.tryStart() } self.fileSyncDaemon = fileSyncDaemon + urlHandler = URLHandler(state: state, vpn: vpn) } func applicationDidFinishLaunching(_: Notification) { @@ -134,6 +136,17 @@ class AppDelegate: NSObject, NSApplicationDelegate { return true } + func application(_: NSApplication, open urls: [URL]) { + guard let url = urls.first else { + // We only accept one at time, for now + return + } + do { try urlHandler.handle(url) } catch { + // TODO: Push notification + print(error.description) + } + } + private func displayIconHiddenAlert() { let alert = NSAlert() alert.alertStyle = .informational diff --git a/Coder-Desktop/Coder-Desktop/Info.plist b/Coder-Desktop/Coder-Desktop/Info.plist index 5e59b25..4712604 100644 --- a/Coder-Desktop/Coder-Desktop/Info.plist +++ b/Coder-Desktop/Coder-Desktop/Info.plist @@ -2,6 +2,21 @@ + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLIconFile + 1024Icon + CFBundleURLName + com.coder.Coder-Desktop + CFBundleURLSchemes + + coder + + + NSAppTransportSecurity