maui-local-notifications
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "maui-local-notifications":https://skillpi.com/zh/skills/deepskill-e5b0f4fb46d30ca2817d24081ca5f9ea7635b9ad7365208e404f5229839f65cb。安装前核对上游来源和版本:https://github.com/davidortinau/maui-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 .NET MAUI 在 Android、iOS 和 Mac Catalyst 上添加本地通知的指南。包含通知渠道、权限、调度、前台/后台处理以及依赖注入注册,支持 XAML/MVVM、C# Markup 与 MauiReactor 场景。适用场景包括本地通知、计划通知、通知渠道、通知权限、提醒与警报通知以及应用内或前台通知。非适用:来自服务器的推送通知(请使用 maui-push-notifications)、仅权限处理(请使用 maui-permissions)或应用生命周期后台任务(请使用 maui-app-lifecycle)。
介绍来源: third_party · davidortinau · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
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
- Define cross-platform
INotificationManagerServiceinterface and event args - Implement Android notification service (channel, AlarmManager, BroadcastReceiver)
- Implement iOS/Mac Catalyst notification service (UNUserNotificationCenter)
- Register platform implementations via DI
- 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
INotificationManagerServiceinterface defined - [ ] Android: notification channel created (API 26+)
- [ ] Android:
POST_NOTIFICATIONSpermission in manifest + runtime request (API 33+) - [ ] Android:
PendingIntentFlags.Immutableused (API 31+) - [ ] Android:
MainActivityhasLaunchMode.SingleTopand handlesOnNewIntent - [ ] iOS:
UNUserNotificationCenterDelegateset for foreground display - [ ] iOS:
Bannerused instead ofAlerton iOS 14+ - [ ] DI registration uses
#ifplatform guards - [ ] UI updates from notification callbacks use
MainThread.BeginInvokeOnMainThread
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 .NET MAUI 本地通知的完整跨平台解决方案
- 明确区分适用与不适用场景,避免误用
- 覆盖 Android/iOS/Mac Catalyst 三大平台的关键实现细节
亮点
- USE FOR 和 DO NOT USE FOR 关键词清晰完整
- 覆盖多种通知相关场景变体,边界明确
待提升项
-
引用文件缺失 原报告严重程度:重大
SKILL.md 引用了 references/local-notifications-api.md 文件但未传入
改进建议:请补充 references/local-notifications-api.md 文件,或移除引用
亮点
- 文档结构清晰,分平台详细说明问题与解决方案
- 包含决策框架和检查清单,便于开发者快速验证
待提升项
-
引用文件内容不完整 原报告严重程度:重大
核心实现代码依赖未传入的 references/local-notifications-api.md 文件
改进建议:请确保所有被引用的实现文件完整上传
亮点
- 提供了平台特定的关键代码片段和最佳实践
- 覆盖了主要异常场景(权限、线程安全、API版本兼容)
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。