Skip to main content

User Preferences

Preferences gives your users the ability to control which notification topics they receive, through the channels of their choice.

DashX returns the Stored Preferences of a User in the following format:

{
"my-preference-1": {
"enabled": true,
"email": true,
"push": false,
"sms": false,
"whatsapp": false
},
"my-preference-2": {
"enabled": false,
"email": true,
"push": true,
"sms": true,
"whatsapp": true
}
}

Here is the same data represented as a table:

IdentifierEnabledEmailPushSMSWhatsApp
my-preference-1
my-preference-2

For a User to receive a template gated by a specific preference, their stored preference must have enabled set to true, and the individual channel settings to be true. If enabled is set to false, then the individual channel settings are disregarded.

import dx from 'lib/dashx'

const preferenceData = await dx.fetchStoredPreferences();

// ... modify preferenceData ...

dx.saveStoredPreferences(preferenceData);