Skip to content

Latest commit

 

History

766 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | Chinese

Update time: 2026-08-06

Introduction to ChatSDK

An Instant Messaging SDK (Software Development Kit) is a collection of tools, libraries, and APIs designed to integrate real-time messaging capabilities into applications. It allows developers to easily add text, voice, and video communication features into mobile apps, websites, or other platforms without having to build the communication infrastructure from scratch.

Development environment requirements

  • MacOS 12 or higher
  • React-Native 0.76 or higher
  • NodeJs 16.18 or higher

For iOS app:

  • Xcode 13 or higher and its related dependency tool.

For the Android app:

  • Android Studio 2021 or higher and its related dependency tool.

Integrate ChatSDK

npm install react-native-chat-sdk
# or
yarn add react-native-chat-sdk

Note: The SDK only supports the React Native New Architecture. It is the only mode on React Native 0.82 and higher; on React Native 0.76–0.81, enable it by setting newArchEnabled=true in android/gradle.properties and ENV['RCT_NEW_ARCH_ENABLED'] = '1' in ios/Podfile (before use_react_native!).

For iOS, the native HyphenateChat dependency can be integrated in two ways:

  • CocoaPods (default): run pod install in the ios directory as usual.
  • Swift Package Manager (optional): run USE_FRAMEWORKS=dynamic pod install in the ios directory. The HyphenateChat dependency is then resolved through the official SPM package instead of the CocoaPods trunk.

See iOS integration: CocoaPods and Swift Package Manager for details.

Quick start

  1. Initialize SDK

    // Please use appkey or appId for initialization.
    const appKey = '<your app key>';
    const appId = '<your app ID>';
    ChatClient.getInstance()
      .init(
        appKey !== undefined
          ? ChatOptions.withAppKey({
              appKey: appKey,
              autoLogin: false,
            })
          : ChatOptions.withAppId({
              appId: appId,
              autoLogin: false,
            })
      )
      .then(() => {
        console.log('initialization success');
      })
      .catch((reason) => {
        console.error(reason);
      });
  2. Connect to server

    // Connect to server
    const userId = '<your user ID>';
    const userToken = '<your user token>';
    ChatClient.getInstance()
      .loginWithToken(userId, userToken)
      .then((value) => {
        console.log(`login success`, value);
      })
      .catch((reason) => {
        console.error(reason);
      });
  3. Send message

    // Send a message
    ChatClient.getInstance()
      .chatManager.sendMessage(message, {
        onError: (localMsgId: string, error: ChatError) => {
          console.error(error);
        },
        onSuccess: (message: ChatMessage) => {
          console.log(`send success`, message);
        },
      })
      .catch((reason) => {
        console.error(reason);
      });

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

环信 IM React Native SDK,用于快速集成聊天功能。

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages