Skip to content

Local Notifications

  • GitHub stars for shinyorg/shiny
  • NuGet downloads for Shiny.Notifications
Operating Systems
Android
iOS

Local notifications allow your app to alert users even when the app is not in the foreground. Use them to notify about completed background tasks, BLE events, geofence triggers, and more.

Shiny.NotificationsNuGet package Shiny.Notifications
Shiny.Hosting.MauiNuGet package Shiny.Hosting.Maui
INotificationManager notifications; // injected
// Basic notification permission
var access = await notifications.RequestAccess();
// With additional capabilities
var access = await notifications.RequestAccess(
AccessRequestFlags.Notification |
AccessRequestFlags.TimeSensitivity |
AccessRequestFlags.LocationAware
);
FlagDescription
NotificationBasic notification permission
TimeSensitivityiOS Time Sensitive notifications
LocationAwareRequired for geofence-triggered notifications

Implement INotificationDelegate to respond when a user taps a notification.

public class MyNotificationDelegate : INotificationDelegate
{
public Task OnEntry(NotificationResponse response)
{
var notification = response.Notification;
var actionId = response.ActionIdentifier;
var text = response.Text; // from text reply actions
// Access custom payload
if (notification.Payload.TryGetValue("orderId", out var orderId))
{
// Navigate to order details
}
return Task.CompletedTask;
}
}
services.AddNotifications<MyNotificationDelegate>();

To handle notification taps properly on Android, add an intent filter to your MainActivity:

[Activity(
Theme = "@style/Maui.SplashTheme",
MainLauncher = true,
LaunchMode = LaunchMode.SingleTop
)]
[IntentFilter(
new[] { Shiny.ShinyNotificationIntents.NotificationClickAction },
Categories = new[] { "android.intent.category.DEFAULT" }
)]
public class MainActivity : MauiAppCompatActivity
{
}