快速开始

JS SDK for relation IM 提供简单的API来构建即时通讯服务。

Quick start

使用NPM下载

npm install --save @relationlabs/im
npm install --save @relationlabs/auth

then

通过 authByMetamask 唤醒 Metamask 签名并获取 addressAuthToken

import { authByMetamask } from "@relationlabs/auth";

const { error, token: addressAuthToken } = await authByMetamask()

then

通过 getRelationToken 获取 unifiedAuthTokenAPIKEY 需从管理员处获取

import RelationIM from "@relationlabs/im";
import { authByMetamask } from "@relationlabs/auth";

const { error, token: addressAuthToken } = await authByMetamask()

const APIKEY = '581c6c4fa0b54912b00088aa563342a4'

if (!error && addressAuthToken) {
    const { error, token: unifiedAuthToken } = await RelationIM.getRelationToken(addressAuthToken, APIKEY)
    if (!error && unifiedAuthToken) {

    }
}

then

初始化 im 实例

const myIm = RelationIM.init({token: unifiedAuthToken, apiKey: APIKEY, connect: true})

Last updated