maui-local-notifications

Guide for adding local notifications to .NET MAUI on Android, iOS, and Mac Catalyst. Covers notification channels, permissions, scheduling, foreground/background handling, and dependency injection registration; supports XAML/MVVM, C# Markup, and MauiReactor scenarios. Applicable to local notifications, scheduled notifications, notification channels, notification permissions, reminder/alert notifications, in-app notifications, and foreground notifications. Not for server-sent push notifications (use maui-push-notifications), permission-only handling (use maui-permissions), or app lifecycle background tasks (use maui-app-lifecycle).

Last repository push
GitHub Stars
181
Forks
21
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "maui-local-notifications" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-e5b0f4fb46d30ca2817d24081ca5f9ea7635b9ad7365208e404f5229839f65cb. Verify the upstream source and version against https://github.com/davidortinau/maui-skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Guide for adding local notifications to .NET MAUI on Android, iOS, and Mac Catalyst. Covers notification channels, permissions, scheduling, foreground/background handling, and dependency injection registration; supports XAML/MVVM, C# Markup, and MauiReactor scenarios. Applicable to local notifications, scheduled notifications, notification channels, notification permissions, reminder/alert notifications, in-app notifications, and foreground notifications. Not for server-sent push notifications (use maui-push-notifications), permission-only handling (use maui-permissions), or app lifecycle background tasks (use maui-app-lifecycle).

0 Downloads

Introduction source: third_party · davidortinau · 0.0.1 Reference

SkillPi interpretation

Tasks
1. Define cross-platform `INotificationManagerService` interface and event args 2. Implement Android notification service (channel, AlarmManager, BroadcastReceiver) 3. Implement iOS/Mac Catalyst notification service (UNUserNotificationCenter) 4. Register platform implementations via DI 5. Configure platform permissions and MainActivity
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: maui-local-notifications
description: >
  Add local notifications to .NET MAUI apps on Android, iOS, and Mac Catalyst.
  Covers notification channels, permissions, scheduling, foreground/background handling,
  and DI registration. Works with XAML/MVVM, C# Markup, and MauiReactor.
  USE FOR: "local notification", "schedule notification", "notification channel",
  "notification permission", "reminder notification", "alert notification",
  "in-app notification", "foreground notification".
  DO NOT USE FOR: push notifications from a server (use maui-push-notifications),
  permission handling only (use maui-permissions), or app lifecycle background tasks (use maui-app-lifecycle).

.NET MAUI Local Notifications

Implementation overview

  1. Define cross-platform INotificationManagerService interface and event args
  2. Implement Android notification service (channel, AlarmManager, BroadcastReceiver)
  3. Implement iOS/Mac Catalyst notification service (UNUserNotificationCenter)
  4. Register platform implementations via DI
  5. Configure platform permissions and MainActivity

See references/local-notifications-api.md for full implementation code.

Platform gotchas

Android

Issue Fix
Notifications silently fail on API 33+ Must request POST_NOTIFICATIONS runtime permission first
PendingIntent crash on Android 12+ Must include PendingIntentFlags.Immutable for API 31+
Scheduled notifications lost on reboot AlarmManager does not survive device restart — re-schedule on boot via BOOT_COMPLETED receiver
No notification appears Channel not created — required on API 26+ (Android 8.0)
Notification tap doesn't return to app LaunchMode = LaunchMode.SingleTop must be set on MainActivity
// ✅ Correct — API 31+ requires Immutable flag
var pendingIntentFlags = (Build.VERSION.SdkInt >= BuildVersionCodes.S)
    ? PendingIntentFlags.CancelCurrent | PendingIntentFlags.Immutable
    : PendingIntentFlags.CancelCurrent;

// ❌ Wrong — crashes on Android 12+
var pendingIntentFlags = PendingIntentFlags.CancelCurrent;

iOS / Mac Catalyst

Issue Fix
No notification prompt appears Permission already denied — user must re-enable in Settings
Foreground notifications don't show Must implement UNUserNotificationCenterDelegate and set Current.Delegate
Notification shows Alert not Banner Use UNNotificationPresentationOptions.Banner on iOS 14+
// ✅ iOS 14+ — use Banner
completionHandler(OperatingSystem.IsIOSVersionAtLeast(14)
    ? UNNotificationPresentationOptions.Banner
    : UNNotificationPresentationOptions.Alert);

// ❌ Always using Alert — deprecated on iOS 14+
completionHandler(UNNotificationPresentationOptions.Alert);

Windows

⚠️ Windows App SDK supports toast notifications but scheduled notifications are not yet supported. Immediate notifications work.

DI registration — platform-specific only

// ✅ Must use #if guards — there's no cross-platform implementation
#if ANDROID
    builder.Services.AddTransient<INotificationManagerService,
        Platforms.Android.NotificationManagerService>();
#elif IOS
    builder.Services.AddTransient<INotificationManagerService,
        Platforms.iOS.NotificationManagerService>();
#elif MACCATALYST
    builder.Services.AddTransient<INotificationManagerService,
        Platforms.MacCatalyst.NotificationManagerService>();
#endif

Common anti-patterns

// ❌ Sending without checking permission — silent failure on API 33+
notificationManager.SendNotification("Title", "Body");

// ✅ Request permission first
#if ANDROID
var status = await Permissions.RequestAsync<Platforms.Android.NotificationPermission>();
if (status != PermissionStatus.Granted) return;
#endif

// ❌ Updating UI directly from notification callback — cross-thread exception
notificationManager.NotificationReceived += (s, e) =>
    myLabel.Text = ((NotificationEventArgs)e).Title;

// ✅ Marshal to UI thread
notificationManager.NotificationReceived += (s, e) =>
    MainThread.BeginInvokeOnMainThread(() =>
        myLabel.Text = ((NotificationEventArgs)e).Title);

Decision framework

Need Approach
Immediate notification SendNotification(title, message) with null notifyTime
Scheduled reminder SendNotification(title, message, DateTime.Now.AddMinutes(30))
Persist across reboot (Android) Add BOOT_COMPLETED receiver to re-schedule alarms
Rich notifications (images, actions) Extend platform implementations with native APIs
Push notifications from server Use a different pattern entirely (FCM/APNs)

Quick checklist

  • [ ] Cross-platform INotificationManagerService interface defined
  • [ ] Android: notification channel created (API 26+)
  • [ ] Android: POST_NOTIFICATIONS permission in manifest + runtime request (API 33+)
  • [ ] Android: PendingIntentFlags.Immutable used (API 31+)
  • [ ] Android: MainActivity has LaunchMode.SingleTop and handles OnNewIntent
  • [ ] iOS: UNUserNotificationCenterDelegate set for foreground display
  • [ ] iOS: Banner used instead of Alert on iOS 14+
  • [ ] DI registration uses #if platform guards
  • [ ] UI updates from notification callbacks use MainThread.BeginInvokeOnMainThread

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 .NET MAUI 本地通知的完整跨平台解决方案
  • 明确区分适用与不适用场景,避免误用
  • 覆盖 Android/iOS/Mac Catalyst 三大平台的关键实现细节
Trigger Precision95/100

Highlights

  • USE FOR 和 DO NOT USE FOR 关键词清晰完整
  • 覆盖多种通知相关场景变体,边界明确
Structure and Standards75/100

Areas to improve

  • 引用文件缺失 Reported severity: Major

    SKILL.md 引用了 references/local-notifications-api.md 文件但未传入

    Recommendation: 请补充 references/local-notifications-api.md 文件,或移除引用

Highlights

  • 文档结构清晰,分平台详细说明问题与解决方案
  • 包含决策框架和检查清单,便于开发者快速验证
Execution Reliability65/100

Areas to improve

  • 引用文件内容不完整 Reported severity: Major

    核心实现代码依赖未传入的 references/local-notifications-api.md 文件

    Recommendation: 请确保所有被引用的实现文件完整上传

Highlights

  • 提供了平台特定的关键代码片段和最佳实践
  • 覆盖了主要异常场景(权限、线程安全、API版本兼容)
Evidence Verifiability (mean of the first four)80/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.