0
点赞
收藏
分享

微信扫一扫

环信API方法介绍


安装

如果你的项目使用Maven构建并且spring boot是2.4.3以上版本,可以在pom.xml中添加下面代码:

<dependency>
    <groupId>com.easemob.im</groupId>
    <artifactId>im-sdk-core</artifactId>
    <version>0.2.5</version>
</dependency>

如果你使用的spring-boot是2.4.3以下版本的,还需要在pom.xml中添加:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-bom</artifactId>
            <version>4.1.59.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-bom</artifactId>
            <version>2020.0.4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

准备

在使用Server SDK之前,需要准备环信appkey、Client ID、ClientSecre。

如果你有环信管理后台账号并创建过应用,请先登录环信管理后台,点击 这里,然后到“应用列表” → 点击“查看”即可获取到appkey、Client ID、ClientSecret。

环信API方法介绍_spring

使用

EMService是所有API的入口,可以这样初始化:

EMProperties properties = EMProperties.builder()
        .setAppkey(cliProperties.getAppkey())
        .setClientId(cliProperties.getClientId())
        .setClientSecret(cliProperties.getClientSecret())
        .build();

EMService service = new EMService(properties);

根据业务资源,API分为:

  • Attachment 用于上传下载附件
  • Block 用于限制访问
  • Contact 用于管理联系人
  • Group 用于管理群组
  • Message 用于发送消息
  • User 用于管理用户
  • Room 用于管理聊天室
举报

相关推荐

0 条评论