Chat Provider for PubNub Chat Components for React Native

USED BY THE OLD IA, PLEASE DISREGARD

Chat provider is used to configure various common options and feed the components with data. It expects at least currentChannel to display within components.

Chat itself is supposed to be wrapped with a PubNubProvider component that is a part of the PubNub React SDK. You should use it to pre-configure your PubNub instance. Read the Getting Started page for details.

Parameters​

You can configure the component using these parameters:

theme?#
Type: "light", "dark"
General theme to be used by the components. Exact looks can be tweaked later on by injecting styles.
Default value
"light"
currentChannel#
Type: string
Current channel to display the messages and members from.
Default value
n/a
channels?#
Type: string[]
Array of channels to subscribe to get events. Allows up to 50 channels. Setting this option will disable the auto subscription when switching the current channel.
Default value
[]
channelGroups?#
Type: string[]
Array of channel groups to subscribe to get events. Allows up to 50 channel groups. Setting this option will disable the auto subscription when switching the current channel group.
Default value
[]
enablePresence?#
Type: boolean
Option to disable presence events when set to false. OccupancyIndicator and MemberList components will only work with memberships in that case.
Default value
true
users?#
Type: UserEntity[]
Option to provide an external list of user metadata. It's used to display information about senders on MessageList and TypingIndicator.
Default value
[]
getUser?#
Type: (userId: string) => UserEntity or (userId: string) => Promise<UserEntity>
Pass a callback function to get user metadata whenever it's not passed to the users option.
Default value
n/a
typingIndicatorTimeout?#
Type: number
Option to define a timeout in seconds for typing indicators to hide after the last typed character.
Default value
10
retryOptions?#
Type: RetryOptions
Options for automatic retries on errors.
Default value
retryOptions: {maxRetries: 1, timeout: 0, exponentialFactor: 1}
onMessage?#
Type: (message: MessageEnvelope) => unknown
Callback run on new messages.
Default value
n/a
onSignal?#
Type: (message: SignalEvent) => unknown
Callback run on signals.
Default value
n/a
onMessageAction?#
Type: (event: MessageActionEvent) => unknown
Callback run on message actions.
Default value
n/a
onPresence?#
Type: (event: PresenceEvent) => unknown
Callback run on presence events.
Default value
n/a
onUser?#
Type: (event: BaseObjectsEvent) => unknown
Callback run on object events.
Default value
n/a
onChannel?#
Type: (event: BaseObjectsEvent) => unknown
Callback run on object events.
Default value
n/a
onMembership?#
Type: (event: BaseObjectsEvent) => unknown
Callback run on object events.
Default value
n/a
onFile?#
Type: (event: FileEvent) => unknown
Callback run on file events.
Default value
n/a
onStatus?#
Type: (event: StatusEvent) => unknown
Callback run on status events.
Default value
n/a
onError?#
Type: (error: Error) => unknown
Callback run on any type of errors raised by the components.
Default value
(): void => null

Was this page useful?

Last updated on