Documentation
Search
K
Comment on page

Sending Dapp-to-User Messages

This section assumes you have loaded a dapp as described in the previous section.
Sending notifications to subscribers is a simple abstraction on top of standard Dialect messaging with the added functionality:
  1. 1.
    Messages are only sent to users who have subscribed to receive notifications.
  2. 2.
    Messages are sent according to what channels users have subscribed to — web3 via Dialect's protocol, email, Telegram, or SMS.

Send a notification to a single user

const title = '...';
const message = '...';
const recipient = '<public-key-as-string>';
await dapp.messages.send({
title,
message,
recipient,
});

Send a notification to a set of users

const title = '...';
const mesage = '...';
const recipients = ['<public-key-as-string>', ...];
await dapp.messages.send({
title,
message,
recipients,
});

Send a notification to all users

When no recipient or recipients are defined, Dialect defaults to sending notifications to all subscribed users.
await dapp.messages.send({
title,
message,
});