Channel settings overview
This section covers APIs related to creation of channel setting.
What are channel settings?
A channel may want to send notification for multiple categories. Ex: Coindesk may want to send notifications for tech, marketing, defi and so on. Similarly, Aave may want to send notifciation for certain loan liquidation value.
Having settings for your channel enables your users to express interest on what settings they want to receive notifications for and when they want to receive it.
Once you have enabled channel settings, you can access settings prefrence of each user via Fetch Subscription API. You can also trigger notifications which target particular settings category via Send Notification API.
If a user hasn't opted in for a particular setting and you trigger notification for that setting category then the notification will be filtered out by Push Node.
Channel setting API
- js
// creates channel settings
const createChannelSettingRes = userAlice.channel.setting([
{
type: 1, // Boolean type
default: 1,
description: 'Receive marketing notifications',
},
{
type: 2, // Slider type
default: 10,
description: 'Notify when loan health breaches',
data: { upper: 100, lower: 5, ticker: 1 },
},
]);
Create channel setting parameters
Param | Type | Subtype | Default | Description |
---|---|---|---|---|
type | number | - | - | The type of notification setting. 1 for boolean type and 2 for slider type |
default | number | - | - | The default value for the setting. |
description | string | - | - | A description of the setting. |
data.upper | number | - | - | Valid for slider type only. The upper limit for the setting. |
data.lower | number | - | - | Valid for slider type only. The lower limit for the setting. |
data.ticker | number | - | 1 | Valid for slider type only. The ticker by which the slider moves. |
Note: Parameters
in this style
are mandatory.
Expected response
{
transactionHash: '0xf5056d382f209b5a7bcbf08d69c80dd13079467ba38413da8ca065a45f901a32';
}
Types of channel settings
Push currently supports defining the following settings for your channel —
- Boolean Setting - This setting allows users to set their preference as true / false. For example: receive marketing notifications
- Slider Setting - This setting allows users to set their preference between a slider. For example: alert when ENS domain expires (Between 1 - 7 days)
Type | ID | Description |
---|---|---|
Boolean | 1 | Set a setting to be yes or no, must have a default |
Slider | 2 | Set a setting to be slider, must have upper and lower range and a default |