mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-07 21:22:34 +01:00
🎨 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:
parent
487e27cb00
commit
51295adb4b
3 changed files with 10 additions and 2 deletions
|
|
@ -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":
|
||||
|
|
|
|||
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue