LocalNotifications 4.0.0
dotnet add package LocalNotifications --version 4.0.0
NuGet\Install-Package LocalNotifications -Version 4.0.0
<PackageReference Include="LocalNotifications" Version="4.0.0" />
<PackageVersion Include="LocalNotifications" Version="4.0.0" />
<PackageReference Include="LocalNotifications" />
paket add LocalNotifications --version 4.0.0
#r "nuget: LocalNotifications, 4.0.0"
#:package LocalNotifications@4.0.0
#addin nuget:?package=LocalNotifications&version=4.0.0
#tool nuget:?package=LocalNotifications&version=4.0.0
LocalNotifications 4.0.0
Local notifications for .NET 10 MAUI on Android and iOS. Version 4.0.0 supports net10.0, net10.0-android, and net10.0-ios. Android builds target API 36 while retaining API 21 as minimum; iOS minimum is 12.2.
Installation
dotnet add package LocalNotifications --version 4.0.0
Register in MauiProgram.cs. Both arguments are required:
using LocalNotifications;
builder
.UseMauiApp<App>()
.UseLocalNotifications(isFirebase: false, autoRegistration: true);
isFirebase enables Firebase Cloud Messaging integration. autoRegistration controls automatic push-notification registration when Firebase is enabled. Lifecycle handling is configured by UseLocalNotifications.
Usage
Examples use LocalNotifications and standard .NET namespaces:
using LocalNotifications;
using System;
using System.Diagnostics;
Immediate notification
LocalNotificationCenter.Current.Show(
notificationId: 1,
title: "Hello",
description: "Shown now",
payload: "immediate",
androidOptions: new AndroidOptions { IconName = "notification_icon" },
iOSOptions: new iOSOptions { Sound = "default" });
Scheduled notification
LocalNotificationCenter.Current.Schedule(
notificationId: 2,
title: "Reminder",
description: "Scheduled notification",
dateTime: DateTime.Now.AddMinutes(10),
payload: "scheduled",
androidOptions: new AndroidOptions(),
iOSOptions: new iOSOptions());
Repeating notifications
var time = new Time(hour: 9, minute: 0);
LocalNotificationCenter.Current.ShowHourly(
3, "Hourly", "Every hour", time, "hourly");
LocalNotificationCenter.Current.ShowDaily(
4, "Daily", "Every day", time, "daily");
LocalNotificationCenter.Current.ShowWeekly(
5, "Weekly", "Every Monday", Day.Monday, time, "weekly");
Cancel and inspect pending notifications
LocalNotificationCenter.Current.Cancel(notificationId: 2);
LocalNotificationCenter.Current.CancelAll();
var pending = LocalNotificationCenter.Current.GetPendingNotificationRequests();
foreach (var request in pending)
Debug.WriteLine($"{request.NotificationId}: {request.Title}");
Permissions and settings
bool granted = await LocalNotificationCenter.Current.RequestNotificationPermission(
new NotificationPermission { AskPermission = true });
bool enabled = await LocalNotificationCenter.Current.IsNotificationsEnabled();
Android API 33 and later require runtime POST_NOTIFICATIONS permission. Library declares permission in merged manifest; app must request it at runtime before showing notifications.
Events
LocalNotificationCenter.Current.OnNotificationReceived += e =>
Debug.WriteLine($"Received {e.NotificationId}: {e.Payload}");
LocalNotificationCenter.Current.OnNotificationTapped += e =>
Debug.WriteLine($"Tapped {e.NotificationId}: {e.Payload}");
LocalNotificationCenter.Current.OnTokenRefresh += (source, e) =>
Debug.WriteLine($"Firebase token: {e.Token}");
Firebase Cloud Messaging
Register with Firebase enabled:
builder.UseLocalNotifications(isFirebase: true, autoRegistration: true);
Android:
- Add
google-services.jsonto app project withGoogleServicesJsonbuild action. - Add Internet permission to
Platforms/Android/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
- On API 33+, request
POST_NOTIFICATIONSpermission as shown above.
iOS:
- Add
GoogleService-Info.plistwithBundleResourcebuild action. - Enable Background Modes and Remote notifications in
Info.plist. - Set
FirebaseAppDelegateProxyEnabledtoNOinInfo.plist. - Enable Push Notifications in
Entitlements.plist. - Configure APNs credentials and provisioning in Apple Developer and Firebase.
Retrieve current token after Firebase setup:
string token = await LocalNotificationCenter.Current.GetTokenAsync();
Scheduling limits
Android scheduling uses WorkManager and is best-effort. Delivery may be delayed by Doze, battery optimization, or OEM background restrictions. Library requires no exact-alarm permission and provides no exact-time guarantee.
iOS keeps at most 64 pending notifications; system retains 64 notifications scheduled to fire soonest.
Migrating to 4.0.0
Version 4 drops .NET 9 targets. Retarget app to .NET 10 (net10.0-android and/or net10.0-ios) and call UseLocalNotifications with both required arguments.
Build and pack
dotnet build LocalNotifications.sln -c Release
dotnet pack Source/LocalNotifications/LocalNotifications.csproj -c Release
See sample app. Licensed under MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-ios was computed. net10.0-ios26.0 is compatible. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Newtonsoft.Json (>= 13.0.3)
-
net10.0-android36.0
- Newtonsoft.Json (>= 13.0.3)
- Xamarin.AndroidX.Work.Runtime (>= 2.11.2.1)
- Xamarin.Firebase.Common (>= 120.1.2)
- Xamarin.Firebase.Messaging (>= 123.0.8)
- Xamarin.GooglePlayServices.Base (>= 118.1.0)
- Xamarin.GooglePlayServices.Basement (>= 118.1.0)
- Xamarin.GooglePlayServices.Tasks (>= 118.0.2)
-
net10.0-ios26.0
- AdamE.Firebase.iOS.CloudMessaging (>= 11.10.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.