mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-26 15:32:11 -05:00
Merge pull request #177 from yannickfunk/push-notifications
Parse Web Push notifications
This commit is contained in:
commit
5abe90583a
1 changed files with 12 additions and 3 deletions
15
src/sw.ts
15
src/sw.ts
|
@ -11,10 +11,19 @@ precacheAndRoute(self.__WB_MANIFEST);
|
||||||
|
|
||||||
self.addEventListener("push", (event) => {
|
self.addEventListener("push", (event) => {
|
||||||
async function process() {
|
async function process() {
|
||||||
if (event.data === null) return;
|
if (event.data) {
|
||||||
// Need to write notification generator on server.
|
const data = event.data.json();
|
||||||
}
|
await self.registration.showNotification(data.author, {
|
||||||
|
icon: data.icon,
|
||||||
|
image: data.image,
|
||||||
|
body: data.body,
|
||||||
|
timestamp: data.timestamp,
|
||||||
|
tag: data.tag,
|
||||||
|
badge: "https://app.revolt.chat/assets/icons/android-chrome-512x512.png"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
event.waitUntil(process());
|
event.waitUntil(process());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue