# Notifications

Need `notifications` permission in manifest.json

Can change icon on bar with browser\_action

```javascript
  const notif = await browser.notifications.create({
    type: "basic",
    title: "HI Mother",
    message: "Folder fff",
    iconUrl: "../img/logo.png"
  });
```

### Listening for Click

```javascript
async function handleC(clickedNotif) {
  if (clickedNotif === notif_id) {
    debug("THEY CLICKED ON MY BABY");
browser.notifications.onClicked.removeListener(handleC);
    await browser.notifications.clear(notif_id); 
    //close after click
  }
}
browser.notifications.onClicked.addListener(handleC);
```

## Old Way

This has better error messages and will tell you what is missing

All these fields are **required** for notification create

```javascript
chrome.notifications.create(
  {
    type: "basic",
    title: "HI",
    message: `Folder`,
    iconUrl: "../img/logo.png"
  },
  notif_id => {
    console.log("Created", notif_id);
  }
);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openai.gitbook.io/code-cheatsheets/js/all/chrome_plugins/notifications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
