Skip to content

Handle user consent in group chat

In addition to permissions that enable designated members to add and remove members from a group chat, you can apply user consent preferences to group chats to prevent unwanted contacts. There are consent preferences that enable a user to allow or deny contact from a group ID, inbox ID, or address in a group chat context.

For example, the Group protocol provides the added_by_inbox_id method to find out who has initiated the user into a group chat. Apps can compare this inboxId using the standard isInboxIdAllowed() or isInboxIdDenied() functions on the contacts to determine how and whether the group should be listed and how and whether messages are displayed based on the design of the app and the user's settings.

Allow or deny contact by wallet in group chat

React Native
// Allow
await contact.allow([walletAddress]);
 
// Deny
await contact.deny([walletAddress]);

Allow or deny contact by inbox ID in group chat

React Native
// Allow
await contact.allowGroup([groupId]);
 
// Deny
await contact.denyGroup([groupId]);

Allow or deny contact by group chat ID

React Native
// Allow group
await contact.allowGroup([groupId]);
 
// Deny a group
await contact.denyGroup([groupId]);

Allow or deny contact from inbox ID

Enable a user to explicitly allow or deny contact from an inbox ID.

React Native
// Allow
await client.contacts.allowInboxes([client.inboxId]);
 
// Deny
await client.contacts.denyInboxes([client.inboxId]);

Check consent for group chat ID

Check if contact from a group chat ID is allowed or denied for a user.

React Native
// Check if contact by a group is allowed for a member
const isAllowed = await group.isGroupAllowed(groupId);
 
// Check if contact by a group is denied for a member
const isDenied = await group.isGroupDenied(groupId);

Check consent for inbox ID

Check if contact from an inbox ID is allowed or denied for a user.

React Native
await client.contacts.isInboxAllowed(client.inboxId);

Stream user consent

To learn how to stream user consent preferences, see Stream the consent list.

Synchronize user consent

To learn how to keep user consent preferences synchronized, see Synchronize user consent preferences.