# PushResource

Canonical page: https://docs.ovok.com/java-sdk/reference/push-resource

```java
public final class PushResource
```

Push devices and the project's push provider under `/v1/push`. Get it from [`Ovok.push()`](/java-sdk/reference/ovok#push).

## Methods [#methods]

### devices [#devices]

```java
public PushResource.Devices devices()
```

Returns the signed-in person's push devices.

**Returns:** the devices resource

### provider [#provider]

```java
public PushResource.Provider provider()
```

Returns the project's push provider, for project admins.

**Returns:** the provider resource

## PushResource.Devices [#pushresourcedevices]

```java
public static final class Devices
```

The devices the signed-in person receives push on, each their own.

### Devices.register [#devicesregister]

```java
public JsonNode register(
        Object device,
        RequestOptions options) throws IOException, InterruptedException
```

Registers a device token to the signed-in person; the same token again answers the same device (`POST /v1/push/devices`).

**Parameters:**

- `device`: the `token`, `platform` (`ios`, `android` or `web`) and optional `appId`
- `options`: per-request options, such as the timeout

**Returns:** the device, never with its token

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Devices.list [#deviceslist]

```java
public JsonNode list(RequestOptions options) throws IOException, InterruptedException
```

Lists the signed-in person's devices (`GET /v1/push/devices`).

**Parameters:**

- `options`: per-request options, such as the timeout

**Returns:** the response body, with the devices under `devices`

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Devices.unregister [#devicesunregister]

```java
public void unregister(String id, RequestOptions options) throws IOException, InterruptedException
```

Removes a device, which then gets no more push (`DELETE /v1/push/devices/{id}`).

**Parameters:**

- `id`: the device id
- `options`: per-request options, such as the timeout

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

## PushResource.Provider [#pushresourceprovider]

```java
public static final class Provider
```

The provider the project's push goes through (`fcm`, `apns`, `expo` or `relay`).

### Provider.retrieve [#providerretrieve]

```java
public JsonNode retrieve(RequestOptions options) throws IOException, InterruptedException
```

Reads the push provider and its settings, never a secret (`GET /v1/push/provider`).

**Parameters:**

- `options`: per-request options, such as the timeout

**Returns:** the provider

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Provider.create [#providercreate]

```java
public JsonNode create(
        Object provider,
        RequestOptions options) throws IOException, InterruptedException
```

Sets up the push provider; a relay's signing secret is answered this once (`POST /v1/push/provider`).

**Parameters:**

- `provider`: the `provider` name and its credentials
- `options`: per-request options, such as the timeout

**Returns:** the provider as set up

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Provider.update [#providerupdate]

```java
public JsonNode update(
        Object changes,
        RequestOptions options) throws IOException, InterruptedException
```

Changes the push provider (`PATCH /v1/push/provider`).

**Parameters:**

- `changes`: the `provider` set up, and the fields to change
- `options`: per-request options, such as the timeout

**Returns:** the provider after the change

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Provider.remove [#providerremove]

```java
public void remove(RequestOptions options) throws IOException, InterruptedException
```

Removes the push provider; no push is sent until one is set up again (`DELETE /v1/push/provider`).

**Parameters:**

- `options`: per-request options, such as the timeout

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response
