확장 프로그램 Notifications API를 사용하여 사용자의 작업 표시줄에 메시지를 게시합니다. 먼저 manifest.json에서 "notifications" 권한을 선언합니다.

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

권한이 선언되면 notifications.create()를 호출하여 알림을 표시합니다. 다음 예는 물 마시기 이벤트 팝업 샘플에서 가져온 것입니다. 알람을 사용하여 물을 마시라는 알림을 설정합니다. 이 코드는 알람 트리거를 보여줍니다. 이전 링크를 따라 설정 방법을 알아보세요.

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

이 코드는 다음과 같이 macOS에서 알림을 만듭니다.

macOS의 알림
macOS의 알림