# How to allow users to manage their push preferences from my website?

By default, users can manage their push preferences from their browser settings on desktop and mobile ([see here how to disable push notifications](https://doc.batch.com/guides-and-best-practices/profiles/how-to-disable-web-push-notifications)).

Instead of making your users dive into their browser settings, you can give them the option to disable/enable push notifications directly from your website using a toggle switch.

<figure><img src="https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2FJQw9OsQEpklNjTzOOOck%2Ftechnical-guides_toggle-deactive-notif_02052025.png?alt=media&#x26;token=2a5a4a42-ed8c-458f-9266-7a38384cf880" alt="Example of a notifications switch button on a website" width="563"><figcaption></figcaption></figure>

The following steps will help you set up this button on your website.

{% stepper %}
{% step %}

## Getting users' opt-in status <a href="#id-1-getting-the-opt-in-status-of-the-user" id="id-1-getting-the-opt-in-status-of-the-user"></a>

First, you need to obtain the users' opt-in status to update the button's status.\
You can use this method :

```javascript
batchSDK(function (api) {api.isSubscribed()});
```

{% endstep %}

{% step %}

## Update the opt-in status <a href="#id-2-update-the-optin-status" id="id-2-update-the-optin-status"></a>

<figure><img src="https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2FopoZQsC479DKO4ELubN2%2Ftechnical-guides_toggle-button_02052025.gif?alt=media&#x26;token=cec57332-a101-4ecb-9652-3bd1738c9508" alt="Gif showing a toogle button switching from off to on"><figcaption></figcaption></figure>

Depending on the action your users perform, you will need to call different methods when users click your toggle switch.

**Turning off** push notifications:

```javascript
batchSDK(function(api) {api.unsubscribe();});
```

**Turning on** push notifications:

```javascript
batchSDK(function(api) {api.subscribe();});
```

Here is an example of how you could implement a toggle switch using these methods:

```html
<input type="checkbox" id="toggle" onclick="validate();" />
```

```html
<script type="text/javascript">
      function validate() {
        if (document.getElementById("toggle").checked) {
          batchSDK(function(api) {api.subscribe();});
        } else {
          batchSDK(function(api) {api.unsubscribe();});
        }
      }
    </script>
```

{% endstep %}
{% endstepper %}

{% hint style="danger" %}
Keep in mind that notifications management may happen at two different levels:

* At the **SDK level**
* In users' **browser settings**: on this level, you cannot control notifications with a toggle switch button as described above.
  {% endhint %}

{% hint style="warning" %}
You will find more details in the [Batch Web API Reference](https://doc.batch.com/web-api-reference/).
{% endhint %}
