maui-push-notifications
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "maui-push-notifications":https://skillpi.com/zh/skills/deepskill-06c236df16f2e620efda8fa31b14899373fdf16c8a3fb3c9f3faae5b743f8415。安装前核对上游来源和版本:https://github.com/davidortinau/maui-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 .NET MAUI 应用提供端到端的推送通知指南。覆盖 Firebase 云消息传递(Android)、Apple 推送通知服务(iOS)、使用 Azure 通知中心 作为跨平台代理、ASP.NET Core 后端 API 实现,以及各平台 MAUI 客户端的集成与设备注册与通知令牌处理。适用场景包括推送通知、FCM、APNS、Azure 通知中心、设备注册、远程通知与发送推送通知。非适用:本地/计划通知(请使用 maui-local-notifications)、通用权限处理(请使用 maui-permissions)、无通知的后台任务(请使用 maui-app-lifecycle)。
介绍来源: third_party · davidortinau · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: maui-push-notifications
description: >
End-to-end guide for adding push notifications to .NET MAUI apps.
Covers Firebase Cloud Messaging (Android), Apple Push Notification Service (iOS),
Azure Notification Hubs as the cross-platform broker, an ASP.NET Core backend API,
and the MAUI client wiring on every platform.
USE FOR: "push notification", "FCM", "APNS", "Firebase Cloud Messaging",
"Azure Notification Hubs", "device registration", "remote notification",
"send push notification", "notification token".
DO NOT USE FOR: local/scheduled notifications (use maui-local-notifications),
general permission handling (use maui-permissions), or background tasks without notifications (use maui-app-lifecycle).Push Notifications — Gotchas & Best Practices
Troubleshooting Table
| Issue | Cause | Fix |
|---|---|---|
| Token changes every debug run (Android) | Debug builds regenerate Firebase tokens | Always re-register in OnNewToken |
HttpClient requests fail silently |
BaseAddress missing trailing / |
Ensure endpoint ends with / |
| iOS push won't arrive on simulator | Simulators don't support APNS | Use a physical iOS device |
| No notifications on Android 13+ | POST_NOTIFICATIONS required (API 33+) |
Call RequestPermissions in OnCreate |
| Notification channel missing (API 26+) | Android requires explicit channel creation | Create channel before sending |
SendNotificationAsync throws for >20 tags |
Azure NH tag expression limit | Batch tags in groups of 20 |
422 on device registration |
Platform string mismatch | Use "fcmv1" (not "gcm") and "apns" |
Token empty at RegisterAsync |
Race condition on cold start | Guard with IsNullOrWhiteSpace check |
Critical Gotchas
⚠️ BaseAddress trailing slash
HttpClient.BaseAddress must end with /. Without it, relative URI resolution silently breaks.
// ❌ Relative URIs resolve incorrectly
_http = new HttpClient { BaseAddress = new Uri("https://example.com") };
// ✅ Trailing slash required
_http = new HttpClient { BaseAddress = new Uri("https://example.com/") };
⚠️ Android: Always re-register on token refresh
Firebase tokens regenerate frequently in debug builds. If you skip OnNewToken, the backend holds a stale token and pushes silently fail.
// ❌ Only registering once at startup
// (token may change later without re-registration)
// ✅ Always re-register in OnNewToken
public override void OnNewToken(string token)
{
var svc = IPlatformApplication.Current?.Services.GetService<IPushNotificationService>();
if (svc is null) return;
svc.Token = token;
_ = svc.RegisterAsync();
}
⚠️ Android 13+ requires POST_NOTIFICATIONS permission
Without explicitly requesting POST_NOTIFICATIONS on API 33+, notifications are silently dropped.
⚠️ Azure NH tag expression limit: 20 tags
SendNotificationAsync throws if a tag expression references more than 20 tags. Batch into chunks:
// ✅ Batch tags to stay under the limit
var batches = request.Tags.Chunk(20);
foreach (var batch in batches)
{
var tagExpr = string.Join(" || ", batch);
await _hub.SendFcmV1NativeNotificationAsync(payload, tagExpr, ct);
}
⚠️ Use "fcmv1" not "gcm"
The legacy "gcm" platform string causes 422 errors on device registration. Always use "fcmv1" for Android and "apns" for iOS.
⚠️ iOS simulators cannot receive push notifications
APNS only works on physical iOS devices. Simulators silently ignore push registrations.
Platform Checklist
Android
- [ ]
google-services.jsoninPlatforms/Android/with<GoogleServicesJson>in.csproj - [ ]
Xamarin.Firebase.MessagingNuGet package added (Android-only condition) - [ ]
POST_NOTIFICATIONSpermission requested on API 33+ - [ ] Notification channel created before first notification (API 26+)
- [ ]
OnNewTokenalways callsRegisterAsync - [ ]
FirebaseMessagingServiceregistered in manifest withMESSAGING_EVENTintent filter
iOS
- [ ] Push Notifications capability enabled in Apple Developer portal
- [ ] APNs key (
.p8) uploaded to Azure Notification Hub - [ ]
Entitlements.plistwithaps-environmentset todevelopmentorproduction - [ ]
CodesignEntitlementsset in.csproj - [ ]
RegisterForRemoteNotificationscalled on main thread after authorization grant - [ ] Device token converted to lowercase hex string (no dashes)
Backend
- [ ] Azure Notification Hub configured with FCM V1 JSON and APNS key
- [ ]
BaseAddressends with trailing/ - [ ] Tag expressions batched in groups of ≤20
- [ ] Platform strings:
"fcmv1"and"apns"(not legacy values)
Architecture Overview
MAUI app → ASP.NET Core backend → Azure Notification Hub → FCM / APNS → device
See references/push-notifications-api.md for full implementation templates.
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- .NET MAUI 推送通知端到端解决方案,覆盖 Android/iOS/后端全栈集成
- 提供详尽的 Troubleshooting Table 和 Platform Checklist,显著降低开发者踩坑风险
亮点
- 触发词完整且边界清晰,明确排除本地通知、权限处理等无关场景
- USE FOR/DO NOT USE FOR 结构有效防止误触发
待提升项
-
description写错位置 原报告严重程度:轻微
description 内容写在 frontmatter 内 skill_body 中,未在顶层单独字段
改进建议:建议将 description 移至顶层元数据字段,保持与平台规范一致
亮点
- 文档结构清晰,含故障排查表、关键陷阱、平台检查清单和架构图
- 代码示例具体,frontmatter 完整,单文件长度合理
待提升项
-
引用文件缺失 原报告严重程度:重大
SKILL.md 引用了 references/push-notifications-api.md 文件但未传入
改进建议:请补充 references/push-notifications-api.md 文件或移除引用链接
亮点
- 工具来源明确(Firebase、Azure、.NET MAUI),参数正确(fcmv1/apns)
- 覆盖主要异常场景(token刷新、权限请求、tag限制、BaseAddress斜杠)并提供修复方案
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- example.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。