Data payloads for PubNub Chat Components for React Native

Migrate to Chat SDK

PubNub will stop supporting Chat Components on January 1, 2025 but you are welcome to contribute. Learn how to migrate to the Chat SDK here.

PubNub Chat Components for React Native enforce you to use the unified JSON schemas (data models) for such common entity types as users, channels, and messages when transferring data over the PubNub network. These common data payloads allow you to create cross-platform applications and ensure that such applications developed in different technologies (Swift, Kotlin, or JavaScript) communicate with one another properly, avoiding any unexpected errors.

Data payload validation

To avoid any parsing errors, validate the data payload you prepared for users, channels, and messages in an online validator.

Users

Follow this schema for the user data in your apps:

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "User",
"description": "User of a chat application",
"properties": {
"id": {
"description": "Unique identifier for a user",
"type": "string"
},
"name": {
"description": "Name of the user that you can display in the UI",
"type": "string"
},
"email": {
"description": "User's email address",
show all 46 lines

Example:

{
"id": "some-user-id",
"name": "Jane Doe",
"email": "jane.doe@example.com",
"externalId": "some-external-user-id",
"profileUrl": "https://randomuser.me/api/portraits/men/1.jpg",
"custom": {
"description": "Office Assistant"
},
"eTag": "AYGyoY3gre71eA",
"updated": "2020-09-23T09:23:34.598494Z"
}

Channels

Follow this schema for the channel data in your apps:

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Channel",
"description": "Channel in the chat application",
"properties": {
"id": {
"description": "Unique identifier for a channel",
"type": "string"
},
"name": {
"description": "Name of the channel that you can display in the UI",
"type": "string"
},
"description": {
"description": "Description of the channel that you can display in the UI",
show all 38 lines

Example:

{
"id": "some-channel-id",
"name": "Off-topic",
"description": "Off-topic channel for random chatter and fun",
"custom": {
"profileUrl": "https://www.gravatar.com/avatar/149e60f311749f2a7c6515f7b34?s=256&d=identicon"
},
"eTag": "AbOx6N+6vu3zoAE",
"updated": "2020-09-23T09:23:37.175764Z"
}

Messages

Follow this schema for the message data in your apps:

Supported data types

PubNub Chat Components for React Native support only text message data types.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Message Content",
"description": "Message content in the chat application",
"type": "object",
"properties": {
"id": {
"description": "Unique identifier for a message. Use the UUID v4 algorithm.",
"type": "string"
},
"text": {
"description": "Text of the message that you can display in the UI",
"type": "string"
},
"contentType": {
show all 34 lines

Example:

{
"id": "6da72b98-e211-4724-aad4-e0fb9f08999f",
"text": "Let's sync on the topic in this thread.",
"contentType": "none",
"content": {},
"custom": {},
"createdAt": "2022-05-10T14:48:00.000Z"
}
Last updated on