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.

3

2 Answers 2

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

3
  • thank you but i'm asking how to communicate with my mysql DB and count the number of entries for example (this number will appear using the chrome notification api). Sep 14, 2013 at 13:19
  • I guess you have to first check if chrome notifications are turned on or not.
    – PG1
    Jun 21, 2014 at 7:51
  • 1
    very importan! : do not forget to add the "notifications" permission in the manifest.json Sep 9, 2020 at 14:01
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'
    })
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.