Skip to main content

Overview

useNotificationPreferences reads and updates the signed-in user’s push notification preferences — the set of event types they’ve disabled for push. Use it to build a notification-settings screen with a per-type toggle. Disabling a type suppresses push only — the in-app notification is still written, so the bell/inbox is unaffected. A user with no preferences is all-on (disabledTypes is []).
Requires an authenticated user and the push bundle installed on the project.

Usage Example

Returns

The hook returns an object:
disabledTypes
PushEventType[] | undefined
The event types the user has disabled for push. undefined until the read resolves; [] when nothing is disabled (all-on).
loading
boolean
true while the initial read is in flight.
updating
boolean
true while an update is in flight.
error
unknown
The read error, if any.
refetch
() => void
Re-fetch the preferences.
updatePreferences
(disabledTypes: PushEventType[]) => Promise<void>
Replace the disabled-types set (upsert). Pass the complete set you want stored, not a delta. Only valid event type names are accepted; unknown names are rejected server-side.

Notes

  • Available on @sublay/react-js, @sublay/react-native, and @sublay/expo (inherited from @sublay/core).
  • The full list of valid type names is exported as PUSH_EVENT_TYPES. See the event palette.
  • For per-conversation muting, see useMuteConversation.