From 45276034b162ade48819c32060506b94e43e9a0e Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Fri, 28 Jan 2022 17:01:40 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20initial=20start=20for=20schem?= =?UTF-8?q?e=20integration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Core/AppDelegate+InterApp.swift | 22 ++++++++++++++++++- .../Core/AppDelegate+Notifications.swift | 4 ++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/phpmon/Domain/Core/AppDelegate+InterApp.swift b/phpmon/Domain/Core/AppDelegate+InterApp.swift index 46a45ee..dd6e34f 100644 --- a/phpmon/Domain/Core/AppDelegate+InterApp.swift +++ b/phpmon/Domain/Core/AppDelegate+InterApp.swift @@ -11,8 +11,28 @@ import Foundation extension AppDelegate { + /** + This is an entry point for future development for integrating with the PHP Monitor + application URL. You can use the `phpmon://` protocol to communicate with the app. + + At this time you can trigger the site list using Alfred (or some other application) + by opening the following URL: `phpmon://list`. + + Please note that PHP Monitor needs to be running in the background for this to work. + */ func application(_ application: NSApplication, open urls: [URL]) { - print(urls) + // Only ever interpret the first URL + if let url = urls.first { + let command = url.absoluteString.replacingOccurrences(of: "phpmon://", with: "") + + switch (command) { + case "list": + SiteListVC.show() + break + default: + break + } + } } } diff --git a/phpmon/Domain/Core/AppDelegate+Notifications.swift b/phpmon/Domain/Core/AppDelegate+Notifications.swift index f848b57..6337381 100644 --- a/phpmon/Domain/Core/AppDelegate+Notifications.swift +++ b/phpmon/Domain/Core/AppDelegate+Notifications.swift @@ -13,6 +13,10 @@ extension AppDelegate { // MARK: - Notifications + /** + Sets up notifications. That does mean we need to ask for permission first. + If we cannot get permission, we should log this. + */ public func setupNotifications() { let notificationCenter = UNUserNotificationCenter.current() notificationCenter.delegate = self