Skip to main content

Type Alias: UsePushNotificationsOptions

UsePushNotificationsOptions = object

Defined in: usePushNotifications.ts:15

Properties​

enabled?​

optional enabled?: boolean

Defined in: usePushNotifications.ts:37

Set to false where no service worker is registered (local dev), and the hook reports unsupported. Defaults to true.


onError?​

optional onError?: (error) => void

Defined in: usePushNotifications.ts:32

Called with every unexpected error, for error tracking.

Parameters​

ParameterType
errorError

Returns​

void


onSubscribe​

onSubscribe: (subscription) => Promise<void>

Defined in: usePushNotifications.ts:24

Persists a new subscription. A rejection unsubscribes the browser again, so the browser and the server never disagree.

Parameters​

ParameterType
subscriptionPushSubscriptionData

Returns​

Promise<void>


onUnsubscribe​

onUnsubscribe: (subscription) => Promise<void>

Defined in: usePushNotifications.ts:28

Removes a subscription before the browser drops it.

Parameters​

ParameterType
subscription{ endpoint: string; }
subscription.endpointstring

Returns​

Promise<void>


vapidPublicKey​

vapidPublicKey: string | undefined

Defined in: usePushNotifications.ts:19

The server's VAPID public key, base64url encoded.