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.
Asked
Active
Viewed 2.1k times
5
-
[Chrome supports desktop notifications natively](http://stackoverflow.com/questions/2271156/chrome-desktop-notification-example). – Dan Dascalescu Feb 11 '14 at 05:47
-
Did you find it working? Can you share your source code? – Anupal Dec 19 '15 at 10:56
-
Well. You could use a php script to communicate to the mySQL DB and make an ajax call to the php script from your chrome extension – Jay Ghosh Dec 29 '16 at 18:23
2 Answers
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
-
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). – Mohamed Tahar Zwawa Sep 14 '13 at 13:19
-
I guess you have to first check if chrome notifications are turned on or not. – PG1 Jun 21 '14 at 07:51
-
1very importan! : do not forget to add the "notifications" permission in the manifest.json – yehonatan yehezkel Sep 09 '20 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'
})
}

yehonatan yehezkel
- 1,116
- 18
- 28