Created
May 4, 2024 11:03
-
-
Save masckmaster2007/78cb6238109fa05a8b831315edf7c8f3 to your computer and use it in GitHub Desktop.
Notification API Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notification.requestPermission().then(permission => { | |
if(permission !== "granted") return; // User refused notifications | |
const image = "https://dgdps.ix.tc/gd.png"; // Logo for notification | |
const target = "https://dgdps.us.to"; // Website to open if user clicks on it | |
const title = "Test"; // Notification title | |
const msg = "Salut"; // Notification body message | |
const notify = new Notification(title, { body: msg, icon: image }); // Builds notification | |
notify.onclick = function () { | |
window.open(target); // Open site | |
notify.close(); // Closes notification (x) | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment