![]() |
VOOZH | about |
dotnet add package LocalNotifications --version 3.0.0.2
NuGet\Install-Package LocalNotifications -Version 3.0.0.2
<PackageReference Include="LocalNotifications" Version="3.0.0.2" />
<PackageVersion Include="LocalNotifications" Version="3.0.0.2" />Directory.Packages.props
<PackageReference Include="LocalNotifications" />Project file
paket add LocalNotifications --version 3.0.0.2
#r "nuget: LocalNotifications, 3.0.0.2"
#:package LocalNotifications@3.0.0.2
#addin nuget:?package=LocalNotifications&version=3.0.0.2Install as a Cake Addin
#tool nuget:?package=LocalNotifications&version=3.0.0.2Install as a Cake Tool
A cross-platform local notifications plugin for .NET MAUI — supports Android and iOS with scheduling, repeating, and Firebase push notification integration.
Install via NuGet Package Manager:
dotnet add package LocalNotifications
Or search for LocalNotifications in the NuGet Package Manager in Visual Studio.
MauiProgram.csAdd .UseLocalNotifications() in your CreateMauiApp() method:
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseLocalNotifications(isFirebase: false, autoRegistration: true);
return builder.Build();
}
| Parameter | Description |
|---|---|
isFirebase |
Set to true to enable Firebase Cloud Messaging |
autoRegistration |
Set to true to automatically register lifecycle events |
If you need more control, you can manually configure platform lifecycle events instead of using autoRegistration:
builder.ConfigureLifecycleEvents(events =>
{
#if ANDROID
events.AddAndroid(android => android
.OnCreate((activity, bundle) => OnNotificationTapped(activity.Intent))
.OnNewIntent((activity, intent) => OnNotificationTapped(intent)));
static void OnNotificationTapped(Android.Content.Intent intent)
{
LocalNotifications.Platform.NotificationService.NotificationTapped(intent);
}
#elif IOS
events.AddiOS(iOS => iOS.FinishedLaunching((app, options) =>
{
LocalNotifications.Platform.NotificationService.Initialize(
options: options,
isFirebase: false,
autoRegistration: true);
return true;
}));
#endif
});
LocalNotificationCenter.Current.Show(
notificationId: 1,
title: "Hello!",
description: "This notification shows immediately.",
payload: "my_payload",
androidOptions: new AndroidOptions { IconName = "notification_icon" },
iOSOptions: new iOSOptions { Sound = "default" });
LocalNotificationCenter.Current.Schedule(
notificationId: 2,
title: "Reminder",
description: "This fires in 30 seconds.",
dateTime: DateTime.Now.AddSeconds(30),
payload: "scheduled_payload",
androidOptions: new AndroidOptions(),
iOSOptions: new iOSOptions());
var time = new Time(hour: 9, minute: 0);
// Every hour at :00
LocalNotificationCenter.Current.ShowHourly(
notificationId: 3, title: "Hourly", description: "Every hour",
time: time, payload: "hourly");
// Every day at 09:00
LocalNotificationCenter.Current.ShowDaily(
notificationId: 4, title: "Daily", description: "Every day at 9 AM",
time: time, payload: "daily");
// Every Monday at 09:00
LocalNotificationCenter.Current.ShowWeekly(
notificationId: 5, title: "Weekly", description: "Every Monday at 9 AM",
weekDay: Day.Monday, time: time, payload: "weekly");
// Cancel a specific notification
LocalNotificationCenter.Current.Cancel(notificationId: 1);
// Cancel all notifications
LocalNotificationCenter.Current.CancelAll();
var pending = LocalNotificationCenter.Current.GetPendingNotificationRequests();
foreach (var n in pending)
{
Debug.WriteLine($"Pending: ID={n.NotificationId}, Title={n.Title}");
}
bool granted = await LocalNotificationCenter.Current.RequestNotificationPermission(
new NotificationPermission { AskPermission = true });
bool enabled = await LocalNotificationCenter.Current.IsNotificationsEnabled();
// Fired when a notification is received while the app is in the foreground
LocalNotificationCenter.Current.OnNotificationReceived += (e) =>
{
Debug.WriteLine($"Received: ID={e.NotificationId}");
};
// Fired when the user taps a notification
LocalNotificationCenter.Current.OnNotificationTapped += (e) =>
{
Debug.WriteLine($"Tapped: ID={e.NotificationId}, Payload={e.Payload}");
};
// Fired when Firebase token is refreshed
LocalNotificationCenter.Current.OnTokenRefresh += (source, e) =>
{
Debug.WriteLine($"Firebase Token: {e.Token}");
};
To enable Firebase Cloud Messaging, pass isFirebase: true when registering:
.UseLocalNotifications(isFirebase: true, autoRegistration: true);
google-services.json to your Android projectGoogleServicesJsonAndroidManifest.xml:<uses-permission android:name="android.permission.INTERNET" />
GoogleService-Info.plist to your iOS project (Build Action: BundleResource)Info.plist, enable Background Modes → Remote NotificationsFirebaseAppDelegateProxyEnabled = NO in Info.plistEntitlements.plist, enable Push Notificationsstring token = await LocalNotificationCenter.Current.GetTokenAsync();
⚠️ iOS imposes a limit of 64 pending notifications. Only the 64 soonest-firing notifications are kept.
⚠️ Some Android OEMs customize the OS in ways that may prevent background scheduling from working reliably. See Don't Kill My App for details.
Check out the sample app for a complete working example.
| Platform | Screenshots |
|---|---|
| Android | <img width="300" alt="Android screenshot 1" src="https://user-images.githubusercontent.com/22674537/199664085-a547575f-1506-4249-bfaf-5417df8dcbad.png"> <img width="300" alt="Android screenshot 2" src="https://user-images.githubusercontent.com/22674537/199664456-dd9e8b62-c9c3-42c2-a91b-51e716861f57.png"> |
| iOS | <img width="300" alt="iOS screenshot 1" src="https://user-images.githubusercontent.com/22674537/200498405-03ebc105-2728-4bb4-bccf-573266f12ed7.png"> <img width="300" alt="iOS screenshot 2" src="https://user-images.githubusercontent.com/22674537/200498521-88d915ac-bc30-4e6b-b90a-7126248f73a8.png"> |
This project is licensed under the .
For more information, visit the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-android35.0 net9.0-android35.0 is compatible. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-ios18.0 net9.0-ios18.0 is compatible. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.