Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-native-agora-chat

AgoraIO1.5kMIT1.3.4TypeScript support: included

react native chat sdk

react-native, ios, android, chat, im, agora, sdk

readme

English | Chinese

Update time: 2022-08-11

react-native-agora-chat

Instant messaging connects people wherever they are and allows them to communicate with others in real time. The Agora Chat SDK enables you to embed real-time messaging in any app, on any device, anywhere.

Directory description

├── CHANGELOG.md // Release notes document
├── CONTRIBUTING.md // Contributor documentation
├── LICENSE // License file
├── README.md // Project help documentation
├── README.zh.md // Project help documentation (Chinese version)
├── android // react native SDK android platform folder
├── docs // docs folder
├── example // project built-in demo
├── examples // Independent demo outside the project
├── ios // react native SDK ios platform folder
├── lib // react native SDK generates product folder
├── native_src // react native SDK native source code folder
├── node_modules // react native depends folder, generated by yarn or npm command
├── package.json // react native project management file
├── scripts // react native script folder
├── src // react native source code folder
├── tsconfig.build.json // typescript language build configuration file
├── tsconfig.json // typescript language configuration file
└── yarn.lock // yarn project dependency version configuration file

Project development environment requirements

The requirements are as follows:

  • React Native 0.63.4 or above
  • NodeJs 16 or above
  • Xcode 12.4 or above for iOS application
  • Android Studio 4.2 or above for Android application

For details, please refer to the Quick Start demo. Portal

Add SDK to existing application

Open the terminal and go to the existing project folder to add SDK dependencies:

yarn add react-native-agora-chat

or

npm i --save react-native-agora-chat

General Usage

Initialization SDK

ChatClient.getInstance()
  .init(
    new ChatOptions({
      appKey: '<your app key>',
    })
  )
  .then(() => {
    console.log('init success');
  })
  .catch((reason) => {
    console.log('init fail:', reason);
  });

Login

ChatClient.getInstance()
  .loginWithToken('<your account ID>', '<your token>')
  .then((value: any) => {
    console.log(`login success`, value);
  })
  .catch((reason: any) => {
    console.log(`login fail:`, reason);
  });

Others

Please refer to the corresponding example or method description.

quick start

See the Quick Start documentation for details. Portal

For more examples, see here.Portal

Contributors

See Contributor Guide for details. Portal.

Release Notes

See the changelog for details. Portal.

Release type description

See version type description for details. Portal.

Developer Instructions

See developer instructions for details. Portal.

User Instructions

See the User Instructions Portal for details.

License

MIT

Q & A

If you encounter problems, please refer to here. Portal.

References

Official website document address

changelog

English | Chinese

Update Log

1.3.4

  • Fixed the crash case with receive recall notification for ios platform.

1.3.2

  • Fixed the issue of compilation error on the Android platform for react native 0.76 version.

1.3.1

  • The dependent native SDKs are upgraded to versions (iOS 4.10.2 and Android 4.10.3).
  • native: Fixed the issue where the second request to get the friend list (including friend remarks) from the server would not get data if there was no change in the friend list.
  • native: Fixed the issue where the message would still be sent successfully when the attachment failed to send under special circumstances.
  • native: Fixed the issue of incorrect nextkey when pulling roaming messages.
  • native: Optimized the success rate of server connection under weak network conditions.
  • native: Fixed the issue where the cache was not updated in time when blacklisting contacts.
  • native: Fixed the issue where push notifications might not work after logging out and logging back in.
  • Fixed the issue of compilation error on the Android platform where CMakeLists.txt could not be found.
  • Fixed the issue of data conversion error in push notification type on the Android platform.

1.3.0

  • The dependent native SDKs are upgraded to versions (iOS 4.5.0 and Android 4.5.0). Adds new features and fixed issues provided by the native SDK.
  • Added global configuration options
    • enableTLS: Whether to enable security policy. Off by default.
    • messagesReceiveCallbackIncludeSend: Whether the message listener receives callback notifications for sent messages. Off by default.
    • regardImportMessagesAsRead: Whether to set messages imported by the server as read.
    • useReplacedMessageContents: When the content of the sent text message is replaced by the text moderation (Moderation) service, whether it needs to be returned to the sender.
  • Added message callback notification
    • onMessagePinChanged: Receive notification of pinned message.
  • Added multi-device events
    • CONVERSATION_UPDATE_MARK: Multi-device session mark update notification.
  • Added message manager related interfaces
    • addRemoteAndLocalConversationsMark: Add conversation mark.
    • deleteRemoteAndLocalConversationsMark: Delete the conversation mark.
    • fetchConversationsByOptions: Get the conversation list with specified conditions.
    • deleteAllMessageAndConversation: Delete all conversations and messages of the conversation.
    • pinMessage: pinned message.
    • unpinMessage: Unpin the message.
    • fetchPinnedMessages: Get the pinned messages of the specified session.
    • getPinnedMessages: Get the local pinned messages of the specified session.
    • getMessagePinInfo: Get the pinned message details.
  • Added message attributes
    • isContentReplaced: Whether the message content has been modified. Main user server-side message auditing. Requires global configuration of useReplacedMessageContents.
    • getPinInfo: Get the pinned details of the message.
  • Obsolete interface description
    • getMessagesWithKeyword: getMsgsWithKeyword replaces this interface.
    • getMessages: getMsgs replaces this interface.
    • getMessageWithTimestamp: getMsgWithTimestamp replaces this interface.
    • getMessagesWithMsgType: getConvMsgsWithMsgType replaces this interface.
    • searchMsgFromDB: getMsgsWithMsgType replaces this interface.

Issues fixed

  • Program crash caused by receiving unsupported multi-device event notifications. Solution: Wrap the unsupported type into an except object and notify the caller through the listener. The modifications involve the Contact Manager, Group Manager, and Chat Room Manager. Related types ChatMultiDeviceEvent.
  • Receiving an unsupported message body type causes the program to crash. Wrap unsupported types into except objects and notify the caller through the listener. Related types ChatMessageType.
  • getConversation、getLatestMessage、getLatestReceivedMessage、getConversationUnreadCount、getConversationMessageCount、markMessageAsRead、markAllMessagesAsRead、 updateConversationMessage、deleteMessage、deleteMessagesWithTimestamp、deleteConversationAllMessages、getMessagesWithMsgType、getMessages、getMessagesWithKeyword、 getMessageWithTimestamp, setConversationExtension, removeMessagesFromServerWithMsgIds, removeMessagesFromServerWithTimestamp, increment parameter isChatThreaddefaults tofalse`.
  • The createSendMessage interface has changed from a private claim to a public one.
  • fetchMembersWithChatThreadFromServer changes the return value type
  • ChatTextMessageBody changed the property name from targetLanguages to targetLanguageCodes
  • Add downloadAttachmentInCombine and downloadThumbnailInCombine api.
  • Supports log output in multi-tag mode.

New Features

  • The dependent native SDK has been upgraded to version (iOS 4.2.0 and Android 4.2.1). Added new features provided by the native SDK.
  • Added friend remarks. See ChatContact
  • Added global broadcast. See ChatMessage.isBroadcast
  • Added the ability to get the number of joined groups. See ChatGroupManager.fetchJoinedGroupCount
  • Updated the callback notification when a group application is declined. See ChatGroupEventListener.onRequestToJoinDeclined

1.2.2

Issues fixed

  • An issue with the permissionType property during the construction of a ChatGroup object.
  • Added the missing method of getConversationMessageCount API in ChatManager.

1.2.1

Issues fixed

  • create send message: remove secret parameter. secret parameter is generated by server.

1.2.0

New features

  • React-Native upgrade to 0.71.11 from 0.66.5

Improvements

  • Dependent native SDK upgraded to version 4.1.1 (iOS and Android). Add new features provided by the native SDK.
  • Optimize the disconnection notification, separate the notification of the servers active disconnection, and the user can specifically deal with the reason for the servers active disconnection.
  • Optimize git commit specification with commitlint. Code cannot be submitted if it is not in accordance with the specification.
  • Optimize git commit with lefthook. Add sensitive information check with gitleaks.
  • Add merge type message body, create merge message method, and get merge message content method.
  • Support for modifying the content of text messages and adding modification attributes.
  • Added message modification callback notification.
  • Added settings to customize the current device type and name.
  • Added the use of tokens to kick specified devices and kick all devices.
  • Added the use of token to get the list of online devices.
  • Update multi-device notification events.
  • Update connection status notification event.
  • Update message notification event.
  • Update chat room notification event.

Issues fixed

  • Fix the problem that the application crashes due to the addition of emoticon responses under the android platform.

Detail

Rename API

  • deleteAllMessages is renamed deleteConversationAllMessages.
  • onRemoved is renamed onMemberRemoved in ChatRoomEventListener.
  • onUserRemoved is renamed onMemberRemoved in ChatGroupEventListener.
  • onChatRoomDestroyed is renamed onDestroyed in ChatRoomEventListener.
  • onGroupDestroyed is renamed onDestroyed in ChatGroupEventListener.

Updated API

  • getLoggedInDevicesFromServer: add token support.
  • kickDevice: add token support.
  • kickAllDevices: add token support.

Added API

  • fetchConversationsFromServerWithCursor: Get the list of conversations from the server with pagination.
  • fetchPinnedConversationsFromServerWithCursor: Get the list of pinned conversations from the server with pagination.
  • pinConversation: Sets whether to pin a conversation.
  • modifyMessageBody: Modifies a local message or a message at the server side.
  • fetchCombineMessageDetail: Get information about combine type messages.
  • selectPushTemplate: Select the push template with template name for offline push.
  • fetchSelectedPushTemplate: Get selected push template for offline push.

Deprecated API

  • fetchAllConversations: please use fetchConversationsFromServerWithCursor instead.

Update Data Object

  • ChatConversation: add isPinned and pinnedTime properties.
  • ChatMessageType: add COMBINE type message body.
  • ChatMessage: add receiverList property.
  • create send message: add secret parameter.
  • ChatMessageBody: add lastModifyOperatorId, lastModifyTime and modifyCount properties.
  • ChatOptions: add enableEmptyConversation, customDeviceName and customOSType properties.
  • ChatMultiDeviceEvent:添加 CONVERSATION_PINNEDCONVERSATION_UNPINNEDCONVERSATION_DELETED

Add Data Object

  • ChatCombineMessageBody: add combine message body object.

Update Listener

  • ChatConnectEventListener.onUserDidLoginFromOtherDevice: add deviceName parameter.
  • ChatConnectEventListener: add onUserDidRemoveFromServer, onUserDidForbidByServer, onUserDidChangePassword, onUserDidLoginTooManyDevice, onUserKickedByOtherDevice, onUserAuthenticationFailed event notifications.
  • ChatConnectEventListener.onDisconnected: remove code parameter.
  • ChatMultiDeviceEventListener: add onMessageRemoved event notification.
  • ChatMultiDeviceEventListener: add onConversationEvent event notification.
  • ChatMessageEventListener: add onMessageContentChanged event notification.
  • ChatRoomEventListener.onRemoved: add reason parameter.

1.1.2

New features

  • Dependent native SDK upgraded to version 4.0.2 (iOS and Android).
  • Added the api to get the current SDK version.
  • Adds the setMemberAttribute group manager api.
  • Adds the fetchMemberAttributes group manager api.
  • Adds the fetchMembersAttributes group manager api.
  • Adds the fetchHistoryMessagesByOptions chat manager api.
  • Adds the deleteMessagesWithTimestamp chat manager api.

Improvements

  • Remove sensitive information.
  • Improve log.
  • Adds ChatGroupEventListener.onMemberAttributesChanged notification.
  • Updates the fetchHistoryMessages chat manager api.
  • Adds ChatConnectEventListener.onAppActiveNumberReachLimit notification.
  • Optimized file types messages for iOS.

Issues fixed

  • renewAgoraToken: Repair update token interface.
  • Fixed failure to send video messages on android.

1.1.1

Issues fixed

  • fetchJoinedGroupsFromServer fixed the issue that the extended attribute of fetching joined public groups was empty.

1.1.0

New features

  • Upgrades the native platforms iOS and Android to 1.1.0.
  • Adds the function of managing custom chat room attributes.
  • Adds the fetchConversationsFromServerWithPage method to allow users to get the conversation list from the server with pagination.
  • Adds the ChatMessage#messagePriority method to implement the chat room message priority.
  • Adds the removeMessagesFromServerWithTimestamp and removeMessagesFromServerWithMsgIds methods to allow users to delete messages on the server in a unidirectional way.

Improvements

  • Removed the sensitive information from the test data.
  • Changed the inviterUser method in the ChatGroupManager class to inviteUser.
  • Changed GROUP_ADD_USER_WHITE_LIST in the enumeration type ChatMultiDeviceEvent to GROUP_ADD_USER_ALLOW_LIST.
  • Changed GROUP_REMOVE_USER_WHITE_LIST in the enumeration type ChatMultiDeviceEvent to GROUP_REMOVE_USER_ALLOW_LIST.

Issues fixed

  • Some insecure code of native platforms was fixed.
  • An issue where getting a session might fail.
  • The potential deadlock issue caused by a callback method that repeatedly enters the main thread for execution. This issue occurs only on the iOS platform.

1.0.11

What`s new

  • Dependent native SDK upgraded to version 3.9.9 (iOS and Android).

Issues fixed

  • Fixed SDK crash in extreme cases.
  • Other fixes, see versions 3.9.8 and 3.9.9 (iOS and Android).

1.0.10

Issues fixed

  • json conversion on the android platform may have an overlimit problem. If more than 50 data elements are returned, an exception will be thrown. An interface that involves returning arrays.

1.0.9

Improvements

  • The dependent native SDK iOS is upgraded to V3.9.7.1.

Issues fixed

  • Fixed the chat room attribute bug.
  • Updated the group listener.

The following Object are updated:

  • ChatGroupEventListener add onDetailChanged notification.
  • ChatGroupEventListener add onStateChanged notification.

1.0.8

Improvements

  • The dependent native SDK (iOS and Android) is upgraded to V3.9.7.
  • Added chat room custom attribute function.
  • Added group disabled status in group details: isDisabled property, which needs to be set by the developer on the server side.
  • Optimized the performance of getting roaming messages.
  • Added area code for server.

Issues fixed

  • Fixed the problem that in a few scenarios, when the message volume is large when synchronizing or pulling messages, the collection fails.
  • Fixed incorrect data statistics.
  • Fixed a crash caused by printing logs on rare occasions.

The following APIs are added:

  • updatePushNickname: update push display name.
  • updatePushDisplayStyle: update push display style.
  • fetchPushOptionFromServer: get push option from server.
  • fetchChatRoomAttributes: get chat room custom attributes.
  • addAttributes: add chat room custom attributes.
  • removeAttributes: remove chat rom custom attributes.
  • ChatPushDisplayStyle: the push display style.
  • ChatPushOption: the push display option.
  • ChatAreaCode: the area code.

The following APIs are renamed:

  • ChatGroupPermissionType is renamed ChatGroupType.

The following Object are updated:

  • ChatGroupOptions add isDisabled attribute.
  • ChatRoomEventListener add onSpecificationChanged, onAttributesUpdated, onAttributesRemoved attribute.

1.0.7

Improvements

  • The dependent native SDK (iOS and Android) is upgraded to V3.9.5.
  • Support push notification settings operation. see {@link ChatPushManager}
  • Support push config setting for FCM. see {@link ChatPushConfig}
  • Support push initialization Settings. see {@link ChatOptions#pushConfig}
  • Support push config setting update. see {@link ChatClient#updatePushConfig}
  • The listener method has been made optional.
  • Update the release script.
  • sync update demonstration app.

Issues fixed

  • Fix bug: Json parse error for type field.

The following APIs are added:

  • setConversationExtension: set conversation extension.
  • insertMessage: insert a message.
  • deleteMessagesBeforeTimestamp: Deletes messages before the specified timestamp.
  • getThreadConversation: Gets or creates a conversation for thread.

The following APIs are renamed:

  • unSubscribe is renamed unsubscribe.

The following Object are updated:

  • ChatConversation add isChatThread attribute.

1.0.6

New features

  • Add a field {@link ChatMessage#isOnline} in chat messages.

Improvements

  • The API reference example is updated.
  • The dependent native SDK (iOS and Android) is upgraded to V3.9.4.
  • React-Native upgrade to 0.66.4 LTS version.
  • The android platform no longer needs to perform additional operations.
  • agora-react-native-chat was changed to react-native-agora-chat.

The following APIs are renamed:

  • deleteRemoteConversation is renamed removeConversationFromServer.
  • loadAllConversations is renamed getAllConversations.
  • getConversationsFromServer is renamed fetchAllConversations.
  • getUnreadMessageCount is renamed getUnreadCount.
  • fetchLatestMessage is renamed getLatestMessage.
  • fetchLastReceivedMessage is renamed getLatestReceivedMessage.
  • unreadCount is renamed getConversationUnreadCount.
  • getMessagesFromTime is renamed getMessageWithTimestamp.
  • WhiteList is renamed AllowList.
  • BlackList is renamed BlockList.

The following API are deprecated and removed:

  • getMessageById
  • insertMessage
  • appendMessage

Issues fixed

  • Fix bug: Type declaration entry point is incorrect
  • Optimize: The android platform no longer needs to perform additional operations.

1.0.5

  • Implement IM foundation functions.
  • Implement base message send and receive functions.
  • Implement group functions.
  • Implement chat room functions.
  • Implement contact functions.
  • Implement user functions.
  • Implement user presence functions.
  • Implement message moderation functions.
  • Implement message translation functions.
  • Implement message reaction functions.
  • Implement message thread functions.
  • The dependent native SDK (ios and android) was upgraded to version 3.9.3.