Skip to content
Introducing AI Conversations: Natural Language Interaction for Your Apps! Learn More

Local Notifications

GitHubGitHub stars for shinyorg/shiny
DownloadsNuGet downloads for Shiny.Notifications
LinuxNuGet 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.

FeatureiOSmacOSAndroidWindowsLinux
Send / scheduleFullFullFullFullFull (in-process)
ChannelsFullFullFullLimitedLimited
Geofence triggerFullN/AFullN/AN/A
Time-sensitive flagiOS 15+macOS 12+N/AN/AN/A
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
{
}