用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill maui-local-notifications命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | maui-local-notifications |
| description | > Use when this capability is needed. |
INotificationManagerService interface and event argsSee references/local-notifications-api.md for full implementation code.
| 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;
| 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 App SDK supports toast notifications but scheduled notifications are not yet supported. Immediate notifications work.
// ✅ 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
// ❌ 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);
| 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) |
INotificationManagerService interface definedPOST_NOTIFICATIONS permission in manifest + runtime request (API 33+)PendingIntentFlags.Immutable used (API 31+)MainActivity has LaunchMode.SingleTop and handles OnNewIntentUNUserNotificationCenterDelegate set for foreground displayBanner used instead of Alert on iOS 14+#if platform guardsMainThread.BeginInvokeOnMainThreadConverted and distributed by TomeVault — claim your Tome and manage your conversions.