Azure Push Notifications
Overview
Section titled “Overview”Azure Notification Hubs provides tag-based targeting, templates, and enterprise-scale push management.
services.AddPushAzureNotificationHubs<MyPushDelegate>( "Endpoint=sb://your-hub.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=your-key", "your-hub-name");With Custom Firebase Config (Android)
Section titled “With Custom Firebase Config (Android)”#if ANDROIDservices.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" ));#elseservices.AddPushAzureNotificationHubs<MyPushDelegate>( "your-connection-string", "your-hub-name");#endifCustomizing the Installation
Section titled “Customizing the Installation”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; }}