forked from jsnbuchanan/crowd-funder-for-time-pwa
don't show non-message to user; fix API server setting; misc doc & task stuff
This commit is contained in:
@@ -5,7 +5,7 @@ importScripts(
|
||||
);
|
||||
|
||||
self.addEventListener("install", (event) => {
|
||||
console.error(event);
|
||||
console.error("Adding event listener for:", event);
|
||||
importScripts(
|
||||
"safari-notifications.js",
|
||||
"nacl.js",
|
||||
@@ -23,16 +23,20 @@ self.addEventListener("push", function (event) {
|
||||
payload = JSON.parse(event.data.text());
|
||||
}
|
||||
const message = await self.getNotificationCount();
|
||||
console.error(message);
|
||||
const title = payload ? payload.title : "Custom Title";
|
||||
const options = {
|
||||
body: message,
|
||||
icon: payload ? payload.icon : "icon.png",
|
||||
badge: payload ? payload.badge : "badge.png",
|
||||
};
|
||||
await self.registration.showNotification(title, options);
|
||||
if (message) {
|
||||
console.log("Will notify user:", message);
|
||||
const title = payload ? payload.title : "Custom Title";
|
||||
const options = {
|
||||
body: message,
|
||||
icon: payload ? payload.icon : "icon.png",
|
||||
badge: payload ? payload.badge : "badge.png",
|
||||
};
|
||||
await self.registration.showNotification(title, options);
|
||||
} else {
|
||||
console.log("No notification message, so will not tell the user.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error in processing the push event:", error);
|
||||
console.error("Error processing the push event:", error);
|
||||
}
|
||||
})(),
|
||||
);
|
||||
@@ -51,7 +55,7 @@ self.addEventListener("activate", (event) => {
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
console.log(event.request);
|
||||
console.log("Got fetch event", event.request);
|
||||
});
|
||||
|
||||
self.addEventListener("error", (event) => {
|
||||
|
||||
Reference in New Issue
Block a user