Notify users

Post messages to a user's system tray using the extensions Notifications API. Start by declaring the "notifications" permission in the manifest.json.

{  "name": "Drink Water Event Popup", ...  "permissions": [  "notifications",  ], ... } 

Once the permission is declared, display a notification by calling notifications.create(). The following example is taken from the Drink water event popup sample. It uses an alarm to set a reminder to drink a glass of water. This code shows the triggering of the alarm. Follow the previous link to explore how this is set up.

chrome.alarms.onAlarm.addListener(() => {  chrome.action.setBadgeText({ text: '' });  chrome.notifications.create({  type: 'basic',  iconUrl: 'stay_hydrated.png',  title: 'Time to Hydrate',  message: "Everyday I'm Guzzlin'!",  buttons: [{ title: 'Keep it Flowing.' }],  priority: 0  }); }); 

This code creates a notification on macOS like the following.

A notification on macOS
A notification on macOS.