fix
This commit is contained in:
parent
6327d56749
commit
7cc7b7d099
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -42,13 +42,6 @@ const w = window as unknown as {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initExtNotif = async (vi: VG, prasi_ext: PrasiExt) => {
|
export const initExtNotif = async (vi: VG, prasi_ext: PrasiExt) => {
|
||||||
w.notif = {
|
|
||||||
async send() {},
|
|
||||||
register() {},
|
|
||||||
onReceive(notif) {},
|
|
||||||
onTap(notif) {},
|
|
||||||
};
|
|
||||||
|
|
||||||
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) {
|
||||||
|
|
@ -118,6 +111,12 @@ 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() {},
|
||||||
|
register() {},
|
||||||
|
onReceive(notif) {},
|
||||||
|
onTap(notif) {},
|
||||||
|
};
|
||||||
w.notif.register = async (user_id: any) => {
|
w.notif.register = async (user_id: any) => {
|
||||||
await waitUntil(() => prasi_ext.notif?.token);
|
await waitUntil(() => prasi_ext.notif?.token);
|
||||||
if (vi && vi.site.api && prasi_ext.notif?.token) {
|
if (vi && vi.site.api && prasi_ext.notif?.token) {
|
||||||
|
|
@ -130,18 +129,20 @@ export const initExtNotif = async (vi: VG, prasi_ext: PrasiExt) => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
w.notif.send = async (data: NOTIF_ARG) => {
|
if (w.notif) {
|
||||||
if (vi && vi.site.api) {
|
w.notif.send = async (data: NOTIF_ARG) => {
|
||||||
return await vi.site.api._notif("send", {
|
if (vi && vi.site.api) {
|
||||||
type: "send",
|
return await vi.site.api._notif("send", {
|
||||||
id:
|
type: "send",
|
||||||
typeof data.user_id === "string"
|
id:
|
||||||
? data.user_id
|
typeof data.user_id === "string"
|
||||||
: data.user_id.toString(),
|
? data.user_id
|
||||||
body: data.body,
|
: data.user_id.toString(),
|
||||||
title: data.title,
|
body: data.body,
|
||||||
data: data.data,
|
title: data.title,
|
||||||
});
|
data: data.data,
|
||||||
}
|
});
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue