AlphaOmega.PushSharp
4.1.9
dotnet add package AlphaOmega.PushSharp --version 4.1.9
NuGet\Install-Package AlphaOmega.PushSharp -Version 4.1.9
<PackageReference Include="AlphaOmega.PushSharp" Version="4.1.9" />
<PackageVersion Include="AlphaOmega.PushSharp" Version="4.1.9" />
<PackageReference Include="AlphaOmega.PushSharp" />
paket add AlphaOmega.PushSharp --version 4.1.9
#r "nuget: AlphaOmega.PushSharp, 4.1.9"
#:package AlphaOmega.PushSharp@4.1.9
#addin nuget:?package=AlphaOmega.PushSharp&version=4.1.9
#tool nuget:?package=AlphaOmega.PushSharp&version=4.1.9
PushSharp v4.1
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:
- Added Apple APNS HTTP/2 support (New version)
- Added Firebase Cloud Messaging V1 support (New version)
- Added Huawei HMS V1 (New) [V2 in progress...]
- Updated .NET Framework from v4.5 to v4.8
- Added .NET Standard v2.0
- Changed assembly signing key file for all assemblies. (PublicKeyToken=a8ac5fc45c3adb8d)
- Added PE file signing. (S/N: 00c18bc05b61a77408c694bd3542d035)
- 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 | 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 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. |
-
.NETFramework 4.8
- Newtonsoft.Json (>= 13.0.3)
- Portable.BouncyCastle (>= 1.9.0)
- System.Net.Http.WinHttpHandler (>= 9.0.7)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.3)
- Portable.BouncyCastle (>= 1.9.0)
- System.Net.Http.WinHttpHandler (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.