# Register push device

Canonical page: https://docs.ovok.com/flutter-sdk/reference/ovok_sdk/register-push-device

{/* Generated by scripts/generate_reference.dart; do not edit. */}

## PushDeviceUnsubscribe [#pushdeviceunsubscribe]

```dart
typedef PushDeviceUnsubscribe = Future<void> Function()
```

Stops re-registering on token refresh and removes the device from Ovok, so it gets no more push.


## registerPushDevice [#registerpushdevice]

```dart
Future<PushDeviceUnsubscribe> registerPushDevice(Ovok ovok, {required Future<String?> Function() token, required Stream<String> onTokenRefresh, required String platform, String? appId})
```

Registers this device for push to the signed-in person, and registers it again whenever its token changes.

The app supplies its own token source, such as firebase_messaging: `token` reads the current token and
`onTokenRefresh` emits each new one. `platform` is `ios`, `android` or `web`; `appId` is the app's bundle or
package id. Ask for notification permission first, and call it after sign-in.

Throws a `StateError` when `token` has no token yet. Completes with a function that stops listening for
token changes and removes the device from Ovok; call it on sign-out, before the session ends.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `ovok` | `Ovok` | positional |  |
| `token` | `Future<String?> Function()` | required named |  |
| `onTokenRefresh` | `Stream<String>` | required named |  |
| `platform` | `String` | required named |  |
| `appId` | `String?` | named |  |
