NtfyCator 0.3.0
dotnet add package NtfyCator --version 0.3.0
NuGet\Install-Package NtfyCator -Version 0.3.0
<PackageReference Include="NtfyCator" Version="0.3.0" />
<PackageVersion Include="NtfyCator" Version="0.3.0" />
<PackageReference Include="NtfyCator" />
paket add NtfyCator --version 0.3.0
#r "nuget: NtfyCator, 0.3.0"
#addin nuget:?package=NtfyCator&version=0.3.0
#tool nuget:?package=NtfyCator&version=0.3.0
NtfyCator
A minimalistic .NET library for publishing messages to ntfy.sh and self-hosted instances.
Features
✅ Simple and lightweight
✅ Async-friendly API
✅ Easy integration
Installation
You can install NtfyCator
via NuGet:
dotnet add package NtfyCator --version 0.3.0
Or using the NuGet Package Manager in Visual Studio:
Install-Package NtfyCator -Version 0.3.0
Getting Started
Register NtfyCator in Program.cs
In an ASP.NET Core or .NET Generic Host application:
using NtfyCator;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddNtfyCator();
var app = builder.Build();
And now you are good to go to publish to ntfy.sh. If you need to target a self-hosted instance, you can simply configure the server URI:
builder.Services.AddNtfyCator(options =>
{
options.Uri = "https://my.ntfy.server";
});
Inject & Use the Client
public class NotificationService
{
private readonly INotificator _notificator;
public NotificationService(INotificator notificator)
{
_notificator = notificator;
}
public async Task SendNotification()
{
var message = new NtfyMessageBuilder("my-topic")
.WithTitle("Test Message")
.WithMarkdownBody("This is _just_ a **Test**!")
.WithPriority(NtfyPriority.High)
.WithTags("tag1", "tag2")
.Build();
await notificator.NotifyAsync(message);
}
}
INotificator
also provides an alternative fluent interface that combines message building and sending:
await notificator.NotifyTopic("my-topic")
.WithBody("Just another Test!")
.WithPriority(NtfyPriority.Low)
.SendAsync();
Authorization / Authentication
NtfyCator currently supports access token authorization. To enable it simply call before first usage:
notificator.WithAccessToken("tk_xxxxxxxxxxxxxxxxx");
Every subsequent notification will use the access token as Bearer Token.
As an alternative, NtfyCator also supports user/password authentication:
notificator.WithCredentials("username", "my*password");
If possible you should always prefer token authorization over providing username and password.
Emoji Support
ntfy.sh
uses a wide range of custom tags that will be transformed into emojis. NtfyCator supports adding emojis as tags and provides an Emoji
enum type so you don't need to use magic strings.
var message = new NtfyMessageBuilder("my-topic")
.WithTags(Emoji.Wink, Emoji.Rocket) // 😉, 🚀
.Build();
Configuration Options
NtfyCator allows configuring these options:
Option | Type | Default Value | Description |
---|---|---|---|
Uri |
String |
https://ntfy.sh |
Server URI |
License
MIT License - see LICENSE for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
- System.Text.Json (>= 9.0.4)
-
net8.0
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Text.Json (>= 9.0.4)
-
net9.0
- Microsoft.Extensions.Http (>= 9.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.