Shiny .NET v4 is here with BLE Windows Support, Improved GPS, & More! Check It Out
Local Notifications
Getting Started
Section titled “Getting Started” 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.
Platform Notes
Section titled “Platform Notes”| 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 |
Requesting Access
Section titled “Requesting Access”INotificationManager notifications; // injected
// Basic notification permissionvar access = await notifications.RequestAccess();
// With additional capabilitiesvar 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 |
Handling Notification Taps
Section titled “Handling Notification Taps”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; }}Registration
Section titled “Registration”services.AddNotifications<MyNotificationDelegate>();Platform Notes
Section titled “Platform Notes”Android
Section titled “Android”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{}