AlphaOmega.PushSharp 4.1.9

dotnet add package AlphaOmega.PushSharp --version 4.1.9
                    
NuGet\Install-Package AlphaOmega.PushSharp -Version 4.1.9
                    
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.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlphaOmega.PushSharp" Version="4.1.9" />
                    
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.9
                    
#r "nuget: AlphaOmega.PushSharp, 4.1.9"
                    
#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.9
                    
#: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.9
                    
Install as a Cake Addin
#tool nuget:?package=AlphaOmega.PushSharp&version=4.1.9
                    
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. Updated .NET Framework from v4.5 to v4.8
  5. Added .NET Standard v2.0
  6. Changed assembly signing key file for all assemblies. (PublicKeyToken=a8ac5fc45c3adb8d)
  7. Added PE file signing. (S/N: 00c18bc05b61a77408c694bd3542d035)
  8. Added CI/CD pipelines

Sample Usage

APNS HTTP/2 Sample usage

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

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

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 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 was computed.  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 was computed.  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 is compatible.  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. 
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.9 46 7/27/2025
4.1.6 424 7/24/2025
4.1.5 424 7/24/2025
4.1.4 183 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), Added .NET Standard 2.0 build. For details on the full changelog, see the Releases tab on GitHub.