im-quick-start.ts TypeScript
import FeiyanIM from '@feiyan/im-sdk';
// 1. Init: get the AppID from the app details in the console
const im = FeiyanIM.init({ appId: 'YOUR_APP_ID' });
// 2. Connect (auto-reconnect after a drop, offline messages are re-delivered)
await im.connect({ userId: 'user_1001', token });
// 3. Send a message: one API for direct chats, groups and chat rooms
await im.sendMessage({
target: 'group_2001',
type: 'text',
content: 'Hello, FeiyanCloud',
});
// 4. Listen for messages and read receipts
im.on('message', (msg) => console.log(msg));
im.on('readReceipt', (r) => {
console.log(`${r.readCount}/${r.totalCount}`, r.readUserIds);
});