Posting pesan ke baki sistem pengguna menggunakan ekstensi Notifications API. Mulailah dengan mendeklarasikan izin "notifications" di manifest.json.

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

Setelah izin dideklarasikan, tampilkan notifikasi dengan memanggil notifications.create(). Contoh berikut diambil dari contoh Pop-up peristiwa air minum. Mode ini menggunakan alarm untuk menyetel pengingat minum segelas air. Kode ini menunjukkan pemicu alarm. Ikuti link sebelumnya untuk mempelajari cara menyiapkannya.

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
  });
});

Kode ini membuat notifikasi di macOS seperti berikut.

Notifikasi di macOS
Notifikasi di macOS.