imsdkweb
TypeScript icon, indicating that this package has built-in type declarations

0.0.53 • Public • Published

Tmmtmm SDK

Initialize SDK

const sdk = IMSdk.getInstance('你的ak', IMEnvironmentType.alpha);
sdk.setDelegate({
    authCodeExpire(auid) {
        if (constants.authcode.length > 0) {
            sdk.setAuthCode(constants.authcode);
            return;
        }
        onGetAuth().then(() => {
            sdk.setAuthCode(constants.authcode);
        });
    },
    onShowUserInfo(auids) {
        const infos: UserInfo[] = [];
        sdk.setUserInfo(infos);
    },
});

Init User

sdk.initUser(auid)

Create Chat

sdk.createChat({
    gid: '会话Id',
    auids: ['用户Id'],
    chatName: '会话名',
    delegate: {
        onSucc: () => {
            console.log('create chat success');
        },
        onError: res => {
            console.log(res);
        },
    },
});

Send Text Message

sdk.sendTextMessage({
    gid,  //会话Id
    amid,    //消息Id
    content  //文本内容
})

Send Image Message

sdk.sendImageMessage({
    gid,  //会话Id
    amid,    //消息Id
    data  //图片blob文件
})

Send Attachment Message

sdk.sendAttachmentMessage({
    gid,  //会话Id
    amid,    //消息Id
    data  //附件blob文件
})

Readme

Keywords

none

Package Sidebar

Install

npm i imsdkweb

Weekly Downloads

1

Version

0.0.53

License

UNLICENSED

Unpacked Size

1.65 MB

Total Files

298

Last publish

Collaborators

  • tmmtmm01