Skip to content
Document DB v12 - Improved Interceptors with Soft Delete Integration, AI protections, & Admin UI with Aspire Integration!How!?

Local Notifications

GitHub GitHub stars for shinyorg/shiny
Downloads NuGet downloads for Shiny.Notifications
Linux NuGet downloads for Shiny.Notifications.Linux
Frameworks
.NET
.NET MAUI
Operating Systems
Android
iOS
macOS
Windows
Linux

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.

Feature iOS macOS Android Windows Linux
Send / schedule Full Full Full Full Full (in-process)
Channels Full Full Full Limited Limited
Geofence trigger Full N/A Full N/A N/A
Time-sensitive flag iOS 15+ macOS 12+ N/A N/A N/A
Changed files
  • MyApp/
Delegates/MyLocalNotificationDelegate.cs
MyLocalNotificationDelegate.cs
1using Shiny.Notifications;23namespace MyApp.Delegates;45public class MyLocalNotificationDelegate : INotificationDelegate6{7    public MyLocalNotificationDelegate() 8    {9    }1011    public async Task OnEntry(NotificationResponse response)12    {13    }14}
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
);
Flag Description
Notification Basic notification permission
TimeSensitivity iOS Time Sensitive notifications
LocationAware Required 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
{
}