LocalNotifications 3.0.0.2
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" />
<PackageReference Include="LocalNotifications" />
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.2
#tool nuget:?package=LocalNotifications&version=3.0.0.2
LocalNotifications for .NET MAUI
A cross-platform local notifications plugin for .NET MAUI — supports Android and iOS with scheduling, repeating, and Firebase push notification integration.
Table of Contents
- Features
- Installation
- Getting Started
- Usage
- Events
- Firebase Push Notifications
- Platform Notes
- Sample App
- License
Features
- 🔔 Show notifications immediately
- ⏰ Schedule notifications at a specific date/time
- 🔁 Repeating notifications — hourly, daily, or weekly
- 📋 Manage pending notifications (list, cancel one, cancel all)
- 🔑 Permission handling for Android 13+ (POST_NOTIFICATIONS)
- 🔥 Firebase Cloud Messaging integration (Android & iOS)
Installation
Install via NuGet Package Manager:
dotnet add package LocalNotifications
Or search for LocalNotifications in the NuGet Package Manager in Visual Studio.
Getting Started
1. Register in MauiProgram.cs
Add .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 |
2. (Alternative) Manual Lifecycle Registration
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
});
Usage
Show a Notification Immediately
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" });
Schedule a Notification
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());
Repeating Notifications
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 Notifications
// Cancel a specific notification
LocalNotificationCenter.Current.Cancel(notificationId: 1);
// Cancel all notifications
LocalNotificationCenter.Current.CancelAll();
Get Pending Notifications
var pending = LocalNotificationCenter.Current.GetPendingNotificationRequests();
foreach (var n in pending)
{
Debug.WriteLine($"Pending: ID={n.NotificationId}, Title={n.Title}");
}
Request Permission
bool granted = await LocalNotificationCenter.Current.RequestNotificationPermission(
new NotificationPermission { AskPermission = true });
Check if Notifications Are Enabled
bool enabled = await LocalNotificationCenter.Current.IsNotificationsEnabled();
Events
// 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}");
};
Firebase Push Notifications
To enable Firebase Cloud Messaging, pass isFirebase: true when registering:
.UseLocalNotifications(isFirebase: true, autoRegistration: true);
Android Setup
- Add
google-services.jsonto your Android project - Set its Build Action to
GoogleServicesJson - Add the following permission to
AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
iOS Setup
- Add
GoogleService-Info.plistto your iOS project (Build Action:BundleResource) - In
Info.plist, enable Background Modes → Remote Notifications - Add
FirebaseAppDelegateProxyEnabled=NOinInfo.plist - In
Entitlements.plist, enable Push Notifications - Configure the required Apple Push Notification certificates and provisioning profile
Get Firebase Token
string token = await LocalNotificationCenter.Current.GetTokenAsync();
Platform Notes
iOS
⚠️ iOS imposes a limit of 64 pending notifications. Only the 64 soonest-firing notifications are kept.
Android
⚠️ Some Android OEMs customize the OS in ways that may prevent background scheduling from working reliably. See Don't Kill My App for details.
Sample App
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"> |
License
This project is licensed under the MIT License.
For more information, visit the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-android35.0 is compatible. net9.0-browser was computed. net9.0-ios was computed. net9.0-ios18.0 is compatible. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
-
net9.0-android35.0
- Newtonsoft.Json (>= 13.0.3)
- Xamarin.AndroidX.Work.Runtime (>= 2.10.0.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)
-
net9.0-ios18.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.