AlphaOmega.PushSharp 4.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package AlphaOmega.PushSharp --version 4.1.2
                    
NuGet\Install-Package AlphaOmega.PushSharp -Version 4.1.2
                    
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="AlphaOmega.PushSharp" Version="4.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlphaOmega.PushSharp" Version="4.1.2" />
                    
Directory.Packages.props
<PackageReference Include="AlphaOmega.PushSharp" />
                    
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 AlphaOmega.PushSharp --version 4.1.2
                    
#r "nuget: AlphaOmega.PushSharp, 4.1.2"
                    
#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 AlphaOmega.PushSharp@4.1.2
                    
#: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=AlphaOmega.PushSharp&version=4.1.2
                    
Install as a Cake Addin
#tool nuget:?package=AlphaOmega.PushSharp&version=4.1.2
                    
Install as a Cake Tool

PushSharp v4.1

Auto build Nuget

PushSharp is a server-side library for sending Push Notifications to iOS/OSX (APNS HTTP/2), Android/Chrome (FCM V1), Huawei (HMS), Windows/Windows Phone, Amazon (ADM) and Blackberry devices!

Improvements:

  1. Added Apple APNS HTTP/2 support (New version)
  2. Added Firebase Cloud Messaging V1 support (New version)
  3. Added Huawei HMS V1 (New) [V2 in progress...]
  4. Changed assembly signing key file for all assemblies. (PublicKeyToken=a8ac5fc45c3adb8d)
  5. Added PE file signing. (S/N: 00c18bc05b61a77408c694bd3542d035)
  6. Added CI/CD pipelines

Sample Usage

APNS HTTP/2 Sample usage

var environment = ApnsSettings.ApnsServerEnvironment.Production;
var p8CertificatePath = "{P8CertificateFilePath}";
var p8CertificatePassword = "{P8CertificatePassword}";
var keyId = "{KeyId}";
var teamId = "{TeamId}";
var bundleId = "{com.company.appName}";

var settings = new ApnsSettings(
	environment,
	p8CertificatePath,
	p8CertificatePassword,
	keyId)
{
	AppBundleId = bundleId,
};

var config = new ApnsConfiguration(settings);
var broker = new ApnsServiceBroker(config);
broker.OnNotificationFailed += (notification, exception) =>
{

};
broker.OnNotificationSucceeded += (notification) =>
{

};

broker.Start();

foreach(var dt in MY_DEVICE_TOKEN_IDS)
{
	broker.QueueNotification(new ApnsNotification
	{
		DeviceToken = dt,
		Payload = JObject.Parse("{ \"aps\" : { \"alert\" : \"I want cookie\" } }")
	});
}

broker.Stop();

Firebase HTTP v1 Sample Usage

Here is how you would send a Firebase HTTP v1 notification:

var projectId = "{ProjectId}";
var privateKey = "{PrivateKey}";
var clientEmail = "{ClientEmail}";
var tokenUri = "{TokenUri}";

var settings = new FirebaseSettings(projectId, privateKey, clientEmail, tokenUri);
// var settings = JsonConvert.DeserializeObject<FirebaseSettings>("{Firebase.ServiceAccount.json}");
var config = new FirebaseConfiguration(settings);

// Create a new broker
var broker = new FirebaseServiceBroker(config);

// Wire up events
broker.OnNotificationFailed += (notification, aggregateEx) => {

	aggregateEx.Handle (ex => {
	
		// See what kind of exception it was to further diagnose
		if (ex is GcmNotificationException notificationException) {
			
			// Deal with the failed notification
			var gcmNotification = notificationException.Notification;
			var description = notificationException.Description;

			Console.WriteLine ($"Notification Failed: ID={gcmNotification.MessageId}, Desc={description}");
		} else if (ex is GcmMulticastResultException multicastException) {

			foreach (var succeededNotification in multicastException.Succeeded) {
				Console.WriteLine ($"Notification Succeeded: ID={succeededNotification.MessageId}");
			}

			foreach (var failedKvp in multicastException.Failed) {
				var n = failedKvp.Key;
				var e = failedKvp.Value;

				Console.WriteLine ($"Notification Failed: ID={n.MessageId}, Desc={e.Description}");
			}

		} else if (ex is DeviceSubscriptionExpiredException expiredException) {
			
			var oldId = expiredException.OldSubscriptionId;
			var newId = expiredException.NewSubscriptionId;

			Console.WriteLine ($"Device RegistrationId Expired: {oldId}");

			if (!string.IsNullOrWhiteSpace (newId)) {
				// If this value isn't null, our subscription changed and we should update our database
				Console.WriteLine ($"Device RegistrationId Changed To: {newId}");
			}
		} else if (ex is RetryAfterException retryException) {
			
			// If you get rate limited, you should stop sending messages until after the RetryAfterUtc date
			Console.WriteLine ($"Rate Limited, don't send more until after {retryException.RetryAfterUtc}");
		} else {
			Console.WriteLine ("Notification Failed for some unknown reason");
		}

		// Mark it as handled
		return true;
	});
};

broker.OnNotificationSucceeded += (notification) => Console.WriteLine ("Notification Sent!");

// Start the broker
broker.Start();

foreach (var regId in MY_REGISTRATION_IDS) {
	// Queue a notification to send
	var notification = new FirebaseNotification();
	notification.message.token = regId;
	notification.message.data = JObject.Parse("{ \"somekey\" : \"I want cookie\" }");

	broker.QueueNotification(notification);
}

// Stop the broker, wait for it to finish
// This isn't done after every message, but after you're
// done with the broker
broker.Stop();

Huawei (HMS) Sample Usage

Here is how you would send a Huawei (HMS) notification:

var clientSecret = "{ClientSecret}";
var projectId = "{ProjectId}";
var applicationId = "{ApplicationId}";

var config = new HuaweiConfiguration(clientSecret, projectId, applicationId);
var broker = new HuaweiServiceBroker(config);

broker.OnNotificationFailed += (notification, exception) =>
{
	
};

broker.OnNotificationSucceeded += (notification) => Console.WriteLine ("Notification Sent!");

broker.Start();

foreach(var regId in MY_REGISTRATION_IDS)
{
	var notification = new HuaweiNotification();
	notification.Message.token = new String[] { regId };
	notification.Message.data = JObject.Parse("{ \"somekey\" : \"I want cookie\" }");

	broker.QueueNotification(notification);
}

broker.Stop();

You can read other sample usages on original author page: Redth PushSharp

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 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
4.1.6 0 7/24/2025
4.1.5 0 7/24/2025
4.1.4 16 7/20/2025
4.1.3 132 7/14/2025
4.1.2 130 7/13/2025
4.1.1 129 7/13/2025

4.1.* - Updated APNS for HTTP/2 implementation, Updated Android FCM V1 implementation, Added Huawei (HMS), see project site for more info