This commit is contained in:
Rizky 2024-05-15 15:23:41 +07:00
parent 33fc9bf1b4
commit 871cb60022
2 changed files with 26 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,6 @@ export const initExtNotif = async (vi: VG, prasi_ext: PrasiExt) => {
if (window.parent) { if (window.parent) {
window.addEventListener("message", async ({ data: raw }) => { window.addEventListener("message", async ({ data: raw }) => {
if (typeof raw === "object" && raw.mobile) { if (typeof raw === "object" && raw.mobile) {
console.log(raw);
const data = raw as unknown as const data = raw as unknown as
| { | {
type: "notification-token"; type: "notification-token";
@ -144,4 +143,21 @@ export const initExtNotif = async (vi: VG, prasi_ext: PrasiExt) => {
window.parent.postMessage({ mobile: true, type: "ready" }, "*"); window.parent.postMessage({ mobile: true, type: "ready" }, "*");
} }
w.notif = {
async send(data: NOTIF_ARG) {
if (vi && vi.site.api) {
return await vi.site.api._notif("send", {
type: "send",
id:
typeof data.user_id === "string"
? data.user_id
: data.user_id.toString(),
body: data.body,
title: data.title,
data: data.data,
});
}
},
} as any;
}; };