跳转至正文

Android 配置

GitHub

该插件会将 POST_NOTIFICATIONS 到你的应用中(Android 13+ 上必需)。使用以下方式请求运行时权限: requestPermission(). 最低 SDK: 24.

使用以下方式创建通知渠道: createChannel 然后再发送。使用 channelId 在每条通知上。

对于 精确闹钟, 全屏意图,以及 前台服务 通知,请在 app manifest 中添加 opt-in 权限和前台服务。在项目根目录下运行:

终端窗口
bun ./node_modules/@capgo/capacitor-rich-notifications/scripts/apply-notification-permissions.mjs --project .

该辅助工具会添加 SCHEDULE_EXACT_ALARM, USE_FULL_SCREEN_INTENT, FOREGROUND_SERVICE, FOREGROUND_SERVICE_SPECIAL_USE,并声明 app.capgo.richnotifications.RichForegroundService 带 foregroundServiceType="specialUse".

使用 foregroundService: true 和 fullScreen: true 仅在具备这些权限时生效。