> This page is for Browser SDK, version v3.
> For other versions, use one of these documentation indexes:
> - v4 (default): https://signalwire.com/docs/browser-sdk/v4/llms.txt
> - v3: https://signalwire.com/docs/browser-sdk/v3/llms.txt
> - v2: https://signalwire.com/docs/browser-sdk/v2/llms.txt

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# Notifications

If you've initialized the SignalWire Client with a [subscriber](/docs/platform/subscribers) token, you can opt into receiving notifications
whenever that subscriber address is called using WebSockets.

The WebSocket notifications are delivered over the WebSocket connection **while your application is active**, and you have
called the `online()` method to opt into receiving them.

To receive incoming call notifications over WebSocket, call `client.online()` with an `incomingCallHandlers` object:

```javascript
client.online({
  incomingCallHandlers: {
    websocket: (callInvite) => {
      const callerName = callInvite.invite.details?.caller_id_name;
      const callerNumber = callInvite.invite.details?.caller_id_number;
      
      // to accept:
      const roomSession = await callInvite.invite.accept(params);
      
      // to reject:
      callInvite.invite.reject();
    },
  },
});
```

When an incoming call arrives, the `websocket` handler receives a `callInvite` object containing:

* `callInvite.invite.details` - call and caller information `IncomingInvite`
* `callInvite.invite.accept()` - accepts the call and returns a `CallSession`
* `callInvite.invite.reject()` - rejects the call