5

i want to create a google chrome extension that notify user when a new record in the mysql DB is added ! there is someone who can help me ? Thank you.

2 Answers2

14

Please refer to this page.

Use the chrome.notifications API to create rich notifications using templates and show these notifications to users in the system tray.

https://developer.chrome.com/docs/extensions/reference/notifications/

chrome.notifications.create(
  "name-for-notification",
  {
    type: "basic",
    iconUrl: "image.jpeg",
    title: "This is a notification",
    message: "hello there!",
  },
  function () {}
);

You can create notification like this.
EDIT: Please do not forget to add the "notifications" permission in the manifest.json file

Tiago Rangel
  • 1,159
  • 15
  • 29
crzyonez777
  • 1,789
  • 4
  • 18
  • 27
0

you can also use the notification from the window object like that

and -- very importan! : do not forget to add the "notifications" permission in the manifest.json

    function init() {
    
    
    if (!window.Notification) {

        alert('notSupport');
    } else if (Notification.permission === "granted") {
        console.log('grant notification')
        installNotification = createInstallNotification();

    } else if (Notification.permission !== 'denied') {
        console.log('denied init notes')
        Notification.requestPermission(function (permission) {
            console.log('ask init notes',permission)
            if (permission === 'granted') {

                installNotification = createInstallNotification();

            }else{
                alert('doNotDenied')
            }
        })

    }
    // end init
}
function createInstallNotification() {
    return new Notification('installSuccess', {
        body: 'text body'
        , tag: 'uniqe-numer-here'
    })
}
yehonatan yehezkel
  • 1,116
  • 18
  • 28