easemob-websdk

    3.6.3 • Public • Published

    环信IM SDK介绍

    sdk提供完整的即时消息功能开发功能,屏蔽/封装并阻止其内部复杂的细节,并提供相对简单和简洁的API接口,以方便第三方应用程序快速集成PC/mobile Web应用程序的即时消息功能

    可以通过以下方式引用 WebSDK:

    1. 安装
    npm install easemob-websdk --save
    
    1. 引入SDK。
    import websdk from 'easemob-websdk'
    
    1. 初始化SDK
    const WebIM = {}
    const conn = WebIM.conn = new websdk.connection({
        appKey: 'your app key',
        isHttpDNS: true,
        https: true
    })
    1. 登录环信服务
    const options = { 
      user: 'username',
      pwd: 'password',
      appKey: 'your app key'
    };
    conn.open(options);
    1. 发送消息
    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);

    Keywords

    none

    Install

    npm i easemob-websdk

    DownloadsWeekly Downloads

    476

    Version

    3.6.3

    License

    ISC

    Unpacked Size

    260 kB

    Total Files

    3

    Last publish

    Collaborators

    • liu48566203
    • wk3368
    • easemob