# Tmmtmm SDK

## Initialize SDK

```typescript
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

```typescript
sdk.initUser(auid)
```

## Create Chat

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

## Send Text Message

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

## Send Image Message

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

## Send Attachment Message

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