> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# PushService (interface)

[PushService](/api-reference/websdk5/pushservice/overview)

Interface for registering push tokens and handling push notifications for incoming calls.

**Since:** 5.2.0

**Methods**

* [handlePushNotification](/api-reference/websdk5/pushservice/pushservice#handlepushnotification)
* [registerPushToken](/api-reference/websdk5/pushservice/pushservice#registerpushtoken)
* [unregisterPushToken](/api-reference/websdk5/pushservice/pushservice#unregisterpushtoken)

## Methods

### handlePushNotification

`handlePushNotification(notificationData: `[`UnknownObject`](/api-reference/websdk5/core/unknownobject)`): Promise<void>`

Reports a received push notification back to the Voximplant Cloud.

The notification data is sent as a JSON string within the notification data message,
available at the
`messagePayload.data.voximplant`
path. It should be parsed via
`JSON.parse()`

before being passed to this method.

If the user is not yet logged in, the request is queued and the data is sent automatically
once the login process completes.

Returns a promise that resolves after the notification data is successfully sent to the cloud.

**Since:** 5.2.0

**Parameters**

| Parameter          | Type                                                         | Requirement | Description                                            |
| ------------------ | ------------------------------------------------------------ | ----------- | ------------------------------------------------------ |
| `notificationData` | [`UnknownObject`](/api-reference/websdk5/core/unknownobject) | Required    | Voximplant-specific payload from the push notification |

**Returns:** Promise\<void>

### registerPushToken

`registerPushToken(options: `[`PushTokenOptions`](/api-reference/websdk5/pushservice/pushtokenoptions)`): Promise<void>`

Registers a push token for the logged in user in the Voximplant cloud.

If the user is not yet logged in, the request is queued and sent automatically
once the login process completes.

Returns a promise that resolves when the token is successfully registered.

**Since:** 5.2.0

**Parameters**

| Parameter | Type                                                                      | Requirement | Description                     |
| --------- | ------------------------------------------------------------------------- | ----------- | ------------------------------- |
| `options` | [`PushTokenOptions`](/api-reference/websdk5/pushservice/pushtokenoptions) | Required    | Push token registration options |

**Returns:** Promise\<void>

**Throws**

* [PushServiceInvalidTokenError](/api-reference/websdk5/pushservice/errors/pushserviceinvalidtokenerror) – if the push token is empty or consists entirely of whitespace characters
* [PushServiceConnectionClosedError](/api-reference/websdk5/pushservice/errors/pushserviceconnectionclosederror) – if the connection to the Voximplant cloud is closed
  before the request can complete
* [PushServiceTimeoutError](/api-reference/websdk5/pushservice/errors/pushservicetimeouterror) – if no response is received within the timeout period
  after the request is sent to the Voximplant cloud
* [PushServiceCancelledError](/api-reference/websdk5/pushservice/errors/pushservicecancellederror) – if the pending request is canceled, typically when multiple
  registration or unregistration requests are made rapidly one after another
* [PushServiceInternalError](/api-reference/websdk5/pushservice/errors/pushserviceinternalerror) – if an internal error occurs

### unregisterPushToken

`unregisterPushToken(options: `[`PushTokenOptions`](/api-reference/websdk5/pushservice/pushtokenoptions)`): Promise<void>`

Unregisters a push token for the logged in user in the Voximplant cloud.

If the user is not yet logged in, the request is queued and sent automatically
once the login process completes.

Returns a promise that resolves when the token is successfully unregistered.

**Since:** 5.2.0

**Parameters**

| Parameter | Type                                                                      | Requirement | Description                       |
| --------- | ------------------------------------------------------------------------- | ----------- | --------------------------------- |
| `options` | [`PushTokenOptions`](/api-reference/websdk5/pushservice/pushtokenoptions) | Required    | Push token unregistration options |

**Returns:** Promise\<void>

**Throws**

* [PushServiceInvalidTokenError](/api-reference/websdk5/pushservice/errors/pushserviceinvalidtokenerror) – if the push token is empty or consists entirely of whitespace characters
* [PushServiceConnectionClosedError](/api-reference/websdk5/pushservice/errors/pushserviceconnectionclosederror) – if the connection to the Voximplant cloud is closed
  before the request can complete
* [PushServiceTimeoutError](/api-reference/websdk5/pushservice/errors/pushservicetimeouterror) – if no response is received within the timeout period
  after the request is sent to the Voximplant cloud
* [PushServiceCancelledError](/api-reference/websdk5/pushservice/errors/pushservicecancellederror) – if the pending request is canceled, typically when multiple
  registration or unregistration requests are made rapidly one after another
* [PushServiceInternalError](/api-reference/websdk5/pushservice/errors/pushserviceinternalerror) – if an internal error occurs