From 2feff336234766d6443d599b9a365009ba344436 Mon Sep 17 00:00:00 2001 From: Luis von der Eltz Date: Sat, 6 Feb 2021 15:37:46 +0100 Subject: [PATCH] Add OSX manager to example --- DesktopNotifications.Apple/AppleNotificationManager.cs | 6 ++++++ Example/Example.csproj | 3 ++- Example/Program.cs | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/DesktopNotifications.Apple/AppleNotificationManager.cs b/DesktopNotifications.Apple/AppleNotificationManager.cs index c2dbaeb..d23263f 100644 --- a/DesktopNotifications.Apple/AppleNotificationManager.cs +++ b/DesktopNotifications.Apple/AppleNotificationManager.cs @@ -1,10 +1,14 @@ using System; +using System.Runtime.InteropServices; using System.Threading.Tasks; namespace DesktopNotifications.Apple { public class AppleNotificationManager : INotificationManager { + [DllImport("DesktopNotifications.Apple.Native.dylib")] + private static extern void ShowNotification(); + public void Dispose() { } @@ -19,6 +23,8 @@ namespace DesktopNotifications.Apple public ValueTask ShowNotification(Notification notification, DateTimeOffset? expirationTime = null) { + ShowNotification(); + return default; } } diff --git a/Example/Example.csproj b/Example/Example.csproj index 7ecc35e..3ab9042 100644 --- a/Example/Example.csproj +++ b/Example/Example.csproj @@ -1,4 +1,4 @@ - + Exe @@ -7,6 +7,7 @@ + diff --git a/Example/Program.cs b/Example/Program.cs index 88f0bc9..13ef5b3 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using DesktopNotifications; +using DesktopNotifications.Apple; using DesktopNotifications.FreeDesktop; using DesktopNotifications.Windows; @@ -25,6 +26,11 @@ namespace Example return new WindowsNotificationManager(); } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return new AppleNotificationManager(); + } + throw new PlatformNotSupportedException(); }