Agora chat sdk Introduction
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