Agora chat sdk Introduction
This version is a preview and should only be used for testing purposes. For production use, please revert to the official stable release. If you require the use of this preview version, please contact Agora.io for assistance.
Version: Web SDK 1.2.2.3 Preview
Agora chat sdk provides complete instant messaging function development capabilities, shields/encapsulate and block its internal complex details, and provides a relatively simple and concise API interface to facilitate third-party applications to quickly integrate instant messaging functions for PC/mobile Web applications
Chat SDK can be integrated in the following way:
- Install
npm install agora-chat --save
- Import agora-chat
import AC from 'agora-chat';
- Initialize the SDK
const conn = new AC.connection({
appKey: '<your app key>',
});
- Login chat server
const options = {
user: 'userID',
agoraToken: 'agoraToken',
};
conn.open(options);
- Send a message
let option = {
chatType: 'singleChat',
type: 'txt',
to: 'userID',
msg: 'message content',
};
let msg = AC.message.create(option);
conn.send(msg)
.then(() => {
console.log('send private text Success');
})
.catch((e) => {
console.log('Send private text error');
});
Reference
Related resources
- Check our FAQ to see if your issue has been recorded.
- Dive into Agora SDK Samples to see more tutorials
- Take a look at Agora Use Case for more complicated real use case
- Repositories managed by developer communities can be found at Agora Community
- If you encounter problems during integration, feel free to ask questions in Stack Overflow