# ovok.push

Canonical page: https://docs.ovok.com/web-sdk/core/namespaces/push

`ovok.push` has two halves. `devices` is the app's side: register the device a person signed in on, list their devices and remove one. `provider` holds the project's push provider and is for project admins. Providers are `fcm`, `apns`, `expo` and `relay`, which posts each push to an HTTPS endpoint of your own.

## Register a device [#register-a-device]

```ts
const device = await ovok.push.devices.register({
  token: expoPushToken,
  platform: 'ios',
  appId: 'com.example.care',
});
```

- Register after sign-in, and again whenever the token changes. Registering the same token again answers the same device.
- The device belongs to the signed-in profile: a patient, practitioner or related person.
- The token is never returned. `list` shows each device's `id`, `platform`, `appId` and `registeredAt`.

## Remove a device [#remove-a-device]

```ts
await ovok.push.devices.unregister(device.id);
```

- Call it on sign-out, so the device gets no more push for that person.

## Set up the provider [#set-up-the-provider]

```ts
const { secret } = await ovok.push.provider.create({ provider: 'relay', url: 'https://push.example.com/ovok' });

await ovok.push.provider.update({ provider: 'apns', environment: 'production' });
await ovok.push.provider.remove();
```

- `create` checks the credentials with the provider first. A relay's `whsec_` signing secret is answered this once; store it where your relay verifies requests.
- `retrieve` shows the provider and its settings, never a secret.
- `update` names the provider set up. To switch providers, `remove` the old one and `create` the new one.
- The calls go to `v1/push/devices` and `v1/push/provider`.

## See also [#see-also]

- [push API reference](../reference/core/push.mdx): every method and type.
- [ovok.omnichannelAlerts](./omnichannelalerts.mdx) for the rule that decides who hears of each alert.
- [Errors and retries](../errors-and-retries.mdx)
