OsNotifications 1.1.5

dotnet add package OsNotifications --version 1.1.5
                    
NuGet\Install-Package OsNotifications -Version 1.1.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OsNotifications" Version="1.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OsNotifications" Version="1.1.5" />
                    
Directory.Packages.props
<PackageReference Include="OsNotifications" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OsNotifications --version 1.1.5
                    
#r "nuget: OsNotifications, 1.1.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OsNotifications@1.1.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OsNotifications&version=1.1.5
                    
Install as a Cake Addin
#tool nuget:?package=OsNotifications&version=1.1.5
                    
Install as a Cake Tool

Native OS notifications

Usage

Calling Notifications.ShowNotification will display a notification using your OS's notification manager.

On MacOS, if you are working without a bundle and you do not want the notification to show Apple's "Finder", you need to specify the BundleIdentifier and this needs to correspond to a defined identifier, otherwise no notification will be shown. It is better to bundle your application to get your own application's icon to show up, but you could spoof another application as well (there is no guarantee that this works with every application though). Also, it must be specified whether the application is a console or GUI application, using SetGuiApplication, because if it is a GUI application and it is specified that it is a console application, the application would hang. For cross-platform compatibility, it's better to always do this. So, creating a notification will look like this:

Notifications.BundleIdentifier = "com.apple.finder"; // Optional (does nothing for bundled applications)
Notifications.SetGuiApplication(true); // false for console application
try {
    Notifications.ShowNotification("notification-title");
} catch (PlatformNotSupportedException e) {
    // Handle exception
}

Of course this works without flaws on Linux and MacOS, but not on Windows... <br/> If the application exits right after the ShowNotification call, the notification will not be shown on Windows, because of the asynchronous nature of Toast notifications. So, either don't display a notification just before exiting or just put a tiny delay (1000ms should be plenty) after the ShowNotification call.

This library uses Microsoft.Toolkit.Uwp.Notifications to display notifications on Windows. This dependency is not shown in the NuGet package because referencing a Windows library statically from a cross-platform library is something I could not figure out how to do. So, the DLLs are included in the NuGet package for this library instead. If anyone has a better fix for this, let me know.

Install

In your .NET project, execute the following command:

dotnet add package OsNotifications 

Build from source

The best way to build this project is on MacOS, because of the Objective-C code needing to be compiled. Make sure you have clang installed and then just run the following commands in the OsNotifications folder (so the folder that contains OsNotifications.csproj):

dotnet build --configuration Release
dotnet pack --no-build --configuration Release

You will get a .nupkg file which you can import using NuGet. Probably, just running dotnet build or dotnet publish ... while referencing the project will not work properly. I'm not sure about it, but I recommend using the pack command.

It should be possible to build this on Linux as well, you just need to find the appropriate libraries to compile Objective-C with and then probably change the clang command in OsNotifications/OsNotifications.csproj to something more Linux-friendly.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.5 1,077 5/25/2026
1.1.4 216 3/28/2026
1.1.3 3,661 4/22/2025
1.1.2 277 3/30/2025
1.1.1 231 3/30/2025
1.1.0 144 3/29/2025
1.0.0 192 3/28/2025
0.3.0 203 3/28/2025
0.2.0 335 3/23/2025
0.1.1 321 3/23/2025
0.1.0 331 3/23/2025