🎨 Support sending notifications on Android https://github.com/siyuan-note/siyuan/issues/17114

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-03-05 10:13:57 +08:00
parent 487e27cb00
commit 51295adb4b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 10 additions and 2 deletions

View file

@ -26,7 +26,7 @@ export const onMessage = (app: App, data: IWebSocketData) => {
break;
case "sendDeviceNotification":
if (window.JSAndroid.sendNotification) {
window.JSAndroid.sendNotification(data.data.title, data.data.body, data.data.delayInSeconds);
window.JSAndroid.sendNotification(data.data.channel, data.data.title, data.data.body, data.data.delayInSeconds);
}
break;
case "backgroundtask":

View file

@ -255,7 +255,7 @@ interface Window {
getScreenWidthPx(): number
exit(): void
setWebViewFocusable(enable: boolean): void
sendNotification(title: string, body: string, delayInSeconds: number): void
sendNotification(channel: string, title: string, body: string, delayInSeconds: number): void
};
JSHarmony: {
showKeyboard(): void

View file

@ -40,6 +40,13 @@ func sendDeviceNotification(c *gin.Context) {
return
}
var channel string
if nil != arg["channel"] {
channel = strings.TrimSpace(arg["channel"].(string))
} else {
channel = "SiYuan Notifications"
}
var title string
if nil != arg["title"] {
title = strings.TrimSpace(arg["title"].(string))
@ -66,6 +73,7 @@ func sendDeviceNotification(c *gin.Context) {
}
util.BroadcastByType("main", "sendDeviceNotification", 0, "", map[string]interface{}{
"channel": channel,
"title": title,
"body": body,
"delayInSeconds": delayInSeconds,