import { registerActionTypes, createChannel, sendNotification, onAction } from '@tauri-apps/plugin-notification';
await registerActionTypes([
{
id: 's',
actions: [
{
id: 's1',
title: '11',
},
],
},
]);
// 创建 channel
await createChannel({
id: 'messages',
name: 'Messages',
description: 'Test message channel',
importance: 4,
});
onAction(() => {
notify({
title: 'XXX 333',
body: '33333',
})
})
sendNotification({
title: 'actions',
body: '测试11',
actionTypeId: 's',
channelId: 'messages'
})
src-tauri/capabilities/default.json
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": [
"main"
],
"permissions": [
"core:default",
"opener:default",
"notification:default",
"notification:allow-request-permission",
"notification:allow-notify",
"notification:allow-register-action-types",
"notification:allow-register-listener"
]
}
Two bugs were found
- In system notifications, the action button does not display text
- when i use
onAction function, console happened
2025-09-01 16:37:07.891 16598-16598 Tauri/Console
com.sc.app
E File: http://tauri.localhost/src/App.vue - Line 155 - Msg: Uncaught (in promise) notification.registerListener not allowed. Command not found

src-tauri/capabilities/default.json
{ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "default", "description": "Capability for the main window", "windows": [ "main" ], "permissions": [ "core:default", "opener:default", "notification:default", "notification:allow-request-permission", "notification:allow-notify", "notification:allow-register-action-types", "notification:allow-register-listener" ] }Two bugs were found
onActionfunction, console happened