Skip to content

Providers

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.

The default provider uses Firebase on Android and APNs on iOS directly. No additional NuGet package needed.

services.AddPush<MyPushDelegate>();

Firebase Cloud Messaging can be used as a unified provider across both platforms.

NuGet: Shiny.Push.FirebaseMessaging

// Auto-config from google-services.json
services.AddPushFirebaseMessaging<MyPushDelegate>();

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"
);
#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;
}
}

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();
}
}
services.AddPush<MyPushDelegate>();
services.AddShinyService<MyPushProvider>();