Manage subscriptions overview
These APIs are useful for managing subscriptions for specific channels including subscribing to a channel, indicating settings for a channel or unsubscribing from a channel.
Subscribe channel API
Channel is any protocol that has activated themselves to send notifications. User needs to subscribe to a channel to enable that channel notifications to come to their inbox (and not land in spam). User can also setup settings along with a channel subscription though it's upto the channel to honor those.
- js
// userAlice.notification.subscribe(channel, {settings?})
const response = await userAlice.notification.subscribe(
`eip155:11155111:${channelAddress}`
);
// Another example but with settings
const response = await userAlice.notification.subscribe(
`eip155:11155111:${channelAddress}`,
{
settings: [
// settings are dependent on channel
{ enabled: true, value: '1' }, // setting 1
{ enabled: false }, // setting 2
{ enabled: true, value: '50' }, // setting 3
],
}
);
Subscribe channel parameters
Param | Type | Subtype | Default | Remarks |
---|---|---|---|---|
channel | string | - | - | Channel/Alias address in chain specific wallet format |
settings | array of objects | - | - | Contain array of individual setting object |
Note: Parameters
in this style
are mandatory.
Individual setting object
Param | Type | Subtype | Default | Remarks |
---|---|---|---|---|
setting | object | - | - | Individual setting object |
- | enabled | boolean | true | Indicates if setting is enabled or disabled |
- | value | string | - | The value set by the user |
Expected response
{ status: 204, message: 'successfully opted into channel' }
Unsubscribe channel API
- js
// userAlice.notification.unsubscribe(channel)
const unsubscribeResponse = await userAlice.notification.unsubscribe(
`eip155:11155111:${channelAddress}` // channel to unsubscribe
);
Unsubscribe channel parameters
Param | Type | Subtype | Default | Remarks |
---|---|---|---|---|
channel | string | - | - | Channel/Alias address in CAIP format |
Note: Parameters
in this style
are mandatory.
Expected response
{ status: 204, message: 'successfully opted out channel' }