Providers
Overview
Section titled “Overview”Push providers layer on top of native APNs (iOS) and FCM (Android) to add features like tag-based targeting, templates, and unified management. Shiny supports multiple providers out of the box.
Native (Default)
Section titled “Native (Default)”The default provider uses Firebase on Android and APNs on iOS directly. No additional NuGet package needed.
services.AddPush<MyPushDelegate>();Firebase Messaging
Section titled “Firebase Messaging”Firebase Cloud Messaging can be used as a unified provider across both platforms.
NuGet: Shiny.Push.FirebaseMessaging
// Auto-config from google-services.jsonservices.AddPushFirebaseMessaging<MyPushDelegate>();Azure Notification Hubs
Section titled “Azure Notification Hubs”Azure Notification Hubs provides tag-based targeting, templates, and enterprise-scale push management.
NuGet: Shiny.Push.AzureNotificationHubs
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; }}Custom Provider
Section titled “Custom Provider”Create your own push provider by implementing IPushProvider.
public class MyPushProvider : IPushProvider{#if ANDROID public async Task<string> Register(string nativeToken) { // Register with your backend, return your provider token var providerToken = await MyBackend.RegisterToken(nativeToken); return providerToken; }#elif IOS public async Task<string> Register(NSData nativeToken) { var tokenString = nativeToken.ToPushTokenString(); var providerToken = await MyBackend.RegisterToken(tokenString); return providerToken; }#endif
public async Task UnRegister() { await MyBackend.UnregisterToken(); }}Registration
Section titled “Registration”services.AddPush<MyPushDelegate>();services.AddShinyService<MyPushProvider>();