VOOZH about

URL: https://www.nuget.org/packages/Tingle.Extensions.PushNotifications/

⇱ NuGet Gallery | Tingle.Extensions.PushNotifications 5.3.0




👁 Image
Tingle.Extensions.PushNotifications 5.3.0

dotnet add package Tingle.Extensions.PushNotifications --version 5.3.0
 
 
NuGet\Install-Package Tingle.Extensions.PushNotifications -Version 5.3.0
 
 
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="Tingle.Extensions.PushNotifications" Version="5.3.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tingle.Extensions.PushNotifications" Version="5.3.0" />
 
Directory.Packages.props
<PackageReference Include="Tingle.Extensions.PushNotifications" />
 
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 Tingle.Extensions.PushNotifications --version 5.3.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tingle.Extensions.PushNotifications, 5.3.0"
 
 
#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 Tingle.Extensions.PushNotifications@5.3.0
 
 
#: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=Tingle.Extensions.PushNotifications&version=5.3.0
 
Install as a Cake Addin
#tool nuget:?package=Tingle.Extensions.PushNotifications&version=5.3.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Tingle.Extensions.PushNotifications

This library contains lightweight clients for sending push notifications to devices via APNS and FCM. It exists either because there is no comprehensive library or the official library cannot be tested by stubbing HTTP requests

Apple Push Notification Service (APNs)

This library is a wrapper around the service, you still need to understand how the service works in order to make correct requests. Make sure to read the official docs.

In your Program.cs:

builder.Services.AddApnsNotifier(options =>
{
 options.TeamId = builder.Configuration["Apns:TeamId"];
 options.KeyId = builder.Configuration["Apns:KeyId"];
 options.BundleId = builder.Configuration["Apns:BundleId"];

 options.UsePrivateKey(keyId => environment.ContentRootFileProvider.GetFileInfo($"AuthKey_{keyId}.p8"));
});

In your appsettings.json (or any other configuration store/source you use):

{
 "Apns:TeamId": "AA0A0AAAA0",
 "Apns:BundleId": "com.apple.iBooks",
 "Apns:KeyId": "AA00AA000A",

 // ...
}

You can also choose to provide the private key directly:

builder.Services.AddApnsNotifier(options =>
{
 options.TeamId = builder.Configuration["Apns:TeamId"];
 options.KeyId = builder.Configuration["Apns:KeyId"];
 options.BundleId = builder.Configuration["Apns:BundleId"];

 options.PrivateKeyBytes = (keyId) => File.ReadAllBytes($"apns-key.p8");
});

In a sample service (named NotificationManager.cs below):

private readonly IHostEnvironment environment;
private readonly ApnsNotifier apnsNotifier;

public NotificationManager(IHostEnvironment environment, ApnsNotifier apnsNotifier)
{
 this.environment = environment ?? throw new ArgumentNullException(nameof(environment));
 this.apnsNotifier = apnsNotifier ?? throw new ArgumentNullException(nameof(apnsNotifier));
}

async Task SendApnsAsync(CancellationToken cancellationToken = default)
{
 var header = new ApnsMessageHeader
 {
 CollapseId = request.Collapse,
 Environment = environment.IsProduction() ? ApnsEnvironment.Production : ApnsEnvironment.Development,
 PushType = ApnsPushType.Background,
 DeviceToken = "<device-token-here>",
 };

 // According to Listing 7-1 Configuring a background update notification,
 // we should set content-available = 1 if the other properties of aps are not set.
 // https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html
 var aps = new ApnsMessagePayload { ContentAvailable = 1, };
 var data = new ApnsMessageData(aps);

 await apnsNotifier.SendAsync(header, data, cancellationToken);
}

Firebase (FCM)

This library is a wrapper around the service, you still need to understand how the service works in order to make correct requests. Make sure to read the official docs.

V1 HTTP API

In your appsettings.json (or any other configuration store/source you use):

{
 "Firebase:ProjectId": "dummy-id",

 // ...
}

In Program.cs add the following code snippet:

builder.Services.AddFirebaseNotifier(options =>
{
 var projectId = configuration.GetRequiredValue<string>("Firebase:ProjectId");
 options.UseConfigurationFromFile(environment.ContentRootFileProvider.GetFileInfo($"{projectId}.json"));
});

// ...

You can also choose to provide the configuration details directly:

builder.Services.AddFirebaseNotifier(options =>
{
 options.ProjectId = builder.Configuration["Firebase:ProjectId"];
 options.ClientEmail = builder.Configuration["Firebase:ClientEmail"];
 options.TokenUri = builder.Configuration["Firebase:TokenUri"];
 options.PrivateKey = builder.Configuration["Firebase:PrivateKey"];
});

In a sample service (named NotificationManager.cs below):

private readonly IHostEnvironment environment;
private readonly FirebaseNotifier firebaseNotifier;

public NotificationManager(IHostEnvironment environment, FirebaseNotifier firebaseNotifier)
{
 this.environment = environment ?? throw new ArgumentNullException(nameof(environment));
 this.firebaseNotifier = firebaseNotifier ?? throw new ArgumentNullException(nameof(firebaseNotifier));
}

async Task SendFirebaseAsync(CancellationToken cancellationToken = default)
{
 var message = new FirebaseRequestMessage
 {
 Token = "<token-here>",
 Android = new FirebaseMessageAndroid
 {
 // add title, body, etc here
 CollapseKey = null,
 },
 Data = new Dictionary<string, string>
 {
 ["key1"] = "something here",
 },
 };

 // send the push notification
 await firebaseNotifier.SendAsync(message, cancellationToken);
}

Legacy HTTP API

In your Program.cs:

builder.Services.AddFcmLegacyNotifier(options =>
{
 options.Key = builder.Configuration["Firebase:Key"];
});

In your appsettings.json (or any other configuration store/source you use):

{
 "Firebase:Key": "<your-legacy-key-here>",

 // ...
}

In a sample service (named NotificationManager.cs below):

private readonly IHostEnvironment environment;
private readonly FcmLegacyNotifier firebaseNotifier;

public NotificationManager(IHostEnvironment environment, FcmLegacyNotifier firebaseNotifier)
{
 this.environment = environment ?? throw new ArgumentNullException(nameof(environment));
 this.firebaseNotifier = firebaseNotifier ?? throw new ArgumentNullException(nameof(firebaseNotifier));
}

async Task SendFirebaseAsync(CancellationToken cancellationToken = default)
{
 var message = new FcmLegacyRequest
 {
 RegistrationIds = ["<token1-here>","<token2-here>"],
 Data = new Dictionary<string, string>
 {
 ["key1"] = "something here",
 },
 };

 // send the push notification
 await firebaseNotifier.SendAsync(message, cancellationToken);
}
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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
5.3.0 362 8/26/2025
5.2.0 350 4/21/2025
5.1.1 361 4/20/2025
5.1.0 348 4/20/2025
5.0.1 458 2/21/2025
5.0.0 374 11/19/2024
4.14.1 540 10/14/2024
4.14.0 409 9/16/2024
4.13.0 584 8/13/2024
4.12.0 316 8/7/2024
4.11.2 389 7/15/2024
4.11.1 437 6/26/2024
4.11.0 397 6/6/2024
4.10.1 295 6/5/2024
4.10.0 287 5/27/2024
4.9.0 379 5/16/2024
4.8.0 419 5/5/2024
4.7.0 560 3/25/2024
4.6.0 463 3/8/2024
4.5.0 1,144 11/22/2023
Loading failed