Package Exports
- easemob-websdk
- easemob-websdk/Easemob-chat.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (easemob-websdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
环信 IM SDK 介绍
sdk 提供完整的即时消息功能开发功能,屏蔽/封装并阻止其内部复杂的细节,并提供相对简单和简洁的 API 接口,以方便第三方应用程序快速集成 PC/mobile Web 应用程序的即时消息功能
可以通过以下方式引用 WebSDK:
- 安装
npm install easemob-websdk --save- 先引入,再访问 WebIM。
import websdk from 'easemob-websdk'3、初始化 SDK
const WebIM = {};
const conn = (WebIM.conn = new websdk.connection({
appKey: 'your app key',
}));4、登录环信服务
const options = {
user: 'username',
pwd: 'password',
};
conn.open(options);5、发送消息
let id = conn.getUniqueId();
let msg = new WebIM.message('txt', id);
msg.set({
msg: 'message content',
to: 'username',
chatType: 'singleChat',
success: function () {
console.log('send private text Success');
},
fail: function (e) {},
});
conn.send(msg.body);