Types of notification overview
Before sending notifications, it's important to learn about their types to help in choosing what notifications you want to send and when.
Types of Notification
Push Protocol supports sending the following types of notifications to users of your protocol —
Notification Type | Identifier | Description |
---|---|---|
Broadcast | 1 | This type of notification is broadcasted or sent to all the subscribers of a channel at once. |
Targeted | 3 | This type of notification is sent to a single wallet address. |
Subset | 4 | This type of notification is sent to a a subset (or a group) of your channel subscribers. |
Broadcast Notification (Type 1)
This type of notification is broadcasted or sent to all the subscribers of a channel at once.
// userAlice.channel.send([recipients], {options?})
// to send a broadcast notification - pass '*' in recipients array
const broadcastNotif = await userAlice.channel.send(['*'], {
notification: { title: 'test', body: 'test' },
});
Targeted Notification (Type 3)
This type of notification is sent to a single wallet address.
// userAlice.channel.send([recipients], {options?})
// to send a targeted notification - pass that single wallet address in recipients array
const targetedNotif = await userAlice.channel.send(
['0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666'],
{
notification: {
title: 'test',
body: 'test',
},
}
);
Subset Notification (Type 4)
This type of notification is sent to a a subset (or a group) of your channel subscribers.
// userAlice.channel.send([recipients], {options?})
// to send a subset notification - pass the list of wallet address in recipients array
const subsetNotif = await userAlice.channel.send(
[
randomWallet1,
randomWallet2,
signer.address,
'0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666',
],
{
notification: {
title: 'test',
body: 'test',
},
}
);