Skip to content
Client v5: BLE, BLE Hosting, HTTP, Jobs - Linux, MacOS, & Blazor Support! Full AOT, RX on BLE only & MANY other features! Power up!

Azure Push Notifications

GitHubGitHub stars for shinyorg/shiny
DownloadsNuGet downloads for Shiny.Push.AzureNotificationHubs
Operating Systems
Android
iOS
Windows
Changed files
  • MyApp/
Delegates/MyPushDelegate.cs
MyPushDelegate.cs
1using Shiny.Push;23namespace MyApp.Delegates;45public partial class MyPushDelegate : PushDelegate6{7    public override async Task OnEntry(PushNotification notification)8    {9    }1011    public override async Task OnReceived(PushNotification notification)12    {13    }1415    public override async Task OnNewToken(string token)16    {17    }1819    public override async Task OnUnRegistered(string token)20    {21    }22}

Azure Notification Hubs provides tag-based targeting, templates, and enterprise-scale push management across iOS (APNs), Android (FCM v1), and Windows (WNS).

services.AddPushAzureNotificationHubs<MyPushDelegate>(
"Endpoint=sb://your-hub.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=your-key",
"your-hub-name"
);
#if ANDROID
services.AddPushAzureNotificationHubs<MyPushDelegate>(
"your-connection-string",
"your-hub-name",
new FirebaseConfig(
UseEmbeddedConfiguration: false,
AppId: "your-app-id",
SenderId: "your-sender-id",
ProjectId: "your-project-id",
ApiKey: "your-api-key"
)
);
#else
services.AddPushAzureNotificationHubs<MyPushDelegate>(
"your-connection-string",
"your-hub-name"
);
#endif

Use IPushInstallationEvent to modify the Azure Notification Hubs installation before it’s sent.

public class MyInstallationEvent : IPushInstallationEvent
{
public Task OnBeforeSend(Installation installation)
{
// Add custom tags
installation.Tags ??= new List<string>();
installation.Tags.Add("custom-tag");
// Add templates
installation.Templates ??= new Dictionary<string, InstallationTemplate>();
installation.Templates["myTemplate"] = new InstallationTemplate
{
Body = "{\"data\":{\"message\":\"$(message)\"}}"
};
return Task.CompletedTask;
}
}