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:
Identifier | Enabled | Push | SMS | ||
---|---|---|---|---|---|
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.
- JavaScript
- iOS
- Android
- React Native
import dx from 'lib/dashx'
const preferenceData = await dx.fetchStoredPreferences();
// ... modify preferenceData ...
dx.saveStoredPreferences(preferenceData);
DashX.fetchStoredPreferences { response in
// ...
} failureCallback: { error in
// ...
}
DashX.saveStoredPreferences(preferenceData: dictionary) { response in
// ...
} failureCallback: { error in
// ...
}
DashXClient.getInstance().fetchStoredPreferences(onSuccess = {
// ...
}, onError = {
// ...
})
DashXClient.getInstance().saveStoredPreferences(Gson().toJsonTree(preferenceData, StoredPreferencesResponse::class.java), onSuccess = {
// ...
}, onError = {
// ...
})
import DashX from '@dashx/react-native';
const preferenceData = await DashX.fetchStoredPreferences();
// ... modify preferenceData ...
DashX.saveStoredPreferences(preferenceData);