mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 20:00:17 +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
c0724d70f5
commit
c5bffb68f1
3 changed files with 15 additions and 5 deletions
|
|
@ -2,7 +2,9 @@ import {openMobileFileById} from "../editor";
|
|||
import {
|
||||
processSync,
|
||||
progressLoading,
|
||||
reloadSync, setDefRefCount, setRefDynamicText,
|
||||
reloadSync,
|
||||
setDefRefCount,
|
||||
setRefDynamicText,
|
||||
transactionError
|
||||
} from "../../dialog/processSystem";
|
||||
import {App} from "../../index";
|
||||
|
|
@ -20,7 +22,7 @@ export const onMessage = (app: App, data: IWebSocketData) => {
|
|||
switch (data.cmd) {
|
||||
case "sendDeviceNotification":
|
||||
if (window.JSAndroid.sendNotification) {
|
||||
window.JSAndroid.sendNotification(data.data.title, data.data.body);
|
||||
window.JSAndroid.sendNotification(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): void
|
||||
sendNotification(title: string, body: string, delayInSeconds: number): void
|
||||
};
|
||||
JSHarmony: {
|
||||
showKeyboard(): void
|
||||
|
|
|
|||
|
|
@ -58,9 +58,17 @@ func sendDeviceNotification(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
var delayInSeconds int
|
||||
if nil != arg["delayInSeconds"] {
|
||||
delayInSeconds = int(arg["delayInSeconds"].(float64))
|
||||
} else {
|
||||
delayInSeconds = 1
|
||||
}
|
||||
|
||||
util.BroadcastByType("main", "sendDeviceNotification", 0, "", map[string]interface{}{
|
||||
"title": title,
|
||||
"body": body,
|
||||
"title": title,
|
||||
"body": body,
|
||||
"delayInSeconds": delayInSeconds,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue