> For the complete documentation index, see [llms.txt](https://docs.klai.studio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.klai.studio/engineering-reference-docs/creating-a-pwa/getting-started/sending-push-notifications.md).

# Sending Push Notifications

With PWA support, you can send push notifications to users, allowing your web app to engage with them. To request push notification permissions from users, we have an action that triggers the browser's 'ask for permission' prompt. This can be used at relevant and convenient points throughout your web app.

The example below shows how we could trigger the permission prompt from a button on a page.

```json
{
    "actions": [{
        "action": "pwaPromptPushPermission",
        "options": {
            "idUser_calc": "window.vueapp.$store.state.auth.user.id"
        }
    }],
    "buttonClasses": "btn btn-info bg-blue-400",
    "styleClasses": "col-md-2",
    "text": "Prompt permission for push notifications",
    "type": "button"
}
```

In this example, we set the user ID (BetterForms ID) as a key to target this when sending a push notification. Clicking on the button will display the following prompt.

<figure><img src="/files/71PKiWXQABYDIGkfzYkq" alt=""><figcaption></figcaption></figure>

Once the user clicks on <mark style="color:red;">`Allow`</mark>, the subscription will be saved in the BF cloud database and you will be able to send a push notification to the user using either an action from the frontend or hitting our <mark style="color:red;">`/pushdata/sendnotification`</mark> endpoint, as shown below.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.klai.studio/engineering-reference-docs/creating-a-pwa/getting-started/sending-push-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.
